我为队列触发器创建了一个隔离的进程Azure Functions。基于link我使用
var configuration = new ConfigurationBuilder().AddEnvironmentVariables()
.AddCommandLine(args)
.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
.Build();
var host = new HostBuilder().ConfigureHostConfiguration(config => {
config.AddConfiguration(configuration);
}).ConfigureFunctionsWorkerDefaults().Build();
函数代码:
[Function("BlobQueueTrigger")]
public async Task RunAsync([QueueTrigger("datablobqueue", Connection = "blobQueue")] string blobQueueItem)
{}
应用程序设置中的属性:
"blobQueue__queueServiceUri": "https://mydatastorage.queue.core.windows.net"
最佳答案
根据documentation您在上面引用的,blobQueue__queueServiceUri
必须定义为环境变量,而不是在 appsettings.json
中。这意味着您需要将其设置为应用程序设置 in the portal 。在本地工作时,local.settings.json
中设置的值确实会加载为 Environment Variables
自从我深入研究这个问题以来已经有一段时间了,但我认为它需要在实际启动您的流程之前访问该值。因此,您在 Program.cs
中定义的自定义配置提供程序尚未加载。
关于.net - 具有托管标识的 Azure 函数队列触发器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/74130843/