【发布时间】:2020-06-11 09:54:19
【问题描述】:
我正在使用 .Net core 3.1 编写一个 azure webjob,并从 eventthub 读取事件。我已经能够在本地工作,我从本地 appsettings.json 和 appsettings.dev.json 读取所有设置。
public async Task ProcessEvent([EventHubTrigger("%EventHubName%", Connection = "EventHubConfigConnectionString", ConsumerGroup = "%ConsumerGroupName%")] EventData eventData)
但是,我现在尝试使用 azure appservice appsettings 来存储连接字符串,其中应用设置作为环境变量公开,我将其添加到配置中:
Configuration = new ConfigurationBuilder()
.AddEnvironmentVariables().Build();
但我仍然收到错误:
System.ArgumentNullException: Value cannot be null. (Parameter 'connectionString')
at Microsoft.Azure.EventHubs.Primitives.Guard.ArgumentNotNullOrWhiteSpace(String argumentName, String value)
我验证变量名称是相同的。 我在线阅读,看起来 EventHubTrigger 的连接字符串必须存在于 appsettings 文件中而不是环境变量中?
我错过了什么吗?
【问题讨论】:
标签: c# azure asp.net-core azure-webjobs azure-eventhub