Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
This quickstart shows how to configure a Durable Functions app using the default Azure Storage provider to use identity-based connections, so your app can access its storage account without managing secrets. A managed identity from Microsoft Entra ID is managed by the Azure platform — you don't need to provision or rotate any secrets.
In this article:
- Local development setup — Use Azurite or your developer credentials for local testing
- Identity-based connections for app deployed to Azure — Enable a managed identity and configure your function app
Note
Managed identity is supported in Durable Functions extension versions 2.7.0 and greater.
If you don't have an Azure account, create a free account before you begin.
Prerequisites
To complete this quickstart, you need:
- An existing Durable Functions project created in the Azure portal or a local Durable Functions project deployed to Azure.
- Familiarity running a Durable Functions app in Azure.
If you don't have an existing Durable Functions project deployed in Azure, we recommend that you start with one of the following quickstarts:
- Create your first durable function - C#
- Create your first durable function - JavaScript
- Create your first durable function - Python
- Create your first durable function - PowerShell
- Create your first durable function - Java
Local development setup
You have two options for local development. Use Azurite for quick local testing without Azure credentials. If you need to test identity-based connections against a real Azure Storage account, use your developer credentials instead.
Option 1: Use the Azure Storage emulator
When developing locally, it's recommended that you use Azurite, which is Azure Storage's local emulator. Configure your app to the emulator by specifying "AzureWebJobsStorage": "UseDevelopmentStorage=true" in the local.settings.json.
Option 2: Identity-based connections for local development
Strictly speaking, a managed identity is only available to apps when executing on Azure. However, you can still configure a locally running app to use identity-based connection by using your developer credentials to authenticate against Azure resources. Then, when deployed on Azure, the app will utilize your managed identity configuration instead.
When using developer credentials, the connection attempts to get a token from the following locations, in this order:
- A local cache shared between Microsoft applications
- The current user context in Visual Studio
- The current user context in Visual Studio Code
- The current user context in the Azure CLI
If none of these options are successful, you get an error indicating the app can't retrieve an authentication token. Verify you're signed into one of the listed tools with an account that has access to your Azure Storage account.
Configure runtime to use local developer identity
Specify the name of your Azure Storage account in local.settings.json, for example:
{ "IsEncrypted": false, "Values": { "AzureWebJobsStorage__accountName": "<<your Azure Storage account name>>", "FUNCTIONS_WORKER_RUNTIME": "dotnet-isolated" } }Navigate to your Azure Storage account resource in the Azure portal.
Select the Access Control (IAM) tab, and then select Add role assignment.
Assign each of the following roles to yourself. For each role, select "+ Select members" and search for the email you use to sign into Visual Studio, Visual Studio Code, or the Azure CLI.
- Storage Queue Data Contributor
- Storage Blob Data Contributor
- Storage Table Data Contributor
Note
These are the same three roles required for your managed identity when deploying to Azure. See Assign access roles to the managed identity.
Identity-based connections for app deployed to Azure
Enable a managed identity resource
To begin, enable a managed identity for your application. Your function app must have either a system-assigned managed identity or a user-assigned managed identity. To enable a managed identity for your function app, and to learn more about the differences between the two types of identities, see the managed identity overview.
Assign access roles to the managed identity
Navigate to your app's Azure Storage resource on the Azure portal and assign three role-based access control (RBAC) roles to your managed identity resource:
- Storage Queue Data Contributor
- Storage Blob Data Contributor
- Storage Table Data Contributor
To find your identity resource, select assign access to Managed identity and then + Select members
Add the managed identity configuration to your app
Before you can use your app's managed identity, make some changes to the app settings:
In the Azure portal, on your function app resource menu under Settings, select Environment variables.
In the list of settings, find AzureWebJobsStorage and select the Delete icon.
Add a setting to link your Azure storage account to the application.
Use one of the following methods depending on the cloud that your app runs in:
Azure cloud: If your app runs in global Azure, add the setting
AzureWebJobsStorage__accountNamethat identifies an Azure storage account name. Example value:mystorageaccount123Non-Azure cloud: If your application runs in a cloud outside of Azure, you must add the following three settings to provide specific service URIs (or endpoints) of the storage account instead of an account name.
Setting name:
AzureWebJobsStorage__blobServiceUriExample value:
https://mystorageaccount123.blob.core.windows.net/Setting name:
AzureWebJobsStorage__queueServiceUriExample value:
https://mystorageaccount123.queue.core.windows.net/Setting name:
AzureWebJobsStorage__tableServiceUriExample value:
https://mystorageaccount123.table.core.windows.net/
You can get the values for these URI variables in the storage account information from the Endpoints tab.
Note
If you are using Azure Government or any other cloud that's separate from global Azure, you must use the option that provides specific service URIs instead of just the storage account name. For more information on using Azure Storage with Azure Government, see the Develop by using the Storage API in Azure Government.
Finish your managed identity configuration (remember to click "Apply" after making the setting changes):
If you use a system-assigned identity, make no other changes.
If you use a user-assigned identity, add the following settings in your app configuration:
AzureWebJobsStorage__credential, enter managedidentity
AzureWebJobsStorage__clientId, get this GUID value from your managed identity resource
Note
Durable Functions does not support
managedIdentityResourceIdwhen using user-assigned identity. UseclientIdinstead.
Verify your configuration
To confirm your managed identity configuration works:
- In the Azure portal, navigate to your function app and trigger your Durable Functions orchestration (for example, by using an HTTP-trigger function).
- Check that the orchestration completes successfully by querying the status endpoint or checking the Monitor tab.
- If you see authentication errors, verify that:
- All three Storage Data Contributor roles are assigned to the correct identity.
- The
AzureWebJobsStorageconnection string setting is removed. - The
AzureWebJobsStorage__accountName(or service URI) settings are correct.