【发布时间】:2019-12-08 19:40:12
【问题描述】:
我需要用 C# 编写的 azure 函数将消息推送到服务总线上。我在网上看到的示例展示了如何在新消息发生时触发 azure 函数。
有例子吗?
当前的天蓝色函数(C#)
[FunctionName("IHandleMessage")]
public void Run([ServiceBusTrigger("my.topic", "my.subscription", Connection = "mybus_SERVICEBUS")]string mySbMsg, ILogger log)
{
// send new message?
}
非常感谢! J
更新
如何在 azure 函数中创建新消息
public void Run([ServiceBusTrigger("my.topic", "my.subscription", Connection = "mybus_SERVICEBUS")]string mySbMsg, ILogger log)
{
ServiceBusOutput("hello", log); // Create a new message
}
[FunctionName("AnotherEvent")]
[return: ServiceBus("my.other.queue", Connection = "mySERVICEBUS")]
public static string ServiceBusOutput([HttpTrigger] dynamic input, ILogger log)
{
log.LogInformation($"C# function processed: {input.Text}");
return input.Text;
}
【问题讨论】:
标签: c# visual-studio-code azure-functions azureservicebus