Use managed identity instead of AzureWebJobsStorage to connect a function app to a storage account

This post has been republished via RSS; it originally appeared at: New blog articles in Microsoft Community Hub.

In a function app, usually we use appsetting AzureWebJobsStorage to connect to storage. This blog shows you how to configure a function app using Azure Active Directory identities instead of secrets or connection strings, where possible. Using identities helps you avoid accidentally leaking sensitive secrets and can provide better visibility into how data is accessed.

 

This will not work if the storage account is in a sovereign cloud or has a custom DNS.

 

Below are the steps to do configuration.

 

1. Enable system assigned identity in your function app and save it.

Bobi_Bao_12-1666252447891.png

 

2. Give storage access to your function app. Search for Storage Blob Data Owner, select it.

Bobi_Bao_13-1666252447894.png

 

 

Bobi_Bao_14-1666252447896.png

 

Bobi_Bao_15-1666252447901.png

 

 

 

3. If you configure a blob-triggered function app, repeat the step 2 to add Storage Account Contributor and Storage Queue Data Contributor roles which will be used for blob trigger.

Bobi_Bao_16-1666252447903.png

 

Bobi_Bao_17-1666252447905.png

 

 

4. Return to Access Control (IAM), click Role assignments, search for your function app name to confirm the roles are added successfully.

Bobi_Bao_18-1666252447910.png

 

 

5. Navigate to your function app. Select Configuration and edit AzureWebJobsStorage. Change the name to AzureWebJobsStorage__accountname.  Change the value to your storage account name. (The new setting uses a double underscore (__), which is a special character in application settings.) 

Bobi_Bao_0-1666332053179.png

 

 

6. Delete the previous AzureWebJobsStorage. Then you will find your function app still works fine.

 

 

 

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *

*

This site uses Akismet to reduce spam. Learn how your comment data is processed.