Skip to content

Commit ad9233b

Browse files
committed
Update Azure Functions tutorials to use Azure Developer CLI for deployment and resource management
1 parent e93d0ec commit ad9233b

2 files changed

Lines changed: 84 additions & 349 deletions

File tree

articles/azure-functions/durable/tutorial-durable-text-analysis-azure-files.md

Lines changed: 38 additions & 174 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ ms.topic: tutorial
66
ms.date: 03/11/2026
77
ms.custom:
88
- devx-track-azurecli
9+
- devx-track-azdevcli
910
- devx-track-python
1011
#customer intent: As a developer, I want to deploy a Durable Functions app on the Flex Consumption plan with Azure Files storage mounts so I can analyze multiple text files in parallel without managing infrastructure.
1112
---
@@ -17,24 +18,23 @@ In this tutorial, you deploy a Python Azure Functions app that uses [Durable Fun
1718
In this tutorial, you:
1819

1920
> [!div class="checklist"]
20-
> * Deploy a Durable Functions app in a Flex Consumption plan with a mounted Azure Files share using Bicep
21-
> * Upload sample text files to the mounted Azure Files share
22-
> * Deploy a Python function app that uses a [fan-out/fan-in pattern](./durable-functions-fan-in-fan-out.md?pivots=durable-functions) to analyze text files in parallel
23-
> * Trigger an orchestration to process the files and verify results
21+
> * Deploy a Durable Functions app in a Flex Consumption plan with a mounted Azure Files share by using Azure Developer CLI
22+
> * Trigger an orchestration to process sample text files in parallel
23+
> * Verify the aggregated analysis results
2424
2525
[!INCLUDE [functions-azure-files-samples-note](../../../includes/functions-azure-files-samples-note.md)]
2626

2727
## Prerequisites
2828

2929
- An Azure account with an active subscription. [Create an account for free](https://azure.microsoft.com/pricing/purchase-options/azure-account?cid=msft_learn).
30-
- [Azure CLI](/cli/azure/install-azure-cli) version 2.60.0 or later
31-
- [Azure Functions Core Tools](../functions-run-local.md) version 4.x or later
32-
- [Python 3.9 or later](https://www.python.org/downloads/)
30+
- [Azure Developer CLI (azd)](/azure/developer/azure-developer-cli/install-azd) version 1.9.0 or later
3331
- [Git](https://git-scm.com/)
3432

35-
## Clone the repository
33+
The CLI examples in this tutorial use Bash syntax and have been tested in [Azure Cloud Shell](/azure/cloud-shell/overview) (Bash) and Linux/macOS terminals.
3634

37-
The sample code for this tutorial is in the [Azure Functions Flex Consumption with Azure Files OS Mount Samples](https://github.com/Azure-Samples/Azure-Functions-Flex-Consumption-with-Azure-Files-OS-Mount-Samples) GitHub repository. The `durable-text-analysis` folder contains the function app code and a Bicep template that provisions the required Azure resources.
35+
## Initialize the sample project
36+
37+
The sample code for this tutorial is in the [Azure Functions Flex Consumption with Azure Files OS Mount Samples](https://github.com/Azure-Samples/Azure-Functions-Flex-Consumption-with-Azure-Files-OS-Mount-Samples) GitHub repository. The `durable-text-analysis` folder contains the function app code, a Bicep template that provisions the required Azure resources, and a post-deployment script that uploads sample text files.
3838

3939
1. Open a terminal and navigate to the directory where you want to clone the repository.
4040

@@ -50,196 +50,61 @@ The sample code for this tutorial is in the [Azure Functions Flex Consumption wi
5050
cd Azure-Functions-Flex-Consumption-with-Azure-Files-OS-Mount-Samples/durable-text-analysis
5151
```
5252

53-
## Create Azure resources
54-
55-
This tutorial uses Bicep to automate resource creation.
56-
57-
1. Sign in to Azure:
58-
59-
```azurecli
60-
az login
61-
```
62-
63-
1. If you have multiple subscriptions, set the one you want to use:
64-
65-
```azurecli
66-
az account set --subscription <YOUR_SUBSCRIPTION_ID>
67-
```
68-
69-
1. Create a resource group:
70-
71-
```azurecli
72-
RESOURCE_GROUP="rg-durable-text"
73-
LOCATION="eastus"
74-
75-
az group create --name $RESOURCE_GROUP --location $LOCATION
76-
```
77-
78-
1. Deploy infrastructure by using Bicep:
79-
80-
```azurecli
81-
az deployment group create \
82-
--resource-group $RESOURCE_GROUP \
83-
--template-file infra/main.bicep \
84-
--parameters infra/main.bicepparam
85-
```
86-
87-
This deployment creates the following resources:
88-
89-
- Storage account with an Azure Files share
90-
- Durable Functions app in a Flex Consumption plan
91-
- Application Insights for monitoring
92-
- Managed identity with permissions to the storage account
93-
94-
1. After the deployment succeeds, save the resource names for later steps:
95-
96-
```azurecli
97-
STORAGE_ACCOUNT=$(az deployment group show \
98-
--resource-group $RESOURCE_GROUP \
99-
--name main \
100-
--query properties.outputs.storageAccountName.value \
101-
-o tsv)
102-
FUNCTION_APP_NAME=$(az deployment group show \
103-
--resource-group $RESOURCE_GROUP \
104-
--name main \
105-
--query properties.outputs.functionAppName.value \
106-
-o tsv)
107-
SHARE_NAME="text-data"
108-
109-
echo "Storage Account: $STORAGE_ACCOUNT"
110-
echo "Function App: $FUNCTION_APP_NAME"
111-
echo "Share Name: $SHARE_NAME"
112-
```
113-
114-
> [!NOTE]
115-
> If you're using Azure Cloud Shell, shell variables don't persist between sessions. If your session times out, rerun the variable assignments in this section before continuing.
116-
117-
## Verify the storage mount configuration
118-
119-
1. The Bicep deployment creates the Azure Files share and configures the mount on your function app. Verify that it's set up correctly:
120-
121-
```azurecli
122-
az storage share list \
123-
--account-name $STORAGE_ACCOUNT \
124-
--query "[].name" \
125-
-o table
126-
```
127-
128-
Expected output:
129-
130-
```
131-
Name
132-
------
133-
text-data
134-
```
135-
136-
1. Verify the mount configuration on the function app:
137-
138-
```azurecli
139-
az functionapp config appsettings list \
140-
--resource-group $RESOURCE_GROUP \
141-
--name $FUNCTION_APP_NAME \
142-
| grep -i mount
143-
```
144-
145-
> [!TIP]
146-
> The storage mount typically appears at `/mnt/filedata` inside the function container. Your app settings map this local path to the Azure Files share.
147-
148-
If you don't see mount configuration settings, manually configure the mount in the Azure portal under **Settings** > **Configuration** > **Path Mappings**.
149-
150-
## Upload sample text files
151-
152-
1. Create local sample files:
53+
1. Initialize the `azd` environment. When prompted, enter an environment name such as `durable-text`:
15354

15455
```bash
155-
mkdir -p sample_texts
156-
cat > sample_texts/file1.txt << 'EOF'
157-
Azure Functions is a serverless compute service that lets you run code on-demand without managing infrastructure.
158-
EOF
159-
160-
cat > sample_texts/file2.txt << 'EOF'
161-
Durable Functions extends Azure Functions with workflow capabilities like orchestration and state management.
162-
EOF
163-
164-
cat > sample_texts/file3.txt << 'EOF'
165-
Azure Files provides managed file shares in the cloud accessible via the SMB protocol.
166-
EOF
56+
azd init
16757
```
16858

169-
1. Upload files to the Azure Files share:
170-
171-
```azurecli
172-
STORAGE_KEY=$(az storage account keys list \
173-
--resource-group $RESOURCE_GROUP \
174-
--account-name $STORAGE_ACCOUNT \
175-
--query "[0].value" \
176-
-o tsv)
59+
## Deploy with Azure Developer CLI
17760

178-
az storage file upload-batch \
179-
--destination $SHARE_NAME \
180-
--source sample_texts \
181-
--account-name $STORAGE_ACCOUNT \
182-
--account-key $STORAGE_KEY
183-
```
61+
This sample is an [Azure Developer CLI (azd)](/azure/developer/azure-developer-cli/overview) template. A single `azd up` command provisions infrastructure, deploys the function code, and uploads sample text files to the Azure Files share.
18462

185-
1. Verify the upload:
63+
1. Sign in to Azure:
18664

187-
```azurecli
188-
az storage file list \
189-
--share-name $SHARE_NAME \
190-
--account-name $STORAGE_ACCOUNT \
191-
--account-key $STORAGE_KEY \
192-
-o table
65+
```bash
66+
azd auth login
19367
```
19468

195-
Expected output:
69+
1. Provision and deploy everything:
19670

197-
```
198-
Name
199-
------
200-
file1.txt
201-
file2.txt
202-
file3.txt
71+
```bash
72+
azd up
20373
```
20474

205-
## Prepare and deploy the function app
75+
When prompted, select the Azure subscription and location to use. The command then:
20676

207-
1. Make sure the remote function app has the required app settings. Run this command even if these settings already exist:
77+
- Creates a resource group, storage account, Flex Consumption function app with a Durable Functions configuration, Application Insights instance, and managed identity
78+
- Deploys the Python function code
79+
- Uploads sample text files to the Azure Files share
80+
- Runs a health check
20881

209-
```azurecli
210-
az functionapp config appsettings set \
211-
--resource-group $RESOURCE_GROUP \
212-
--name $FUNCTION_APP_NAME \
213-
--settings MOUNT_PATH=/mnt/filedata
214-
```
82+
The deployment takes a few minutes. When it completes, you see a summary of the created resources.
21583

216-
1. Publish the function app to Azure. The `--build remote` flag installs Python dependencies on the server, so you don't need to install them locally:
84+
1. Save resource names as shell variables for the remaining steps:
21785

21886
```bash
219-
func azure functionapp publish $FUNCTION_APP_NAME --build remote
87+
RESOURCE_GROUP=$(azd env get-value AZURE_RESOURCE_GROUP)
88+
FUNCTION_APP_NAME=$(azd env get-value AZURE_FUNCTION_APP_NAME)
89+
FUNCTION_APP_URL=$(azd env get-value AZURE_FUNCTION_APP_URL)
22090
```
22191

22292
## Trigger the orchestration
22393

224-
1. Get the function URL and host key:
94+
1. Get the function host key:
22595

22696
```azurecli
22797
HOST_KEY=$(az functionapp keys list \
22898
--resource-group $RESOURCE_GROUP \
22999
--name $FUNCTION_APP_NAME \
230100
--query "functionKeys.default" \
231101
-o tsv)
232-
233-
FUNCTION_URL="https://${FUNCTION_APP_NAME}.azurewebsites.net/api/orchestrators/TextAnalysisOrchestrator"
234102
```
235103

236104
1. Start the orchestration:
237105

238106
```bash
239-
curl -X POST "$FUNCTION_URL" \
240-
-H "x-functions-key: $HOST_KEY" \
241-
-H "Content-Type: application/json" \
242-
-d '{}'
107+
curl -s -X POST "${FUNCTION_APP_URL}/api/start-analysis?code=${HOST_KEY}" | jq .
243108
```
244109

245110
The response includes an instance ID and status query URIs:
@@ -260,8 +125,7 @@ This tutorial uses Bicep to automate resource creation.
260125
```bash
261126
INSTANCE_ID="<instance-id-from-trigger-response>"
262127
263-
curl "https://${FUNCTION_APP_NAME}.azurewebsites.net/api/orchestrators/TextAnalysisOrchestrator/${INSTANCE_ID}" \
264-
-H "x-functions-key: $HOST_KEY"
128+
curl -s "${FUNCTION_APP_URL}/api/orchestrators/TextAnalysisOrchestrator/${INSTANCE_ID}?code=${HOST_KEY}" | jq .
265129
```
266130

267131
While the orchestration is running, the `runtimeStatus` is `Running`. When complete, the response looks like:
@@ -274,19 +138,19 @@ This tutorial uses Bicep to automate resource creation.
274138
"output": {
275139
"results": [
276140
{
277-
"file": "file1.txt",
141+
"file": "sample1.txt",
278142
"word_count": 15,
279143
"char_count": 98,
280144
"sentiment": "positive"
281145
},
282146
{
283-
"file": "file2.txt",
147+
"file": "sample2.txt",
284148
"word_count": 18,
285149
"char_count": 120,
286150
"sentiment": "positive"
287151
},
288152
{
289-
"file": "file3.txt",
153+
"file": "sample3.txt",
290154
"word_count": 12,
291155
"char_count": 85,
292156
"sentiment": "neutral"
@@ -304,10 +168,10 @@ This tutorial uses Bicep to automate resource creation.
304168
305169
## Clean up resources
306170
307-
To avoid ongoing charges, delete the resource group when you no longer need the resources:
171+
To avoid ongoing charges, delete all the resources created by this tutorial:
308172
309-
```azurecli
310-
az group delete --name $RESOURCE_GROUP --yes
173+
```bash
174+
azd down --purge
311175
```
312176
313177
> [!WARNING]

0 commit comments

Comments
 (0)