Azure Functions基于身份的Blob触发器本地运行失败
背景信息
使用Java编写的Blob触发函数:
@FunctionName("blob") public String execute( @BlobTrigger(name = "test", path = "testcontainer/{name}", connection = "BlobTriggerConnection") String content, ExecutionContext context) { // function's code }
根据官方文档,要使用基于身份的触发器,必须创建以下应用设置项:
BlobTriggerConnection__blobServiceUriBlobTriggerConnection__queueServiceUriBlobTriggerConnection__credential
此外,函数的身份必须在Blob存储上拥有正确的权限。我在Azure环境中完成了上述配置,运行正常。
问题描述
但在本地结合Azurite运行该函数时失败,报错如下:
Microsoft.Azure.WebJobs.Host: Error indexing method 'Functions.blob'. Microsoft.Extensions.Azure: Unable to find matching constructor while trying to create an instance of BlobServiceClient. Expected one of the follow sets of configuration parameters: 1. connectionString 2. serviceUri 3. serviceUri, credential:accountName, credential:accountKey 4. serviceUri, credential:signature 5. serviceUri Found the following configuration keys: queueServiceUri, credential, blobServiceUri.
看起来本地似乎不支持基于身份的触发器。
local.settings.json文件内容:
{ "IsEncrypted": false, "Values": { "AzureWebJobsStorage": "UseDevelopmentStorage=true", "FUNCTIONS_WORKER_RUNTIME": "java", "BlobTriggerConnection__blobServiceUri": "UseDevelopmentStorage=true;DevelopmentStorageProxyUri=http://127.0.0.1:10000", "BlobTriggerConnection__credential": "managedidentity", "BlobTriggerConnection__queueServiceUri": "UseDevelopmentStorage=true;DevelopmentStorageProxyUri=http://127.0.0.1:10001" } }
我本地使用的是最新版本的工具:
> brew search azure-functions-core-tools azure/functions/azure-functions-core-tools@4
补充说明:我使用的是搭载Intel芯片的MacBook。
内容的提问来源于stack exchange,提问作者Amir Keibi
相关产品推荐
相关产品推荐

