azure-functions-dotnet-worker: Azure Functions: Exception with Managed Identity and EventGrid source for Blob Trigger

Hello everyone. I am having a problem with Azure Function with a Blob Trigger: Environment:

.NET: 7
Function SDK: 4
Blob Extension Version: 6.1.0
Process Mode: Isolated

After following this tutorial https://learn.microsoft.com/en-us/azure/azure-functions/functions-event-grid-blob-trigger to change the transport from BlobTriggerSource.LogsAndContainerScan to BlobTriggerSource.EventGrid everything was working fine. I was able to enter (and debug) the function when I uploaded a new file to the storage account.

When I tried to use Managed Identity, instead of a connection string, I got the following error:

Exception: Microsoft.Azure.Functions.Worker.FunctionInputConverterException: Error converting 1 input parameters for Function '<FUNCTION_NAME>': Cannot convert input parameter 'stream' to type 'System.IO.Stream' from type 'Microsoft.Azure.Functions.Worker.Grpc.Messages.GrpcModelBindingData'. Error:System.ArgumentNullException: Value cannot be null. (Parameter 'connectionString')

with the following call stack:

- at Microsoft.Azure.Functions.Worker.BlobStorageConverter.CreateBlobContainerClient(String connectionName, String containerName) in D:\a\_work\1\s\extensions\Worker.Extensions.Storage.Blobs\src\BlobStorageConverter.cs:line 253
- at Azure.Storage.StorageConnectionString.Parse(String connectionString)
- at Azure.Storage.Blobs.BlobServiceClient..ctor(String connectionString, BlobClientOptions options)
- at Microsoft.Azure.Functions.Worker.BlobStorageConverter.ConvertModelBindingDataAsync(Type targetType, BlobBindingData blobData) in D:\a\_work\1\s\extensions\Worker.Extensions.Storage.Blobs\src\BlobStorageConverter.cs:line 118
- at Microsoft.Azure.Functions.Worker.BlobStorageConverter.ConvertFromBindingDataAsync(ConverterContext context, ModelBindingData modelBindingData) in D:\a\_work\1\s\extensions\Worker.Extensions.Storage.Blobs\src\BlobStorageConverter.cs:line 63
- at Microsoft.Azure.Functions.Worker.BlobStorageBindingOptions.CreateClient() in D:\a\_work\1\s\extensions\Worker.Extensions.Storage.Blobs\src\Config\BlobStorageBindingOptions.cs:line 35
- at Microsoft.Azure.Functions.Worker.Context.Features.DefaultFunctionInputBindingFeature.BindFunctionInputAsync(FunctionContext context) in D:\a\_work\1\s\src\DotNetWorker.Core\Context\Features\DefaultFunctionInputBindingFeature.cs:line 105

In my local.settings.json I have added the settings as per described here: https://learn.microsoft.com/en-us/azure/azure-functions/functions-bindings-storage-blob-trigger (section “Identity-based connections”).

Is Managed Identity with EventGrid source for Blob Trigger Azure Function supported ?

About this issue

  • Original URL
  • State: open
  • Created 3 years ago
  • Reactions: 1
  • Comments: 19 (2 by maintainers)

Most upvoted comments

We also ran into this issue while using the serviceUri form and the Queue access seems to have been the problem.

The blob trigger handles failure across multiple retries by writing poison blobs to a queue. In the serviceUri form, the AzureWebJobsStorage connection is used.

https://learn.microsoft.com/en-us/azure/azure-functions/functions-bindings-storage-blob-trigger#identity-based-connections

We were using Azurite for AzureWebJobsStorage when testing this, which doesn’t appear to work with this setup.

Passing blobServiceUri and queueServiceUri separately (both pointing to a storage account) and assigning Storage Queue Data Contributor on the account got it working.

Note, I was able to get the blob trigger and Stream parameter working with just the MyAccount__blobServiceUri and MyAccount__queueServiceUri configuration set. (Set to the triggering blob account). I did not need the __accountname. I also have not attempted to use Managed Identity for the actual AzureWebJobs storage account yet.

I’m also very interested in this issue, connection string works perfectly. Using “blobservice__serviceUri”: “https://<mystorageaccount>.blob.core.windows.net/”, it fires when it detects a file, but doesn’t even get to the method’s { before failing. Also running .NET 8 isolated

This is an issue for us as well.

.NET: 7
Function SDK: 4
Blob Extension Version: 6.2.0
Process Mode: Isolated

If I use a managed identity connection and BlobTrigger I get the same error:

Exception: Microsoft.Azure.Functions.Worker.FunctionInputConverterException: Error converting 1 input parameters for 
Function 'IngestFunction': Cannot convert input parameter 'stream' to type 'System.IO.Stream' from type 
'Microsoft.Azure.Functions.Worker.Grpc.Messages.GrpcModelBindingData'. Error:System.ArgumentNullException: Value cannot 
be null. (Parameter 'connectionString')

The connectionstring parameter is stored with the __serviceUri suffix.

Attribute binding:

public async Task UploadFile([BlobTrigger("archive-json/{name}", 
Connection = "StorageAccountConnectionString")] Stream stream, string name)

We will move away from manged identity and back to using a storage key for the time being.