从配置中读取主题名称为Azure功能服务总线触发不工作

问题描述 投票:0回答:2
提出问题

public async Task MyFunctionAsync( [ServiceBusTrigger("%TopicName%", "data-subscription", Connection = "event-bus-connection")] string mySbMsg) { } 在我的localsettings.json文件中我有

"bindings": [ { "%TopicName%": "topic" } ]
“绑定”:[
{
“%topicname%”:“ Rockit-Notification-Topic”
}
]

这不起作用
Microsoft.azure.webjobs.host:错误索引方法“ myFunction”。 microsoft.azure.webjobs.host:“%topicname%”不能解析为一个值。
也是,即使确实有效,我如何将其添加到门户内部功能的设置中,因为这是数组中的项目?

您不应该在当地文件中添加“绑定”部分。 localsettings.json应该看起来像这样:

azure azure-functions servicebus
2个回答
2
投票
{ "IsEncrypted": false, "Values": { "AzureWebJobsStorage": "UseDevelopmentStorage=true", "FUNCTIONS_WORKER_RUNTIME": "dotnet", "event-bus-connection": "test", "TopicName":"topic", "SubsriptionName":"data-subscription" } }

在Azure Portal中,您可以将其直接添加到应用程序服务/功能配置,例如具有名称主题名称,subriptionName等的适当配置。

dynymancy file -dix fix服务主题和订阅名称
FunctionController.java

@@functionName(“ notificationeventtopictrigger”) 公共void ServiceBustopICEVENT( @servicebustopictrigger(name =“消息”,topicname =“%topic_name%”, subscriptionName =“%subs_name%”, 连接=“ service_conn_url”) 字符串消息,最终executionContext上下文){ loginfo(“服务总线触发器处理了一条消息...”); EventProcessor.processevent(消息); }

local.settings.json

0
投票
{ “ isencrypted”:false, “值”:{ “ functions_worker_runtime”:“ java”, “ azurewebjobsstorage”:“ undereevelvementStorage = true”, “ subs_name”:“ notification1”, “ service_conn_url”:“ endpoint = sb:// test”, “ topic_name”:“通知主题”, },, “主持人”: { “ localhtppport”:7072, “ cors”:“*”, “ Corscredentials”:false } }

application.yml

spring: 云: Azure: ServiceBus: 连接弦:$ {service_conn_url} 名称空间:POC123 主题名称:$ {topic_name} 订阅名称:$ {subs_name}

最新问题
© www.soinside.com 2019 - 2025. All rights reserved.