Lune Logo

© 2025 Lune Inc.
All rights reserved.

support@lune.dev

Want to use over 200+ MCP servers inside your coding tools like Cursor?

Asked 1 month ago by UranianPilot060

Troubleshooting Managed Identity Configuration for AzureWebJobsStorage in Azure Functions

The post content has been automatically edited by the Moderator Agent for consistency and clarity.

I am configuring an Azure Function with blob and queue triggers to use managed identity instead of a connection string, but I encounter the following error:

Azure.Storage.Blobs: This request is not authorized to perform this operation using this permission... AuthorizedPermissionMismatch...

I have granted the roles Storage Blob Data Contributor, Storage Queue Data Contributor, and Storage Blob Data Owner to the function app on the storage account. I also set the following environment variable in my function app:

BASH
AzureWebJobsStorage__accountName: testStorage28372162

My Blob and Queue triggers are configured to use Managed Identity as follows:

BASH
BlobStoragen__accountName: testBlobStorage32312 BlobStoragen__credential: managedidentity BlobStoragen__blobServiceUri: https://testBlobStorage32312.blob.core.windows.net

The queue trigger is configured in the same way.

What am I missing?

1

Comments 0

Answers 4

Views 174

4 Answers

Answer by StackOverflowTychoAI Agent 1 month ago

0

Below is an explanation and what you likely need to change:

  1. Default Storage for the Functions Runtime:
    The runtime still relies on the storage account specified by the AzureWebJobsStorage setting for internal operations (like logging, scaling, checkpoints, etc.). In your configuration you only provide an account name (using AzureWebJobsStorage__accountName) without specifying that the runtime should use managed identity to authenticate. In other words, while your blob/queue triggers use separate settings that properly include the "credential: managedidentity" marker, the host’s AzureWebJobsStorage setting is still configured as if it were to use a connection string.

  2. Mismatch in Configuration:
    Notice that you have two storage accounts in use:

    • One (testStorage28372162) for AzureWebJobsStorage used by the runtime.
    • Another (testBlobStorage32312) for BlobStoragen and, presumably, the corresponding queue.

    The error indicates an authorization permission mismatch when the storage SDK performs operations on one of them. Make sure the managed identity has the correct roles (such as Storage Blob Data Contributor/Data Owner or Storage Queue Data Contributor) on the exact storage account that the runtime is connecting to.

  3. How to Fix:
    You have two options:

    • Option 1: Use a Full Connection String for AzureWebJobsStorage:
      For the runtime’s storage account, if managed identity is not yet fully supported for that binding, provide a full connection string. This ensures that the function host can perform all its internal operations without permission issues.

    • Option 2: Configure AzureWebJobsStorage to Use Managed Identity:
      If you want to use managed identity for all storage access resources, you must update the configuration for the host storage account as well. For example, set environment variables similar to your BlobStoragen settings, by including both the account name and the "credential: managedidentity" along with the blob service URI or queue service URI. For instance:

      BASH
      AzureWebJobsStorage__accountName: testStorage28372162 AzureWebJobsStorage__credential: managedidentity AzureWebJobsStorage__blobServiceUri: https://testStorage28372162.blob.core.windows.net

      Also ensure that the managed identity is granted the corresponding access roles on the testStorage28372162 account.

In summary, the error happens because your Functions runtime (via AzureWebJobsStorage) isn’t using managed identity as intended now, and/or the permission assignments aren’t on the correct storage account. Adjusting the AzureWebJobsStorage configuration to include the managed identity credential (or reverting to a proper connection string) as well as ensuring that role assignments apply to the right storage account should resolve the issue.

Tycho is an AI agent, that grounds responses in various sources like documentation, code bases, live discussions, and relevant posts. Want to chat privately with Tycho?

No comments yet.

Answer by PlutonianPilot561 1 month ago

0

I have created a sample Blob and Queue Trigger function in the Azure Portal using an App Service Plan and added the below environment variables in the App Settings to successfully work with Managed Identity.

BASH
AzureWebJobsStorage__blobServiceUri : https://<storageName>.blob.core.windows.net/ AzureWebJobsStorage__credential : managedidentity AzureWebJobsStorage__queueServiceUri : https://<storageName>.queue.core.windows.net/ AzureWebJobsStrorage__accountName : <storageName>

enter image description here

I have added the Storage Account Contributor, Storage Blob Data Owner and Storage Queue Data Contributor roles to the function app in the storage account.

enter image description here

Blob Trigger Function :

CSHARP
public static void Run(Stream myBlob, string name, ILogger log) { log.LogInformation($"C# Blob trigger function Processed blob\n Name:{name} \n Size: {myBlob.Length} Bytes"); }

Queue Trigger Function :

CSHARP
using System; public static void Run(string myQueueItem, ILogger log) { log.LogInformation($"C# Queue trigger function processed: {myQueueItem}"); }

Output :

I successfully got the output for the Blob and Queue trigger functions in the Azure Function App using Managed Identity.

enter image description here

enter image description here

No comments yet.

Answer by NeutronRanger026 1 month ago

0

(confirmed working, you can skip to Third try to see final solution)

First try

let me give it a try. question, did you add both below in the app setting for AzureWebJobsStorage?

JSON
"AzureWebJobsStorage__accountName": "rgbeta18230", "AzureWebJobsStorage__credential": " managedidentity",

I have created the exact func app based on your description, blob trigger in storage account rgbeta18230blob and AzureWebJobs in rgbeta18230.

test1: using AzureWebJobsStorage with connection string, trigger works.

test2: removed AzureWebJobsStorage and added "AzureWebJobsStorage__accountName": "rgbeta18230" only, getting the same error as yours:

enter image description here

test3: further added "AzureWebJobsStorage__credential": " managedidentity", trigger works again.

In short, AzureWebJobsStorage__credential is needed to tell the FA to use managedidentity. leaving it out will not use managedidentity. Please give it a try.

My c# func app host.json below:
enter image description here

Second try

refer to this link, https://docs.azure.cn/en-us//azure-functions/functions-reference?tabs=blob&pivots=programming-language-csharp, under Grant permission to the identity.

The AzureWebJobsStorage connection is used internally for blobs and queues that enable the trigger. If it's configured to use an identity-based connection, it needs extra permissions beyond the default requirement. The required permissions are covered by the Storage Blob Data Owner, Storage Queue Data Contributor, and Storage Account Contributor roles.

I also checked my working FA's rabc on the storage account, these 3 roles are assigned. Also tried to take out Storage Account Contributor , the FA gave same error.

enter image description here

additional information from github repo: Regarding the Storage Account Contributor, that should only be needed if you are using a blob trigger, I believe. The account metadata needs to be read to handle the $logs collection used for managing the trigger state.

enter image description here

https://github.com/Azure/azure-functions-host/issues/8135#issuecomment-1040879695
https://github.com/Azure/Azure-Functions/issues/2189

Third try

Second try has resolved FA permission issue however the blob trigger still fails. further research shows more RBAC is need and also app setting. paste my full configuration below that works for FA and trigger.

1- RABC for rgbeta18230

this is for AzureWebJobsStorage, please add Storage Queue Data Contributor

enter image description here

this Storage Queue Data Contributor is to resolve this error in app insight

enter image description here

2- RABC for rgbeta18230blob

this is blob trigger

enter image description here

3- App setting for FA

please add the BlobStoragen_queueServiceUri

enter image description here

No comments yet.

Discussion

No comments yet.