You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/azure-functions/durable/durable-functions-mssql-container-apps-hosting.md
+52-50Lines changed: 52 additions & 50 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,6 +10,7 @@ ms.date: 05/06/2025
10
10
This article shows how to host a Durable Functions app in Azure Container Apps. While Durable Functions supports several [storage providers](./durable-functions-storage-providers.md) or *backends*, autoscaling of the app is only available when using the Microsoft SQL (MSSQL) backend. If another backends is used, you need to [manually set up scaling](../functions-container-apps-hosting.md#event-driven-scaling) today.
11
11
12
12
## Prerequisites
13
+
13
14
+[Visual Studio Code](https://code.visualstudio.com/download) installed.
@@ -25,10 +26,12 @@ This article shows how to host a Durable Functions app in Azure Container Apps.
25
26
+ An HTTP test tool that keeps your data secure. For more information, see [HTTP test tools](../functions-develop-local.md#http-test-tools).
26
27
27
28
## Create a local Durable Functions project
29
+
28
30
In Visual Studio Code, [create a .NET isolated Durable Functions project](./quickstart-mssql.md) configured to use the MSSQL backend. Follow the article until the [Test locally](./quickstart-mssql.md#test-locally) section and make sure you can run the app locally before going to the next step.
29
31
30
32
### Add Docker related files
31
-
1. In the project root directory, add a *Dockerfile* with the following content:
33
+
34
+
1. In the project root directory, add a _Dockerfile_ with the following content:
32
35
```
33
36
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS installer-env
34
37
@@ -45,14 +48,14 @@ In Visual Studio Code, [create a .NET isolated Durable Functions project](./quic
1. Add a *.dockerignore* file with the following content:
51
+
1. Add a _.dockerignore_ file with the following content:
50
52
```
51
53
local.settings.json
52
54
```
53
55
54
56
## Build the container image
55
-
The Dockerfile in the project root describes the minimum required environment to run the function app in a container. You can find the complete list of supported base images for Azure Functions documented as Host images in the prerequisites section or can be found in the [Azure Functions Base by Microsoft | Docker Hub](https://hub.docker.com/_/microsoft-azure-functions-base)
57
+
58
+
The Dockerfile in the project root describes the minimum required environment to run the function app in a container. The complete list of supported base images for Azure Functions is documented above as Host images in the pre-requisites section or can be found in the [Azure Functions Base by Microsoft | Docker Hub](https://hub.docker.com/_/microsoft-azure-functions-base)
56
59
57
60
1. Start the Docker daemon.
58
61
@@ -74,44 +77,46 @@ The Dockerfile in the project root describes the minimum required environment to
74
77
```bash
75
78
docker push $dockerId/$imageName:$imageVersion
76
79
```
77
-
78
-
Depending on network speed, pushing the image the first time might take a few minutes (pushing subsequent changes is faster). While you're waiting, proceed to the next section to create Azure resources in another terminal.
80
+
Depending on network speed, pushing the image the first time might take a few minutes (pushing subsequent changes is much faster). While you're waiting, proceed to the next section to create Azure resources in another terminal.
79
81
80
82
## Create Azure resources
81
-
The following instructions guide you through creating these Azure resources:
83
+
84
+
The following instructions will guide you through creating these Azure resources:
82
85
- Azure resource group: For convenient cleanup later, all resources are created in this group.
83
86
- Azure Container App environment: Environment where container app is hosted.
84
87
- Azure Container App: Image containing the Durable Functions app is deployed to this app.
85
88
- Azure Storage Account: Required by the function app to store app related data such as application code.
86
-
- A virtual network: Required when running container apps.
89
+
- A virtual network: Required by the Azure Container App environment.
87
90
88
-
### Initial setup
89
-
1. Log in to your Azure subscription:
90
-
```azurecli
91
-
az login
92
-
az account set -subscription | -s <subscription_name>
93
-
```
91
+
### Initial set up
94
92
95
-
1.Run the required commands to setup the Azure Container Apps CLI extension:
96
-
```azurecli
97
-
az upgrade
93
+
1. Login to your Azure subscription:
94
+
```azurecli
95
+
az login
98
96
99
-
az extension add --name containerapp --upgrade
97
+
az account set -subscription | -s <subscription_name>
98
+
```
100
99
101
-
az provider register --namespace Microsoft.App
100
+
1. Run the required commands to set up the Azure Container Apps CLI extension:
101
+
```azurecli
102
+
az upgrade
102
103
103
-
az provider register --namespace Microsoft.OperationalInsights
104
-
```
104
+
az extension add --name containerapp --upgrade
105
+
106
+
az provider register --namespace Microsoft.App
107
+
108
+
az provider register --namespace Microsoft.OperationalInsights
109
+
```
110
+
111
+
### Create container app and related resources
105
112
106
-
### Create app related resources
107
113
A workload profile determines the amount of compute and memory resources available to the container apps deployed in an environment. Create a Consumption workload profile for scale-to-zero support and pay-per-use. Learn more about [workload profiles](../functions-container-apps-hosting.md#hosting-and-workload-profiles).
Your Durable Functions also needs an Azure SQL Database as its storage backend. This backend is where state information is persisted as your orchestrations run. In the Azure portal, you can [create an Azure SQL database](/azure/azure-sql/database/single-database-create-quickstart). During creation:
171
-
- Enable Azure services and resources to access this server (under **Networking**)
172
-
- Set the value for **Database collation** (under **Additional settings**) to `Latin1_General_100_BIN2_UTF8`.
176
+
Your Durable Functions also needs an Azure SQL Database as its storage backend. This is where state information is persisted as your orchestrations run. In the Azure portal, you can [create an Azure SQL database](/azure/azure-sql/database/single-database-create-quickstart). During creation:
177
+
- Enable Azure services and resources to access this server (under _Networking_)
178
+
- Set the value for _Database collation_ (under _Additional settings_) to `Latin1_General_100_BIN2_UTF8`.
173
179
174
180
> [!NOTE]
175
181
> Enabling the **Allow Azure services and resources to access this server** setting isn't a recommended security practice for production scenarios. Real applications should implement more secure approaches, such as stronger firewall restrictions or virtual network configurations.
176
182
183
+
177
184
### Configure identity-based authentication
178
-
Managed identities make your app more secure by eliminating secrets from your app, such as credentials in the connection strings. You can choose between [system-assigned and user-assigned managed identity](/entra/identity/managed-identities-azure-resources/overview). This article demonstrates setting up user-assigned managed identity, which is the recommended option as it isn't tied to the app lifecycle.
185
+
186
+
Managed identities make your app more secure by eliminating secrets from your app, such as credentials in the connection strings. You can choose between [system-assigned and user-assigned managed identity](/entra/identity/managed-identities-azure-resources/overview). This article demonstrates setting up user-assigned managed identity, which is the recommended option as it is not tied to the app lifecycle.
179
187
180
188
1. Create identity and assign it to the container app:
181
189
```azurecli
@@ -187,9 +195,6 @@ Managed identities make your app more secure by eliminating secrets from your ap
187
195
echo "Creating $identity"
188
196
az identity create -g $resourceGroup -n $identity --location "$location"
@@ -208,9 +213,12 @@ Managed identities make your app more secure by eliminating secrets from your ap
208
213
az role assignment create --assignee "$clientId" --role "Storage Blob Data Owner" --scope "$scope"
209
214
```
210
215
216
+
> [!NOTE]
217
+
> Authenticating to the MSSQL database using managed identity isn't supported when hosting a Durable Functions app in Azure Container Apps. Use connection string for now.
218
+
211
219
### Set up app settings
212
-
1. Start by storing the SQL database's connection string as a [secret](../../container-apps/manage-secrets.md) in the container app. Find the connection string by going to the SQL database resource on Azure portal, navigating to the **Settings** tab, then clicking on **Connection strings**:
213
220
221
+
1. Find the connection string by going to the SQL database resource on Azure portal, navigating to the **Settings** tab, then clicking on **Connection strings**:
> Authenticating to the MSSQL database using managed identity isn't yet supported when hosting a Durable Functions app in Azure Container Apps. Only connection string is supported today.
228
-
>
229
-
> If you forget the password from the previous database creation step, you can reset it on the SQL server resource:
- `AzureWebJobsStorage__accountName`: Azure Storage account name
249
+
- `AzureWebJobsStorage__clientId`: ClientId of the managed identity
250
+
- `AzureWebJobsStorage__credential`: Credential type, which is _managedidentity_
251
+
- `SQLDB_Connection`: Reference the SQL database connection string stored as a secret
252
+
- `FUNCTIONS_WORKER_RUNTIME`: Programming language of the app
249
253
250
254
```azurecli
251
255
az containerapp update \
@@ -267,8 +271,7 @@ Managed identities make your app more secure by eliminating secrets from your ap
267
271
268
272
The response is the HTTP function's initial result. It lets you know that the Durable Functions orchestration started successfully. It doesn't yet display the end result of the orchestration. The response includes a few useful URLs.
269
273
270
-
1. Copy the URL value for `statusQueryGetUri`, paste it in your browser's address bar, and execute the request. Alternatively, you can also continue to use the HTTP test tool to issue the `GET` request.
271
-
274
+
1. Copy the URL value for `statusQueryGetUri`, paste it in your browser's address bar, and execute the request. Alternatively, you can also continue to use the HTTP test tool to issue the GET request.
272
275
The request queries the orchestration instance for the status. You should see that the instance finished and that it includes the outputs or results of the Durable Functions app like in this example:
273
276
274
277
```json
@@ -284,7 +287,6 @@ Managed identities make your app more secure by eliminating secrets from your ap
0 commit comments