Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
Prepare applications for Azure deployment by generating infrastructure code, Dockerfiles, and config files.
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
references/services/durable-task-scheduler/bicep.md
1# Durable Task Scheduler — Bicep Patterns23Bicep templates for provisioning the Durable Task Scheduler, task hubs, and RBAC role assignments.45## Scheduler + Task Hub67```bicep8// Parameters — define these at file level or pass from a parent module9param schedulerName string10param location string = resourceGroup().location1112@allowed(['Consumption', 'Dedicated'])13@description('Use Consumption for quickstarts/variable workloads, Dedicated for high-demand/predictable throughput')14param skuName string = 'Consumption'1516resource scheduler 'Microsoft.DurableTask/schedulers@2025-11-01' = {17name: schedulerName18location: location19properties: {20sku: { name: skuName }21ipAllowlist: ['0.0.0.0/0'] // Required: empty list denies all traffic22}23}2425resource taskHub 'Microsoft.DurableTask/schedulers/taskHubs@2025-11-01' = {26parent: scheduler27name: 'default'28}29```3031## SKU Selection3233| SKU | Best For |34|-----|----------|35| **Consumption** | quickstarts, variable or bursty workloads, pay-per-use |36| **Dedicated** | High-demand workloads, predictable throughput requirements |3738> **💡 TIP**: Start with `Consumption` for development and variable workloads. Switch to `Dedicated` when you need consistent, high-throughput performance.3940> **⚠️ WARNING**: The scheduler's `ipAllowlist` **must** include at least one entry (e.g., `['0.0.0.0/0']` for allow-all). An empty array `[]` denies **all** traffic, causing 403 errors on gRPC calls even with correct RBAC.4142## RBAC — Durable Task Data Contributor4344The Function App's managed identity **must** have the `Durable Task Data Contributor` role on the scheduler resource. Without it, the app receives **403 PermissionDenied** on gRPC calls.4546```bicep47// Assumes the UAMI principal ID is passed from the base template's identity module48param functionAppPrincipalId string4950var durableTaskDataContributorRoleId = '0ad04412-c4d5-4796-b79c-f76d14c8d402'5152resource durableTaskRoleAssignment 'Microsoft.Authorization/roleAssignments@2022-04-01' = {53name: guid(scheduler.id, functionAppPrincipalId, durableTaskDataContributorRoleId)54scope: scheduler55properties: {56roleDefinitionId: subscriptionResourceId('Microsoft.Authorization/roleDefinitions', durableTaskDataContributorRoleId)57principalId: functionAppPrincipalId58principalType: 'ServicePrincipal'59}60}61```6263## RBAC — Dashboard Access for Developers6465To allow developers to view orchestration status and history in the [DTS dashboard](https://portal.azure.com), assign the same `Durable Task Data Contributor` role to the deploying user's identity. Without this, the dashboard returns **403 Forbidden**.6667```bicep68// Accept the deploying user's principal ID (azd auto-populates this from AZURE_PRINCIPAL_ID)69param principalId string = ''7071resource dashboardRoleAssignment 'Microsoft.Authorization/roleAssignments@2022-04-01' = if (!empty(principalId)) {72name: guid(scheduler.id, principalId, durableTaskDataContributorRoleId)73scope: scheduler74properties: {75roleDefinitionId: subscriptionResourceId('Microsoft.Authorization/roleDefinitions', durableTaskDataContributorRoleId)76principalId: principalId77principalType: 'User'78}79}80```8182> **💡 TIP**: This is the same role used for the Function App's managed identity, but assigned with `principalType: 'User'` to the developer. See the [sample repo](https://github.com/Azure-Samples/Durable-Task-Scheduler/blob/main/samples/infra/main.bicep) for a full example.8384## Connection String App Setting8586Include these entries in the Function App resource's `siteConfig.appSettings` array:8788```bicep89// UAMI client ID from base template identity module - REQUIRED for UAMI auth90param uamiClientId string9192{93name: 'DURABLE_TASK_SCHEDULER_CONNECTION_STRING'94value: 'Endpoint=${scheduler.properties.endpoint};TaskHub=${taskHub.name};Authentication=ManagedIdentity;ClientID=${uamiClientId}'95}96```9798> **⚠️ IMPORTANT**: The base templates use User Assigned Managed Identity (UAMI). You **must** include `ClientID=<uami-client-id>` in the connection string. Without it, the Durable Task SDK cannot resolve the correct identity.99100> **⚠️ WARNING**: Always use `scheduler.properties.endpoint` to get the scheduler URL. Do **not** construct it manually — the endpoint includes a hash suffix and region (e.g., `https://myscheduler-abc123.westus2.durabletask.io`).101102## Provision via CLI103104> **💡 TIP**: When hosting Durable Functions, use a **Flex Consumption** plan (`FC1` SKU) rather than the legacy Consumption plan (`Y1`). Flex Consumption supports identity-based storage connections natively and handles deployment artifacts correctly.105106```bash107# Install the durabletask CLI extension (if not already installed)108az extension add --name durabletask109110# Create scheduler (consumption SKU for getting started)111az durabletask scheduler create \112--resource-group myResourceGroup \113--name my-scheduler \114--location eastus \115--sku consumption116```117