|
Add this skill
npx mdskills install sickn33/azure-mgmt-botservice-dotnetComprehensive SDK documentation with clear examples but lacks agent-specific triggers and workflows
1---2name: azure-mgmt-botservice-dotnet3description: |4 Azure Resource Manager SDK for Bot Service in .NET. Management plane operations for creating and managing Azure Bot resources, channels (Teams, DirectLine, Slack), and connection settings. Triggers: "Bot Service", "BotResource", "Azure Bot", "DirectLine channel", "Teams channel", "bot management .NET", "create bot".5package: Azure.ResourceManager.BotService6---78# Azure.ResourceManager.BotService (.NET)910Management plane SDK for provisioning and managing Azure Bot Service resources via Azure Resource Manager.1112## Installation1314```bash15dotnet add package Azure.ResourceManager.BotService16dotnet add package Azure.Identity17```1819**Current Versions**: Stable v1.1.1, Preview v1.1.0-beta.12021## Environment Variables2223```bash24AZURE_SUBSCRIPTION_ID=<your-subscription-id>25# For service principal auth (optional)26AZURE_TENANT_ID=<tenant-id>27AZURE_CLIENT_ID=<client-id>28AZURE_CLIENT_SECRET=<client-secret>29```3031## Authentication3233```csharp34using Azure.Identity;35using Azure.ResourceManager;36using Azure.ResourceManager.BotService;3738// Authenticate using DefaultAzureCredential39var credential = new DefaultAzureCredential();40ArmClient armClient = new ArmClient(credential);4142// Get subscription and resource group43SubscriptionResource subscription = await armClient.GetDefaultSubscriptionAsync();44ResourceGroupResource resourceGroup = await subscription.GetResourceGroups().GetAsync("myResourceGroup");4546// Access bot collection47BotCollection botCollection = resourceGroup.GetBots();48```4950## Resource Hierarchy5152```53ArmClient54└── SubscriptionResource55 └── ResourceGroupResource56 └── BotResource57 ├── BotChannelResource (DirectLine, Teams, Slack, etc.)58 ├── BotConnectionSettingResource (OAuth connections)59 └── BotServicePrivateEndpointConnectionResource60```6162## Core Workflows6364### 1. Create Bot Resource6566```csharp67using Azure.ResourceManager.BotService;68using Azure.ResourceManager.BotService.Models;6970// Create bot data71var botData = new BotData(AzureLocation.WestUS2)72{73 Kind = BotServiceKind.Azurebot,74 Sku = new BotServiceSku(BotServiceSkuName.F0),75 Properties = new BotProperties(76 displayName: "MyBot",77 endpoint: new Uri("https://mybot.azurewebsites.net/api/messages"),78 msaAppId: "<your-msa-app-id>")79 {80 Description = "My Azure Bot",81 MsaAppType = BotMsaAppType.MultiTenant82 }83};8485// Create or update the bot86ArmOperation<BotResource> operation = await botCollection.CreateOrUpdateAsync(87 WaitUntil.Completed,88 "myBotName",89 botData);9091BotResource bot = operation.Value;92Console.WriteLine($"Bot created: {bot.Data.Name}");93```9495### 2. Configure DirectLine Channel9697```csharp98// Get the bot99BotResource bot = await resourceGroup.GetBots().GetAsync("myBotName");100101// Get channel collection102BotChannelCollection channels = bot.GetBotChannels();103104// Create DirectLine channel configuration105var channelData = new BotChannelData(AzureLocation.WestUS2)106{107 Properties = new DirectLineChannel()108 {109 Properties = new DirectLineChannelProperties()110 {111 Sites =112 {113 new DirectLineSite("Default Site")114 {115 IsEnabled = true,116 IsV1Enabled = false,117 IsV3Enabled = true,118 IsSecureSiteEnabled = true119 }120 }121 }122 }123};124125// Create or update the channel126ArmOperation<BotChannelResource> channelOp = await channels.CreateOrUpdateAsync(127 WaitUntil.Completed,128 BotChannelName.DirectLineChannel,129 channelData);130131Console.WriteLine("DirectLine channel configured");132```133134### 3. Configure Microsoft Teams Channel135136```csharp137var teamsChannelData = new BotChannelData(AzureLocation.WestUS2)138{139 Properties = new MsTeamsChannel()140 {141 Properties = new MsTeamsChannelProperties()142 {143 IsEnabled = true,144 EnableCalling = false145 }146 }147};148149await channels.CreateOrUpdateAsync(150 WaitUntil.Completed,151 BotChannelName.MsTeamsChannel,152 teamsChannelData);153```154155### 4. Configure Web Chat Channel156157```csharp158var webChatChannelData = new BotChannelData(AzureLocation.WestUS2)159{160 Properties = new WebChatChannel()161 {162 Properties = new WebChatChannelProperties()163 {164 Sites =165 {166 new WebChatSite("Default Site")167 {168 IsEnabled = true169 }170 }171 }172 }173};174175await channels.CreateOrUpdateAsync(176 WaitUntil.Completed,177 BotChannelName.WebChatChannel,178 webChatChannelData);179```180181### 5. Get Bot and List Channels182183```csharp184// Get bot185BotResource bot = await botCollection.GetAsync("myBotName");186Console.WriteLine($"Bot: {bot.Data.Properties.DisplayName}");187Console.WriteLine($"Endpoint: {bot.Data.Properties.Endpoint}");188189// List channels190await foreach (BotChannelResource channel in bot.GetBotChannels().GetAllAsync())191{192 Console.WriteLine($"Channel: {channel.Data.Name}");193}194```195196### 6. Regenerate DirectLine Keys197198```csharp199var regenerateRequest = new BotChannelRegenerateKeysContent(BotChannelName.DirectLineChannel)200{201 SiteName = "Default Site"202};203204BotChannelResource channelWithKeys = await bot.GetBotChannelWithRegenerateKeysAsync(regenerateRequest);205```206207### 7. Update Bot208209```csharp210BotResource bot = await botCollection.GetAsync("myBotName");211212// Update using patch213var updateData = new BotData(bot.Data.Location)214{215 Properties = new BotProperties(216 displayName: "Updated Bot Name",217 endpoint: bot.Data.Properties.Endpoint,218 msaAppId: bot.Data.Properties.MsaAppId)219 {220 Description = "Updated description"221 }222};223224await bot.UpdateAsync(updateData);225```226227### 8. Delete Bot228229```csharp230BotResource bot = await botCollection.GetAsync("myBotName");231await bot.DeleteAsync(WaitUntil.Completed);232```233234## Supported Channel Types235236| Channel | Constant | Class |237|---------|----------|-------|238| Direct Line | `BotChannelName.DirectLineChannel` | `DirectLineChannel` |239| Direct Line Speech | `BotChannelName.DirectLineSpeechChannel` | `DirectLineSpeechChannel` |240| Microsoft Teams | `BotChannelName.MsTeamsChannel` | `MsTeamsChannel` |241| Web Chat | `BotChannelName.WebChatChannel` | `WebChatChannel` |242| Slack | `BotChannelName.SlackChannel` | `SlackChannel` |243| Facebook | `BotChannelName.FacebookChannel` | `FacebookChannel` |244| Email | `BotChannelName.EmailChannel` | `EmailChannel` |245| Telegram | `BotChannelName.TelegramChannel` | `TelegramChannel` |246| Telephony | `BotChannelName.TelephonyChannel` | `TelephonyChannel` |247248## Key Types Reference249250| Type | Purpose |251|------|---------|252| `ArmClient` | Entry point for all ARM operations |253| `BotResource` | Represents an Azure Bot resource |254| `BotCollection` | Collection for bot CRUD |255| `BotData` | Bot resource definition |256| `BotProperties` | Bot configuration properties |257| `BotChannelResource` | Channel configuration |258| `BotChannelCollection` | Collection of channels |259| `BotChannelData` | Channel configuration data |260| `BotConnectionSettingResource` | OAuth connection settings |261262## BotServiceKind Values263264| Value | Description |265|-------|-------------|266| `BotServiceKind.Azurebot` | Azure Bot (recommended) |267| `BotServiceKind.Bot` | Legacy Bot Framework bot |268| `BotServiceKind.Designer` | Composer bot |269| `BotServiceKind.Function` | Function bot |270| `BotServiceKind.Sdk` | SDK bot |271272## BotServiceSkuName Values273274| Value | Description |275|-------|-------------|276| `BotServiceSkuName.F0` | Free tier |277| `BotServiceSkuName.S1` | Standard tier |278279## BotMsaAppType Values280281| Value | Description |282|-------|-------------|283| `BotMsaAppType.MultiTenant` | Multi-tenant app |284| `BotMsaAppType.SingleTenant` | Single-tenant app |285| `BotMsaAppType.UserAssignedMSI` | User-assigned managed identity |286287## Best Practices2882891. **Always use `DefaultAzureCredential`** — supports multiple auth methods2902. **Use `WaitUntil.Completed`** for synchronous operations2913. **Handle `RequestFailedException`** for API errors2924. **Use async methods** (`*Async`) for all operations2935. **Store MSA App credentials securely** — use Key Vault for secrets2946. **Use managed identity** (`BotMsaAppType.UserAssignedMSI`) for production bots2957. **Enable secure sites** for DirectLine channels in production296297## Error Handling298299```csharp300using Azure;301302try303{304 var operation = await botCollection.CreateOrUpdateAsync(305 WaitUntil.Completed,306 botName,307 botData);308}309catch (RequestFailedException ex) when (ex.Status == 409)310{311 Console.WriteLine("Bot already exists");312}313catch (RequestFailedException ex)314{315 Console.WriteLine($"ARM Error: {ex.Status} - {ex.ErrorCode}: {ex.Message}");316}317```318319## Related SDKs320321| SDK | Purpose | Install |322|-----|---------|---------|323| `Azure.ResourceManager.BotService` | Bot management (this SDK) | `dotnet add package Azure.ResourceManager.BotService` |324| `Microsoft.Bot.Builder` | Bot Framework SDK | `dotnet add package Microsoft.Bot.Builder` |325| `Microsoft.Bot.Builder.Integration.AspNet.Core` | ASP.NET Core integration | `dotnet add package Microsoft.Bot.Builder.Integration.AspNet.Core` |326327## Reference Links328329| Resource | URL |330|----------|-----|331| NuGet Package | https://www.nuget.org/packages/Azure.ResourceManager.BotService |332| API Reference | https://learn.microsoft.com/dotnet/api/azure.resourcemanager.botservice |333| GitHub Source | https://github.com/Azure/azure-sdk-for-net/tree/main/sdk/botservice/Azure.ResourceManager.BotService |334| Azure Bot Service Docs | https://learn.microsoft.com/azure/bot-service/ |335
Full transparency — inspect the skill content before installing.