Skip to main content 首页 创作者 christophacham agent-skills-library azure-mgmt-botservice-dotnet
azure-mgmt-botservice-dotnet 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.
跳到安装 Skills Marketplace 发现并探索由社区构建的 Agent Skills
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/christophacham/agent-skills-library --skill azure-mgmt-botservice-dotnet命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
下载 Zip 下载中... name azure-mgmt-botservice-dotnet description 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. risk unknown source community date_added 2026-02-27
Azure.ResourceManager.BotService (.NET)
Management plane SDK for provisioning and managing Azure Bot Service resources via Azure Resource Manager.
Installation
dotnet add package Azure.ResourceManager.BotService
dotnet add package Azure.Identity
Current Versions : Stable v1.1.1, Preview v1.1.0-beta.1
Environment Variables
AZURE_SUBSCRIPTION_ID=<your-subscription-id>
AZURE_TENANT_ID=<tenant-id>
AZURE_CLIENT_ID=<client-id>
AZURE_CLIENT_SECRET=<client-secret>
Authentication
using Azure.Identity;
using Azure.ResourceManager;
using Azure.ResourceManager.BotService;
credential = DefaultAzureCredential();
ArmClient armClient = ArmClient(credential);
SubscriptionResource subscription = armClient.GetDefaultSubscriptionAsync();
ResourceGroupResource resourceGroup = subscription.GetResourceGroups().GetAsync( );
BotCollection botCollection = resourceGroup.GetBots();
var
new
new
await
await
"myResourceGroup"
Resource Hierarchy ArmClient
└── SubscriptionResource
└── ResourceGroupResource
└── BotResource
├── BotChannelResource (DirectLine, Teams, Slack, etc.)
├── BotConnectionSettingResource (OAuth connections)
└── BotServicePrivateEndpointConnectionResource
Core Workflows
1. Create Bot Resource using Azure.ResourceManager.BotService;
using Azure.ResourceManager.BotService.Models;
var botData = new BotData(AzureLocation.WestUS2)
{
Kind = BotServiceKind.Azurebot,
Sku = new BotServiceSku(BotServiceSkuName.F0),
Properties = new BotProperties(
displayName: "MyBot" ,
endpoint: new Uri("https://mybot.azurewebsites.net/api/messages" ),
msaAppId: "<your-msa-app-id>" )
{
Description = "My Azure Bot" ,
MsaAppType = BotMsaAppType.MultiTenant
}
};
ArmOperation<BotResource> operation = await botCollection.CreateOrUpdateAsync(
WaitUntil.Completed,
"myBotName" ,
botData);
BotResource bot = operation.Value;
Console.WriteLine($"Bot created: {bot.Data.Name} " );
2. Configure DirectLine Channel
BotResource bot = await resourceGroup.GetBots().GetAsync("myBotName" );
BotChannelCollection channels = bot.GetBotChannels();
var channelData = new BotChannelData(AzureLocation.WestUS2)
{
Properties = new DirectLineChannel()
{
Properties = new DirectLineChannelProperties()
{
Sites =
{
new DirectLineSite("Default Site" )
{
IsEnabled = true ,
IsV1Enabled = false ,
IsV3Enabled = true ,
IsSecureSiteEnabled = true
}
}
}
}
};
ArmOperation<BotChannelResource> channelOp = await channels.CreateOrUpdateAsync(
WaitUntil.Completed,
BotChannelName.DirectLineChannel,
channelData);
Console.WriteLine("DirectLine channel configured" );
3. Configure Microsoft Teams Channel var teamsChannelData = new BotChannelData(AzureLocation.WestUS2)
{
Properties = new MsTeamsChannel()
{
Properties = new MsTeamsChannelProperties()
{
IsEnabled = true ,
EnableCalling = false
}
}
};
await channels.CreateOrUpdateAsync(
WaitUntil.Completed,
BotChannelName.MsTeamsChannel,
teamsChannelData);
4. Configure Web Chat Channel var webChatChannelData = new BotChannelData(AzureLocation.WestUS2)
{
Properties = new WebChatChannel()
{
Properties = new WebChatChannelProperties()
{
Sites =
{
new WebChatSite("Default Site" )
{
IsEnabled = true
}
}
}
}
};
await channels.CreateOrUpdateAsync(
WaitUntil.Completed,
BotChannelName.WebChatChannel,
webChatChannelData);
5. Get Bot and List Channels
BotResource bot = await botCollection.GetAsync("myBotName" );
Console.WriteLine($"Bot: {bot.Data.Properties.DisplayName} " );
Console.WriteLine($"Endpoint: {bot.Data.Properties.Endpoint} " );
await foreach (BotChannelResource channel in bot.GetBotChannels().GetAllAsync())
{
Console.WriteLine($"Channel: {channel.Data.Name} " );
}
6. Regenerate DirectLine Keys var regenerateRequest = new BotChannelRegenerateKeysContent(BotChannelName.DirectLineChannel)
{
SiteName = "Default Site"
};
BotChannelResource channelWithKeys = await bot.GetBotChannelWithRegenerateKeysAsync(regenerateRequest);
7. Update Bot BotResource bot = await botCollection.GetAsync("myBotName" );
var updateData = new BotData(bot.Data.Location)
{
Properties = new BotProperties(
displayName: "Updated Bot Name" ,
endpoint: bot.Data.Properties.Endpoint,
msaAppId: bot.Data.Properties.MsaAppId)
{
Description = "Updated description"
}
};
await bot.UpdateAsync(updateData);
8. Delete Bot BotResource bot = await botCollection.GetAsync("myBotName" );
await bot.DeleteAsync(WaitUntil.Completed);
Supported Channel Types Channel Constant Class Direct Line BotChannelName.DirectLineChannelDirectLineChannelDirect Line Speech BotChannelName.DirectLineSpeechChannelDirectLineSpeechChannelMicrosoft Teams BotChannelName.MsTeamsChannelMsTeamsChannelWeb Chat BotChannelName.WebChatChannelWebChatChannelSlack BotChannelName.SlackChannelSlackChannelFacebook BotChannelName.FacebookChannelFacebookChannelEmail BotChannelName.EmailChannelEmailChannelTelegram BotChannelName.TelegramChannelTelegramChannelTelephony BotChannelName.TelephonyChannelTelephonyChannel
Key Types Reference Type Purpose ArmClientEntry point for all ARM operations BotResourceRepresents an Azure Bot resource BotCollectionCollection for bot CRUD BotDataBot resource definition BotPropertiesBot configuration properties BotChannelResourceChannel configuration BotChannelCollectionCollection of channels BotChannelDataChannel configuration data BotConnectionSettingResourceOAuth connection settings
BotServiceKind Values Value Description BotServiceKind.AzurebotAzure Bot (recommended) BotServiceKind.BotLegacy Bot Framework bot BotServiceKind.DesignerComposer bot BotServiceKind.FunctionFunction bot BotServiceKind.SdkSDK bot
BotServiceSkuName Values Value Description BotServiceSkuName.F0Free tier BotServiceSkuName.S1Standard tier
BotMsaAppType Values Value Description BotMsaAppType.MultiTenantMulti-tenant app BotMsaAppType.SingleTenantSingle-tenant app BotMsaAppType.UserAssignedMSIUser-assigned managed identity
Best Practices
Always use DefaultAzureCredential — supports multiple auth methods
Use WaitUntil.Completed for synchronous operations
Handle RequestFailedException for API errors
Use async methods (*Async) for all operations
Store MSA App credentials securely — use Key Vault for secrets
Use managed identity (BotMsaAppType.UserAssignedMSI) for production bots
Enable secure sites for DirectLine channels in production
Error Handling using Azure;
try
{
var operation = await botCollection.CreateOrUpdateAsync(
WaitUntil.Completed,
botName,
botData);
}
catch (RequestFailedException ex) when (ex.Status == 409 )
{
Console.WriteLine("Bot already exists" );
}
catch (RequestFailedException ex)
{
Console.WriteLine($"ARM Error: {ex.Status} - {ex.ErrorCode} : {ex.Message} " );
}
Related SDKs SDK Purpose Install Azure.ResourceManager.BotServiceBot management (this SDK) dotnet add package Azure.ResourceManager.BotServiceMicrosoft.Bot.BuilderBot Framework SDK dotnet add package Microsoft.Bot.BuilderMicrosoft.Bot.Builder.Integration.AspNet.CoreASP.NET Core integration dotnet add package Microsoft.Bot.Builder.Integration.AspNet.Core
Reference Links
When to Use This skill is applicable to execute the workflow or actions described in the overview.