我已创建Azure服务总线主题触发器。不知道为什么它没有从主题的订阅中提取消息。我使用Visual Studio 2022登录到组织Azure帐户,在Azure中将我的用户角色设置为读取器/写入。
使用以下版本:
<ItemGroup>
<PackageReference Include="Microsoft.Azure.Functions.Worker" Version="1.19.0" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.ServiceBus" Version="5.13.0" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Sdk" Version="1.15.1" />
</ItemGroup>
和local.settings.json作为
{
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "UseDevelopmentStorage=true",
"FUNCTIONS_WORKER_RUNTIME": "dotnet-isolated",
"ServiceBusConnectionString__fullyQualifiedNamespace": "xxxxxx.servicebus.windows.net"
}
}
其功能简单如下:
[Function(nameof(ServiceBusTrigger))]
public void Run([ServiceBusTrigger("xxxx", "yyyy", Connection = "ServiceBusConnectionString")] ServiceBusReceivedMessage message)
{
_logger.LogInformation("Message ID: {id}", message.MessageId);
_logger.LogInformation("Message Body: {body}", message.Body);
_logger.LogInformation("Message Content-Type: {contentType}", message.ContentType);
}
函数启动,确认消息在订阅队列中:
Azure Functions Core Tools
Core Tools Version: 4.0.5413 Commit hash: N/A (64-bit)
Function Runtime Version: 4.25.3.21264
[2023-10-19T00:32:59.110Z] Found C:\SCM\Poc\functions\ServiceBusTopicDemo\LocalFunctionProj\LocalFunctionProj.csproj. Using for user secrets file configuration.
[2023-10-19T00:33:01.599Z] Worker process started and initialized.
Functions:
ServiceBusTrigger: serviceBusTrigger
For detailed output, run func with --verbose flag.
[2023-10-19T00:33:05.890Z] Host lock lease acquired by instance ID '000000000000000000000000C8B5EEE0'.
1条答案
按热度按时间zbq4xfa01#
日志记录输出实际上是在获取消息数据吗?我已经做了完全相同的集成与队列,而不是主题,它的工作很好。
我看到你的 *ServiceBusConnectionString * 和你的 local.settings.json 中定义的不一样,如果设置不正确就会这样。
除此之外,一切都很好.