|
| 1 | +--- |
| 2 | +title: "Quickstart: Durable text analysis with Azure Files OS mount" |
| 3 | +description: Learn how to deploy a Python Azure Functions app that uses Durable Functions to orchestrate parallel text file analysis by using an Azure Files OS mount on a Flex Consumption plan. |
| 4 | +ms.service: azure-functions |
| 5 | +ms.topic: quickstart |
| 6 | +ms.date: 03/11/2026 |
| 7 | +ms.custom: |
| 8 | + - devx-track-azurecli |
| 9 | + - devx-track-python |
| 10 | +#customer intent: As a developer, I want to deploy a Durable Functions app on the Flex Consumption plan with Azure Files OS mounts so I can analyze multiple text files in parallel without managing infrastructure. |
| 11 | +--- |
| 12 | + |
| 13 | +# Quickstart: Durable text analysis with Azure Files OS mount |
| 14 | + |
| 15 | +In this quickstart, you deploy a Python Azure Functions app that uses [Durable Functions](./durable/durable-functions-overview.md) to orchestrate parallel text file analysis. Your function app mounts an Azure Files share, analyzes multiple text files in parallel (fan-out), aggregates the results (fan-in), and returns them to the caller. |
| 16 | + |
| 17 | +This quickstart demonstrates a key advantage of OS mounts: shared file access across multiple function instances without per-request network overhead. |
| 18 | + |
| 19 | +[!INCLUDE [functions-azure-files-samples-note](../../includes/functions-azure-files-samples-note.md)] |
| 20 | + |
| 21 | +## Prerequisites |
| 22 | + |
| 23 | +- An Azure account with an active subscription. [Create an account for free](https://azure.microsoft.com/pricing/purchase-options/azure-account?cid=msft_learn). |
| 24 | +- [Azure CLI](/cli/azure/install-azure-cli) version 2.60.0 or later. |
| 25 | +- [Azure Functions Core Tools](./functions-run-local.md) version 4.x or later. |
| 26 | +- [Python 3.9 or later](https://www.python.org/downloads/). |
| 27 | +- [Git](https://git-scm.com/). |
| 28 | + |
| 29 | +## What you'll build |
| 30 | + |
| 31 | +You deploy an application with the following components: |
| 32 | + |
| 33 | +- **Orchestrator function**: Receives a trigger to analyze a folder of text files. Reads the mount point, discovers files, and fans out parallel analysis tasks. |
| 34 | +- **Activity functions**: Each activity analyzes one file, computing word count, character count, and mock sentiment. |
| 35 | +- **Azure Files mount**: A shared network path mounted on your function app, accessible to all instances. |
| 36 | + |
| 37 | +When you trigger the orchestration, it: |
| 38 | + |
| 39 | +1. Connects to your mounted Azure Files share. |
| 40 | +1. Lists all text files in a folder. |
| 41 | +1. Starts parallel analysis tasks (one per file). |
| 42 | +1. Waits for all tasks to complete (fan-in). |
| 43 | +1. Returns aggregated results. |
| 44 | + |
| 45 | +## Clone the repository |
| 46 | + |
| 47 | +```bash |
| 48 | +git clone https://github.com/Azure-Samples/Azure-Functions-Flex-Consumption-with-Azure-Files-OS-Mount-Samples.git |
| 49 | +cd Azure-Functions-Flex-Consumption-with-Azure-Files-OS-Mount-Samples/durable-text-analysis |
| 50 | +``` |
| 51 | + |
| 52 | +## Create Azure resources |
| 53 | + |
| 54 | +This quickstart uses Bicep to automate resource creation. Alternatively, you can create resources manually in the Azure portal. |
| 55 | + |
| 56 | +### Sign in to Azure |
| 57 | + |
| 58 | +```bash |
| 59 | +az login |
| 60 | +az account set --subscription <YOUR_SUBSCRIPTION_ID> |
| 61 | +``` |
| 62 | + |
| 63 | +### Create a resource group |
| 64 | + |
| 65 | +```bash |
| 66 | +RESOURCE_GROUP="rg-durable-text" |
| 67 | +LOCATION="eastus" |
| 68 | + |
| 69 | +az group create --name $RESOURCE_GROUP --location $LOCATION |
| 70 | +``` |
| 71 | + |
| 72 | +### Deploy infrastructure with Bicep |
| 73 | + |
| 74 | +```bash |
| 75 | +az deployment group create \ |
| 76 | + --resource-group $RESOURCE_GROUP \ |
| 77 | + --template-file infra/main.bicep \ |
| 78 | + --parameters infra/main.bicepparam |
| 79 | +``` |
| 80 | + |
| 81 | +This deployment creates the following resources: |
| 82 | + |
| 83 | +- Storage account with an Azure Files share |
| 84 | +- Flex Consumption function app plan |
| 85 | +- Azure Functions app |
| 86 | +- Application Insights for monitoring |
| 87 | +- Managed identity with permissions to the storage account |
| 88 | + |
| 89 | +After the deployment succeeds, save the resource names for later steps: |
| 90 | + |
| 91 | +```bash |
| 92 | +STORAGE_ACCOUNT=$(az deployment group show --resource-group $RESOURCE_GROUP --name main --query properties.outputs.storageAccountName.value -o tsv) |
| 93 | +FUNCTION_APP_NAME=$(az deployment group show --resource-group $RESOURCE_GROUP --name main --query properties.outputs.functionAppName.value -o tsv) |
| 94 | +SHARE_NAME="text-data" |
| 95 | + |
| 96 | +echo "Storage Account: $STORAGE_ACCOUNT" |
| 97 | +echo "Function App: $FUNCTION_APP_NAME" |
| 98 | +echo "Share Name: $SHARE_NAME" |
| 99 | +``` |
| 100 | + |
| 101 | +## Verify the Azure Files mount |
| 102 | + |
| 103 | +The Bicep deployment creates the Azure Files share and configures the mount on your function app. |
| 104 | + |
| 105 | +### Verify the storage share exists |
| 106 | + |
| 107 | +```bash |
| 108 | +az storage share list --account-name $STORAGE_ACCOUNT --query "[].name" -o table |
| 109 | +``` |
| 110 | + |
| 111 | +Expected output: |
| 112 | + |
| 113 | +``` |
| 114 | +Name |
| 115 | +------ |
| 116 | +text-data |
| 117 | +``` |
| 118 | + |
| 119 | +### Verify mount configuration on the function app |
| 120 | + |
| 121 | +```bash |
| 122 | +az functionapp config appsettings list --resource-group $RESOURCE_GROUP --name $FUNCTION_APP_NAME | grep -i mount |
| 123 | +``` |
| 124 | + |
| 125 | +> [!TIP] |
| 126 | +> The OS mount typically appears at `/mnt/filedata` inside the function container. Your app settings map this local path to the Azure Files share. |
| 127 | +
|
| 128 | +## Upload sample text files |
| 129 | + |
| 130 | +### Create local sample files |
| 131 | + |
| 132 | +```bash |
| 133 | +mkdir -p sample_texts |
| 134 | +cat > sample_texts/file1.txt << 'EOF' |
| 135 | +Azure Functions is a serverless compute service that lets you run code on-demand without managing infrastructure. |
| 136 | +EOF |
| 137 | + |
| 138 | +cat > sample_texts/file2.txt << 'EOF' |
| 139 | +Durable Functions extends Azure Functions with workflow capabilities like orchestration and state management. |
| 140 | +EOF |
| 141 | + |
| 142 | +cat > sample_texts/file3.txt << 'EOF' |
| 143 | +Azure Files provides managed file shares in the cloud accessible via the SMB protocol. |
| 144 | +EOF |
| 145 | +``` |
| 146 | + |
| 147 | +### Upload files to the Azure Files share |
| 148 | + |
| 149 | +```bash |
| 150 | +STORAGE_KEY=$(az storage account keys list --resource-group $RESOURCE_GROUP --account-name $STORAGE_ACCOUNT --query "[0].value" -o tsv) |
| 151 | + |
| 152 | +az storage file upload-batch \ |
| 153 | + --destination $SHARE_NAME \ |
| 154 | + --source sample_texts \ |
| 155 | + --account-name $STORAGE_ACCOUNT \ |
| 156 | + --account-key $STORAGE_KEY |
| 157 | +``` |
| 158 | + |
| 159 | +Verify the upload: |
| 160 | + |
| 161 | +```bash |
| 162 | +az storage file list --share-name $SHARE_NAME --account-name $STORAGE_ACCOUNT --account-key $STORAGE_KEY -o table |
| 163 | +``` |
| 164 | + |
| 165 | +Expected output: |
| 166 | + |
| 167 | +``` |
| 168 | +Name |
| 169 | +------ |
| 170 | +file1.txt |
| 171 | +file2.txt |
| 172 | +file3.txt |
| 173 | +``` |
| 174 | + |
| 175 | +## Deploy the function app |
| 176 | + |
| 177 | +### Install dependencies |
| 178 | + |
| 179 | +```bash |
| 180 | +pip install -r requirements.txt |
| 181 | +``` |
| 182 | + |
| 183 | +### Configure local settings |
| 184 | + |
| 185 | +```bash |
| 186 | +cp local.settings.json.example local.settings.json |
| 187 | +``` |
| 188 | + |
| 189 | +Edit `local.settings.json` to include your mount path: |
| 190 | + |
| 191 | +```json |
| 192 | +{ |
| 193 | + "IsEncrypted": false, |
| 194 | + "Values": { |
| 195 | + "FUNCTIONS_WORKER_RUNTIME": "python", |
| 196 | + "AzureWebJobsStorage": "DefaultEndpointsProtocol=https;AccountName=<your-account>;...", |
| 197 | + "MOUNT_PATH": "/mnt/filedata" |
| 198 | + } |
| 199 | +} |
| 200 | +``` |
| 201 | + |
| 202 | +### Publish to Azure |
| 203 | + |
| 204 | +```bash |
| 205 | +func azure functionapp publish $FUNCTION_APP_NAME --build remote |
| 206 | +``` |
| 207 | + |
| 208 | +## Trigger the orchestration |
| 209 | + |
| 210 | +### Get the function URL |
| 211 | + |
| 212 | +```bash |
| 213 | +HOST_KEY=$(az functionapp keys list --resource-group $RESOURCE_GROUP --name $FUNCTION_APP_NAME --query "functionKeys.default" -o tsv) |
| 214 | + |
| 215 | +FUNCTION_URL="https://${FUNCTION_APP_NAME}.azurewebsites.net/api/orchestrators/TextAnalysisOrchestrator" |
| 216 | +``` |
| 217 | + |
| 218 | +### Start the orchestration |
| 219 | + |
| 220 | +```bash |
| 221 | +curl -X POST "$FUNCTION_URL" \ |
| 222 | + -H "x-functions-key: $HOST_KEY" \ |
| 223 | + -H "Content-Type: application/json" \ |
| 224 | + -d '{}' |
| 225 | +``` |
| 226 | + |
| 227 | +The response includes an instance ID and status query URIs: |
| 228 | + |
| 229 | +```json |
| 230 | +{ |
| 231 | + "id": "abc123def456", |
| 232 | + "statusQueryGetUri": "https://...", |
| 233 | + "sendEventPostUri": "https://...", |
| 234 | + "terminatePostUri": "https://..." |
| 235 | +} |
| 236 | +``` |
| 237 | + |
| 238 | +## Verify results |
| 239 | + |
| 240 | +### Check orchestration status |
| 241 | + |
| 242 | +Use the `statusQueryGetUri` from the previous response, or construct the URL manually: |
| 243 | + |
| 244 | +```bash |
| 245 | +INSTANCE_ID="<instance-id-from-trigger-response>" |
| 246 | + |
| 247 | +curl "https://${FUNCTION_APP_NAME}.azurewebsites.net/api/orchestrators/TextAnalysisOrchestrator/${INSTANCE_ID}" \ |
| 248 | + -H "x-functions-key: $HOST_KEY" |
| 249 | +``` |
| 250 | + |
| 251 | +While the orchestration is running, the `runtimeStatus` is `Running`. When complete, the response looks like: |
| 252 | + |
| 253 | +```json |
| 254 | +{ |
| 255 | + "name": "TextAnalysisOrchestrator", |
| 256 | + "instanceId": "abc123def456", |
| 257 | + "runtimeStatus": "Completed", |
| 258 | + "output": { |
| 259 | + "results": [ |
| 260 | + { |
| 261 | + "file": "file1.txt", |
| 262 | + "word_count": 15, |
| 263 | + "char_count": 98, |
| 264 | + "sentiment": "positive" |
| 265 | + }, |
| 266 | + { |
| 267 | + "file": "file2.txt", |
| 268 | + "word_count": 18, |
| 269 | + "char_count": 120, |
| 270 | + "sentiment": "positive" |
| 271 | + }, |
| 272 | + { |
| 273 | + "file": "file3.txt", |
| 274 | + "word_count": 12, |
| 275 | + "char_count": 85, |
| 276 | + "sentiment": "neutral" |
| 277 | + } |
| 278 | + ], |
| 279 | + "total_words": 45, |
| 280 | + "total_chars": 303, |
| 281 | + "analysis_duration_seconds": 2.34 |
| 282 | + } |
| 283 | +} |
| 284 | +``` |
| 285 | + |
| 286 | +> [!TIP] |
| 287 | +> Your function app accessed all three files in parallel through the OS mount. No per-request network calls were needed. The function read them directly from the mounted share by using standard file I/O. This approach demonstrates the power of OS mounts combined with Durable Functions. |
| 288 | +
|
| 289 | +## Clean up resources |
| 290 | + |
| 291 | +To avoid ongoing charges, delete the resource group when you no longer need the resources: |
| 292 | + |
| 293 | +```bash |
| 294 | +az group delete --name $RESOURCE_GROUP --yes |
| 295 | +``` |
| 296 | + |
| 297 | +> [!WARNING] |
| 298 | +> This command deletes the resource group and all resources in it, including the function app, storage account, and Application Insights instance. |
| 299 | +
|
| 300 | +## Troubleshooting |
| 301 | + |
| 302 | +| Issue | Resolution | |
| 303 | +| --- | --- | |
| 304 | +| **Mount path not found** | Verify the mount is configured in the Azure portal under **Settings** > **Configuration** > **Path Mappings**. | |
| 305 | +| **Permission denied when reading files** | Verify the storage account access key in the mount configuration is correct and hasn't been rotated. OS mounts use storage account keys, not managed identity RBAC. | |
| 306 | +| **Deployment failed** | Check the Bicep parameters file (`infra/main.bicepparam`). Ensure all required values are set and the storage account name is globally unique. | |
| 307 | +| **Orchestration timed out** | Increase `maxRetryInterval` in `function_app.py` if your files are large or your analysis is slow. | |
| 308 | + |
| 309 | +## Related content |
| 310 | + |
| 311 | +- [Durable Functions overview](./durable/durable-functions-overview.md) |
| 312 | +- [Tutorial: Shared file access patterns with Azure Files OS mounts](./tutorial-shared-file-access-azure-files.md) |
| 313 | +- [Quickstart: FFmpeg image processing with Azure Files OS mount](./quickstart-ffmpeg-processing-azure-files.md) |
| 314 | +- [Flex Consumption plan](./flex-consumption-plan.md) |
| 315 | +- [Storage considerations for Azure Functions](./storage-considerations.md) |
0 commit comments