|
2 | 2 |
|
3 | 3 | This document explains how local development authentication works for this Azure Functions project. |
4 | 4 |
|
| 5 | +## Quick Start |
| 6 | + |
| 7 | +### Option A: With Docker (Recommended) |
| 8 | + |
| 9 | +The fastest way to get started is using Docker Compose: |
| 10 | + |
| 11 | +```bash |
| 12 | +# Start both Azurite and DTS emulator |
| 13 | +docker compose up -d |
| 14 | + |
| 15 | +# Generate local settings from your Azure environment |
| 16 | +./scripts/generate-settings.sh |
| 17 | + |
| 18 | +# Run the Functions app |
| 19 | +cd src |
| 20 | +func start |
| 21 | +``` |
| 22 | + |
| 23 | +**Dashboard URLs:** |
| 24 | + |
| 25 | +- DTS Dashboard: <http://localhost:8082/> |
| 26 | +- Azurite Blob: <http://localhost:10000/> |
| 27 | + |
| 28 | +To stop the emulators: |
| 29 | + |
| 30 | +```bash |
| 31 | +docker compose down |
| 32 | +``` |
| 33 | + |
| 34 | +### Option B: Without Docker - Native Azurite + Azure Storage Backend |
| 35 | + |
| 36 | +If Docker is not available, you can use native Azurite and Azure Storage for Durable Functions: |
| 37 | + |
| 38 | +```bash |
| 39 | +# 1. Install Azurite globally via npm |
| 40 | +npm install -g azurite |
| 41 | + |
| 42 | +# 2. Start Azurite in a separate terminal |
| 43 | +azurite |
| 44 | + |
| 45 | +# 3. Temporarily switch to Azure Storage backend (see configuration below) |
| 46 | + |
| 47 | +# 4. Generate local settings |
| 48 | +./scripts/generate-settings.sh |
| 49 | + |
| 50 | +# 5. Run the Functions app |
| 51 | +cd src |
| 52 | +func start |
| 53 | +``` |
| 54 | + |
| 55 | +**Configuration changes for Azure Storage backend:** |
| 56 | + |
| 57 | +Temporarily update `src/host.json` durableTask section: |
| 58 | + |
| 59 | +```json |
| 60 | +"durableTask": { |
| 61 | + "hubName": "%TASKHUB_NAME%", |
| 62 | + "storageProvider": { |
| 63 | + "type": "azureStorage", |
| 64 | + "connectionStringName": "AzureWebJobsStorage" |
| 65 | + }, |
| 66 | + "tracing": { |
| 67 | + "traceInputsAndOutputs": true |
| 68 | + } |
| 69 | +} |
| 70 | +``` |
| 71 | + |
| 72 | +Your `local.settings.json` should have: |
| 73 | + |
| 74 | +```json |
| 75 | +{ |
| 76 | + "Values": { |
| 77 | + "AzureWebJobsStorage": "UseDevelopmentStorage=true", |
| 78 | + "TASKHUB_NAME": "default" |
| 79 | + } |
| 80 | +} |
| 81 | +``` |
| 82 | + |
| 83 | +**Note:** This approach uses Azure Storage (via Azurite) instead of DTS for orchestration state. You won't have the DTS dashboard, but all Durable Functions features will work. |
| 84 | + |
| 85 | +### Switching Between Backends |
| 86 | + |
| 87 | +Use the provided helper script to easily switch between DTS and Azure Storage: |
| 88 | + |
| 89 | +```bash |
| 90 | +# Switch to Azure Storage (for environments without Docker) |
| 91 | +./scripts/switch-storage-backend.sh azureStorage |
| 92 | + |
| 93 | +# Switch back to DTS (when Docker is available) |
| 94 | +./scripts/switch-storage-backend.sh dts |
| 95 | +``` |
| 96 | + |
| 97 | +PowerShell: |
| 98 | + |
| 99 | +```powershell |
| 100 | +# Switch to Azure Storage |
| 101 | +.\scripts\switch-storage-backend.ps1 azureStorage |
| 102 | +
|
| 103 | +# Switch to DTS |
| 104 | +.\scripts\switch-storage-backend.ps1 dts |
| 105 | +``` |
| 106 | + |
| 107 | +The script automatically updates your `host.json` configuration and provides instructions for the required environment setup. |
| 108 | + |
| 109 | +## Prerequisites |
| 110 | + |
| 111 | +Before you begin, ensure you have: |
| 112 | + |
| 113 | +1. **Docker** installed for running the Durable Task Scheduler emulator |
| 114 | +2. **Azurite** installed for local Azure Storage emulation |
| 115 | +3. **Azure CLI** installed and configured |
| 116 | + |
| 117 | +## Durable Task Scheduler Setup |
| 118 | + |
| 119 | +This project uses the **Durable Task Scheduler** (DTS) for orchestration instead of Azure Storage. For local development, you need to run the DTS emulator. |
| 120 | + |
| 121 | +### 1. Start the DTS Emulator |
| 122 | + |
| 123 | +Pull and run the DTS emulator Docker container: |
| 124 | + |
| 125 | +```bash |
| 126 | +# Pull the emulator image |
| 127 | +docker pull mcr.microsoft.com/dts/dts-emulator:latest |
| 128 | + |
| 129 | +# Run the emulator (exposes ports 8080 for gRPC and 8082 for dashboard) |
| 130 | +docker run -d -p 8080:8080 -p 8082:8082 mcr.microsoft.com/dts/dts-emulator:latest |
| 131 | +``` |
| 132 | + |
| 133 | +The emulator exposes two ports: |
| 134 | +- **8080**: gRPC endpoint for the Functions app to connect |
| 135 | +- **8082**: Dashboard UI at http://localhost:8082/ |
| 136 | + |
| 137 | +### 2. Start Azurite |
| 138 | + |
| 139 | +The Azure Functions runtime still requires Azurite for some components: |
| 140 | + |
| 141 | +```bash |
| 142 | +azurite start |
| 143 | +``` |
| 144 | + |
| 145 | +### 3. Verify Configuration |
| 146 | + |
| 147 | +Check that your `local.settings.json` includes these DTS-specific settings: |
| 148 | + |
| 149 | +```json |
| 150 | +{ |
| 151 | + "Values": { |
| 152 | + "DTS_CONNECTION_STRING": "Endpoint=http://localhost:8080;Authentication=None", |
| 153 | + "TASKHUB_NAME": "default" |
| 154 | + } |
| 155 | +} |
| 156 | +``` |
| 157 | + |
5 | 158 | ## Authentication Approach |
6 | 159 |
|
7 | 160 | This project uses **Azure Managed Identity** for authentication - both in production AND for local development. **No API keys are required!** |
@@ -64,6 +217,16 @@ func start |
64 | 217 |
|
65 | 218 | The Azure Functions runtime will automatically use your Azure credentials via `DefaultAzureCredential`. |
66 | 219 |
|
| 220 | +### 5. Monitor Orchestrations |
| 221 | + |
| 222 | +You can monitor orchestration instances in real-time using the DTS dashboard: |
| 223 | + |
| 224 | +1. Open <http://localhost:8082/> in your browser |
| 225 | +2. Click on your task hub (default: **default**) |
| 226 | +3. View orchestration status, history, and execution details |
| 227 | + |
| 228 | +**Note**: The DTS emulator stores data in memory, so all orchestration data is lost when the container stops. |
| 229 | + |
67 | 230 | ## Benefits of This Approach |
68 | 231 |
|
69 | 232 | ✅ **No secrets to manage** - No API keys in config files or environment variables |
|
0 commit comments