Identity-based blob triggers for Azure functions fail locally

413 Views Asked by At

Context

A blob triggered function written in Java:

@FunctionName("blob")
public String execute(
    @BlobTrigger(name = "test", path = "testcontainer/{name}", connection = "BlobTriggerConnection")
    String content, ExecutionContext context) {
    // function's code
}

Based on the documentation, to use identity based triggers, following App Settings entries must be created:

  • BlobTriggerConnection__blobServiceUri
  • BlobTriggerConnection__queueServiceUri
  • BlobTriggerConnection__credential

Moreover, function's identity must have correct permissions on the blob storage.

I've done that in Azure and it works well.

Problem

However, running the function locally along with Azurite fails with the following error:

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.

It is as if identity based triggers aren't supported.

local.settings.json file's content:

{
  "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"
  }
}

I'm using the latest version of tools locally:

> brew search azure-functions-core-tools

azure/functions/azure-functions-core-tools@4

I should point out that this is a MacBook with intel's chipset.

1

There are 1 best solutions below

2
Faraz Ahmad On

Add this in your local.settings.json to resolve your issue:

"AzureWebJobsblobConnection__serviceUri":"https://xxxxx.blob.core.windows.net"

Make sure you add this too

"blobConnection__serviceUri ":"https://xxxxxx.blob.core.windows.net"

and this is how the .cs file will look:

public void Run([BlobTrigger("%blobName%", Connection = "blobConnection")]Stream myBlob, string name, ILogger log)