Jump to content

Use User managed identity to replace connection string in"AzureWebJobsStorage" for function apps

Featured Replies

Posted

Managing the connectivity between the function app and the storage account is crucial as the Azure Function runtime is stored in the Azure storage account. In case of a disconnection, you might run into common errors such as "Azure Functions runtime is unreachable". Fortunately, Microsoft has a helpful guide to address this issue, which provides self-help troubleshooting steps for recovering your storage account in case of such errors. You can check it out here: Troubleshoot error: Azure Functions Runtime is unreachable.

 

 

 

Previously, the only way to grant the permission for an Azure Function to access its runtime in a storage account was via the connection string in "azurewebjobsstorage" configuration. However, a new and more secure approach exists for granting a function app access to the storage account without compromising sensitive information. This method involves leveraging a "managed identity" to replace the connection string used in "azurewebjobsstorage". By adopting this approach, you can ensure that secrets remain private while still granting necessary permissions for the function app to operate seamlessly.

 

 

 

We already have detailed instructions available for replacing the connection string in "azurewebjobsstorage" using a "system-assigned identity". The tutorial can be found here: Create a function app without default storage secrets in its definition - Azure Functions. It's worth noting that both "system-assigned" and "user-assigned" identities are supported in this scenario. For those who prefer to use a "user-assigned" identity to replace the connection string, here are the instructions:

 

 

 

Instructions:

 

a. Prepare a user-assigned identity and copy client id for later use.

 

959x240vv2.png.29e07ea628b51f65f8f43f27f1698904.png

 

b. Grant “Storage Blob Data Owner” for the identity in storage account.

 

958x279vv2.png.643a038d402ddcae4e1bb791caa0ebc3.png

 

c. Assigned user-assigned identity to the function app.

 

959x137vv2.png.5342d520054cf2ebb79a27819b072a84.png

 

d. Add 3 corresponding appSettings.

 

AzureWebJobsStorage__accountName = Storage account name (System assigned identity only need this setting.)

 

AzureWebJobsStorage__clientId = Client id of user assigned identity.

 

AzureWebJobsStorage__credential = managedidentity

 

956x280vv2.png.795f5e56c459ecae53d6b5f183ea4c8a.png

 

 

 

Then it is done. You would be able to run your function app correctly without “AzureWebJobsStorage”.

 

Continue reading...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...