我正在尝试将托管标识与 Azure Functions V3 和 QueueTrigger 结合使用。
函数代码定义如下:
[Function("ProcessUserData")]
public async Task ProcessUserData([QueueTrigger("%QueueSettings:UserDataQueue%", Connection = "QueueSettings:StorageAccount")] string queueItem, FunctionContext context)
{
var logger = context.GetLogger<QueueListener>();
...
}
根据微软文档,这应该可以通过定义一些额外的配置属性来实现
https://learn.microsoft.com/en-us/azure/azure-functions/functions-reference?tabs=blob#local-development-with-identity-based-connections https://learn.microsoft.com/en-us/azure/azure-functions/functions-reference?tabs=blob#local-development-with-identity-based-connections
我的 local.settings.json 看起来像这样:
// "QueueSettings:StorageAccount": "",
"QueueSettings:StorageAccount__queueServiceUri": "https://mytestfa.queue.core.windows.net/",
"QueueSettings:StorageAccount__credential": "managedidentity",
当尝试在本地运行项目时,出现以下错误:
[2021-12-06T18:07:53.181Z]“ProcessUserData”函数出现错误:Microsoft.Azure.WebJobs.Host:索引方法“Functions.ProcessUserData”出错。 Microsoft.Azure.WebJobs.Extensions.Storage:存储帐户连接字符串“AzureWebJobsQueueSettings:StorageAccount”不存在。确保它是已定义的应用程序设置。
当我使用和空连接字符串时,我收到另一个错误:
"QueueSettings:StorageAccount": "",
"QueueSettings:StorageAccount__queueServiceUri": "https://mytestfa.queue.core.windows.net/",
"QueueSettings:StorageAccount__credential": "managedidentity",
Error:
[2021-12-06T18:25:20.262Z]“ProcessUserData”函数出现错误:Microsoft.Azure.WebJobs.Host:索引方法“Functions.ProcessUserData”出错。 Microsoft.Azure.WebJobs.Extensions.Storage:“AzureWebJobsQueueSettings:StorageAccount”的存储帐户连接字符串无效。
当使用带有帐户密钥的完整连接字符串时,这可以正常工作,但我们必须使用托管身份。
我已升级到最新版本的 Azure Functions Core Tole (3.0.3904),并使用 Visual Studio 2022。
附加文档表明这should work:
https://devblogs.microsoft.com/azure-sdk/introducing-the-new-azure-function-extension-libraries-beta/ https://devblogs.microsoft.com/azure-sdk/introducing-the-new-azure-function-extension-libraries-beta/
感谢您的任何见解。