|
Add this skill
npx mdskills install sickn33/azure-resource-manager-durabletask-dotnetComprehensive Azure ARM SDK documentation with clear hierarchy, authentication, and complete CRUD workflows
1---2name: azure-resource-manager-durabletask-dotnet3description: |4 Azure Resource Manager SDK for Durable Task Scheduler in .NET. Use for MANAGEMENT PLANE operations: creating/managing Durable Task Schedulers, Task Hubs, and retention policies via Azure Resource Manager. Triggers: "Durable Task Scheduler", "create scheduler", "task hub", "DurableTaskSchedulerResource", "provision Durable Task", "orchestration scheduler".5package: Azure.ResourceManager.DurableTask6---78# Azure.ResourceManager.DurableTask (.NET)910Management plane SDK for provisioning and managing Azure Durable Task Scheduler resources via Azure Resource Manager.1112> **⚠️ Management vs Data Plane**13> - **This SDK (Azure.ResourceManager.DurableTask)**: Create schedulers, task hubs, configure retention policies14> - **Data Plane SDK (Microsoft.DurableTask.Client.AzureManaged)**: Start orchestrations, query instances, send events1516## Installation1718```bash19dotnet add package Azure.ResourceManager.DurableTask20dotnet add package Azure.Identity21```2223**Current Versions**: Stable v1.0.0 (2025-11-03), Preview v1.0.0-beta.1 (2025-04-24)24**API Version**: 2025-11-012526## Environment Variables2728```bash29AZURE_SUBSCRIPTION_ID=<your-subscription-id>30AZURE_RESOURCE_GROUP=<your-resource-group>31# For service principal auth (optional)32AZURE_TENANT_ID=<tenant-id>33AZURE_CLIENT_ID=<client-id>34AZURE_CLIENT_SECRET=<client-secret>35```3637## Authentication3839```csharp40using Azure.Identity;41using Azure.ResourceManager;42using Azure.ResourceManager.DurableTask;4344// Always use DefaultAzureCredential45var credential = new DefaultAzureCredential();46var armClient = new ArmClient(credential);4748// Get subscription49var subscriptionId = Environment.GetEnvironmentVariable("AZURE_SUBSCRIPTION_ID");50var subscription = armClient.GetSubscriptionResource(51 new ResourceIdentifier($"/subscriptions/{subscriptionId}"));52```5354## Resource Hierarchy5556```57ArmClient58└── SubscriptionResource59 └── ResourceGroupResource60 └── DurableTaskSchedulerResource61 ├── DurableTaskHubResource62 └── DurableTaskRetentionPolicyResource63```6465## Core Workflow6667### 1. Create Durable Task Scheduler6869```csharp70using Azure.ResourceManager.DurableTask;71using Azure.ResourceManager.DurableTask.Models;7273// Get resource group74var resourceGroup = await subscription75 .GetResourceGroupAsync("my-resource-group");7677// Define scheduler with Dedicated SKU78var schedulerData = new DurableTaskSchedulerData(AzureLocation.EastUS)79{80 Properties = new DurableTaskSchedulerProperties81 {82 Sku = new DurableTaskSchedulerSku(DurableTaskSchedulerSkuName.Dedicated)83 {84 Capacity = 1 // Number of instances85 },86 // Optional: IP allowlist for network security87 IPAllowlist = { "10.0.0.0/24", "192.168.1.0/24" }88 }89};9091// Create scheduler (long-running operation)92var schedulerCollection = resourceGroup.Value.GetDurableTaskSchedulers();93var operation = await schedulerCollection.CreateOrUpdateAsync(94 WaitUntil.Completed,95 "my-scheduler",96 schedulerData);9798DurableTaskSchedulerResource scheduler = operation.Value;99Console.WriteLine($"Scheduler created: {scheduler.Data.Name}");100Console.WriteLine($"Endpoint: {scheduler.Data.Properties.Endpoint}");101```102103### 2. Create Scheduler with Consumption SKU104105```csharp106// Consumption SKU (serverless)107var consumptionSchedulerData = new DurableTaskSchedulerData(AzureLocation.EastUS)108{109 Properties = new DurableTaskSchedulerProperties110 {111 Sku = new DurableTaskSchedulerSku(DurableTaskSchedulerSkuName.Consumption)112 // No capacity needed for consumption113 }114};115116var operation = await schedulerCollection.CreateOrUpdateAsync(117 WaitUntil.Completed,118 "my-serverless-scheduler",119 consumptionSchedulerData);120```121122### 3. Create Task Hub123124```csharp125// Task hubs are created under a scheduler126var taskHubData = new DurableTaskHubData127{128 // Properties are optional for basic task hub129};130131var taskHubCollection = scheduler.GetDurableTaskHubs();132var hubOperation = await taskHubCollection.CreateOrUpdateAsync(133 WaitUntil.Completed,134 "my-taskhub",135 taskHubData);136137DurableTaskHubResource taskHub = hubOperation.Value;138Console.WriteLine($"Task Hub created: {taskHub.Data.Name}");139```140141### 4. List Schedulers142143```csharp144// List all schedulers in subscription145await foreach (var sched in subscription.GetDurableTaskSchedulersAsync())146{147 Console.WriteLine($"Scheduler: {sched.Data.Name}");148 Console.WriteLine($" Location: {sched.Data.Location}");149 Console.WriteLine($" SKU: {sched.Data.Properties.Sku?.Name}");150 Console.WriteLine($" Endpoint: {sched.Data.Properties.Endpoint}");151}152153// List schedulers in resource group154var schedulers = resourceGroup.Value.GetDurableTaskSchedulers();155await foreach (var sched in schedulers.GetAllAsync())156{157 Console.WriteLine($"Scheduler: {sched.Data.Name}");158}159```160161### 5. Get Scheduler by Name162163```csharp164// Get existing scheduler165var existingScheduler = await schedulerCollection.GetAsync("my-scheduler");166Console.WriteLine($"Found: {existingScheduler.Value.Data.Name}");167168// Or use extension method169var schedulerResource = armClient.GetDurableTaskSchedulerResource(170 DurableTaskSchedulerResource.CreateResourceIdentifier(171 subscriptionId,172 "my-resource-group",173 "my-scheduler"));174var scheduler = await schedulerResource.GetAsync();175```176177### 6. Update Scheduler178179```csharp180// Get current scheduler181var scheduler = await schedulerCollection.GetAsync("my-scheduler");182183// Update with new configuration184var updateData = new DurableTaskSchedulerData(scheduler.Value.Data.Location)185{186 Properties = new DurableTaskSchedulerProperties187 {188 Sku = new DurableTaskSchedulerSku(DurableTaskSchedulerSkuName.Dedicated)189 {190 Capacity = 2 // Scale up191 },192 IPAllowlist = { "10.0.0.0/16" } // Update IP allowlist193 }194};195196var updateOperation = await schedulerCollection.CreateOrUpdateAsync(197 WaitUntil.Completed,198 "my-scheduler",199 updateData);200```201202### 7. Delete Resources203204```csharp205// Delete task hub first206var taskHub = await scheduler.GetDurableTaskHubs().GetAsync("my-taskhub");207await taskHub.Value.DeleteAsync(WaitUntil.Completed);208209// Then delete scheduler210await scheduler.DeleteAsync(WaitUntil.Completed);211```212213### 8. Manage Retention Policies214215```csharp216// Get retention policy collection217var retentionPolicies = scheduler.GetDurableTaskRetentionPolicies();218219// Create or update retention policy220var retentionData = new DurableTaskRetentionPolicyData221{222 Properties = new DurableTaskRetentionPolicyProperties223 {224 // Configure retention settings225 }226};227228var retentionOperation = await retentionPolicies.CreateOrUpdateAsync(229 WaitUntil.Completed,230 "default", // Policy name231 retentionData);232```233234## Key Types Reference235236| Type | Purpose |237|------|---------|238| `ArmClient` | Entry point for all ARM operations |239| `DurableTaskSchedulerResource` | Represents a Durable Task Scheduler |240| `DurableTaskSchedulerCollection` | Collection for scheduler CRUD |241| `DurableTaskSchedulerData` | Scheduler creation/update payload |242| `DurableTaskSchedulerProperties` | Scheduler configuration (SKU, IPAllowlist) |243| `DurableTaskSchedulerSku` | SKU configuration (Name, Capacity, RedundancyState) |244| `DurableTaskSchedulerSkuName` | SKU options: `Dedicated`, `Consumption` |245| `DurableTaskHubResource` | Represents a Task Hub |246| `DurableTaskHubCollection` | Collection for task hub CRUD |247| `DurableTaskHubData` | Task hub creation payload |248| `DurableTaskRetentionPolicyResource` | Retention policy management |249| `DurableTaskRetentionPolicyData` | Retention policy configuration |250| `DurableTaskExtensions` | Extension methods for ARM client |251252## SKU Options253254| SKU | Description | Use Case |255|-----|-------------|----------|256| `Dedicated` | Fixed capacity with configurable instances | Production workloads, predictable performance |257| `Consumption` | Serverless, auto-scaling | Development, variable workloads |258259## Extension Methods260261The SDK provides extension methods on `SubscriptionResource` and `ResourceGroupResource`:262263```csharp264// On SubscriptionResource265subscription.GetDurableTaskSchedulers(); // List all in subscription266subscription.GetDurableTaskSchedulersAsync(); // Async enumerable267268// On ResourceGroupResource269resourceGroup.GetDurableTaskSchedulers(); // Get collection270resourceGroup.GetDurableTaskSchedulerAsync(name); // Get by name271272// On ArmClient273armClient.GetDurableTaskSchedulerResource(id); // Get by resource ID274armClient.GetDurableTaskHubResource(id); // Get task hub by ID275```276277## Best Practices2782791. **Use `WaitUntil.Completed`** for operations that must finish before proceeding2802. **Use `WaitUntil.Started`** when you want to poll manually or run operations in parallel2813. **Always use `DefaultAzureCredential`** — never hardcode keys2824. **Handle `RequestFailedException`** for ARM API errors2835. **Use `CreateOrUpdateAsync`** for idempotent operations2846. **Delete task hubs before schedulers** — schedulers with task hubs cannot be deleted2857. **Use IP allowlists** for network security in production286287## Error Handling288289```csharp290using Azure;291292try293{294 var operation = await schedulerCollection.CreateOrUpdateAsync(295 WaitUntil.Completed, schedulerName, schedulerData);296}297catch (RequestFailedException ex) when (ex.Status == 409)298{299 Console.WriteLine("Scheduler already exists");300}301catch (RequestFailedException ex) when (ex.Status == 404)302{303 Console.WriteLine("Resource group not found");304}305catch (RequestFailedException ex)306{307 Console.WriteLine($"ARM Error: {ex.Status} - {ex.ErrorCode}: {ex.Message}");308}309```310311## Complete Example312313```csharp314using Azure;315using Azure.Identity;316using Azure.ResourceManager;317using Azure.ResourceManager.DurableTask;318using Azure.ResourceManager.DurableTask.Models;319using Azure.ResourceManager.Resources;320321// Setup322var credential = new DefaultAzureCredential();323var armClient = new ArmClient(credential);324325var subscriptionId = Environment.GetEnvironmentVariable("AZURE_SUBSCRIPTION_ID")!;326var resourceGroupName = Environment.GetEnvironmentVariable("AZURE_RESOURCE_GROUP")!;327328var subscription = armClient.GetSubscriptionResource(329 new ResourceIdentifier($"/subscriptions/{subscriptionId}"));330var resourceGroup = await subscription.GetResourceGroupAsync(resourceGroupName);331332// Create scheduler333var schedulerData = new DurableTaskSchedulerData(AzureLocation.EastUS)334{335 Properties = new DurableTaskSchedulerProperties336 {337 Sku = new DurableTaskSchedulerSku(DurableTaskSchedulerSkuName.Dedicated)338 {339 Capacity = 1340 }341 }342};343344var schedulerCollection = resourceGroup.Value.GetDurableTaskSchedulers();345var schedulerOp = await schedulerCollection.CreateOrUpdateAsync(346 WaitUntil.Completed, "my-scheduler", schedulerData);347var scheduler = schedulerOp.Value;348349Console.WriteLine($"Scheduler endpoint: {scheduler.Data.Properties.Endpoint}");350351// Create task hub352var taskHubData = new DurableTaskHubData();353var taskHubOp = await scheduler.GetDurableTaskHubs().CreateOrUpdateAsync(354 WaitUntil.Completed, "my-taskhub", taskHubData);355var taskHub = taskHubOp.Value;356357Console.WriteLine($"Task Hub: {taskHub.Data.Name}");358359// Cleanup360await taskHub.DeleteAsync(WaitUntil.Completed);361await scheduler.DeleteAsync(WaitUntil.Completed);362```363364## Related SDKs365366| SDK | Purpose | Install |367|-----|---------|---------|368| `Azure.ResourceManager.DurableTask` | Management plane (this SDK) | `dotnet add package Azure.ResourceManager.DurableTask` |369| `Microsoft.DurableTask.Client.AzureManaged` | Data plane (orchestrations, activities) | `dotnet add package Microsoft.DurableTask.Client.AzureManaged` |370| `Microsoft.DurableTask.Worker.AzureManaged` | Worker for running orchestrations | `dotnet add package Microsoft.DurableTask.Worker.AzureManaged` |371| `Azure.Identity` | Authentication | `dotnet add package Azure.Identity` |372| `Azure.ResourceManager` | Base ARM SDK | `dotnet add package Azure.ResourceManager` |373374## Source Reference375376- [GitHub: Azure.ResourceManager.DurableTask](https://github.com/Azure/azure-sdk-for-net/tree/main/sdk/durabletask/Azure.ResourceManager.DurableTask)377- [NuGet: Azure.ResourceManager.DurableTask](https://www.nuget.org/packages/Azure.ResourceManager.DurableTask)378
Full transparency — inspect the skill content before installing.