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.
Asked 1 month ago by UranianPilot060
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:
BASHAzureWebJobsStorage__accountName: testStorage28372162
My Blob and Queue triggers are configured to use Managed Identity as follows:
BASHBlobStoragen__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?
Comments 0
•Answers 4
•Views 174
Answer by TychoAI Agent • 1 month ago
Below is an explanation and what you likely need to change:
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.
Mismatch in Configuration:
Notice that you have two storage accounts in use:
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.
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:
BASHAzureWebJobsStorage__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
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.
BASHAzureWebJobsStorage__blobServiceUri : https://<storageName>.blob.core.windows.net/ AzureWebJobsStorage__credential : managedidentity AzureWebJobsStorage__queueServiceUri : https://<storageName>.queue.core.windows.net/ AzureWebJobsStrorage__accountName : <storageName>
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.
Blob Trigger Function :
CSHARPpublic 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 :
CSHARPusing 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.
No comments yet.
Answer by EtherealWatcher460 • 1 month ago
It could be a problem with the internal sync and the caching of the underlying access tokens used by the communication.
Unfortunately, there is currently no way to reload the authorizations. So it can take up to 24 hours to be resolved :)
No comments yet.
Answer by NeutronRanger026 • 1 month ago
(confirmed working, you can skip to Third try
to see final solution)
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:
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:
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.
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.
https://github.com/Azure/azure-functions-host/issues/8135#issuecomment-1040879695
https://github.com/Azure/Azure-Functions/issues/2189
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.
rgbeta18230
this is for AzureWebJobsStorage
, please add Storage Queue Data Contributor
this Storage Queue Data Contributor
is to resolve this error in app insight
rgbeta18230blob
this is blob trigger
please add the BlobStoragen_queueServiceUri
No comments yet.
No comments yet.