新Bot服务创建Bot的可用ARM模板及Azure CLI等效门户操作咨询
嘿,我来帮你搞定这两个Azure Bot服务的问题,都是日常运维里挺实用的点:
问题一:是否存在可用于新Bot服务下创建Bot的ARM模板
当然有!Azure Bot服务完全支持通过ARM模板来自动化创建Bot,这在批量部署或者基础设施即代码场景里特别好用。我实际用过不少次,给你一个简化版的ARM模板示例,你可以根据自己的需求调整参数:
{ "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", "contentVersion": "1.0.0.0", "parameters": { "botName": { "type": "string", "metadata": { "description": "The name of the Bot Service resource." } }, "location": { "type": "string", "defaultValue": "[resourceGroup().location]", "metadata": { "description": "The location for the Bot Service resource." } }, "sku": { "type": "string", "defaultValue": "F0", "allowedValues": ["F0", "S1"], "metadata": { "description": "The SKU of the Bot Service." } }, "msaAppId": { "type": "string", "metadata": { "description": "The Microsoft App ID for the Bot." } } }, "resources": [ { "type": "Microsoft.BotService/botServices", "apiVersion": "2022-09-15", "name": "[parameters('botName')]", "location": "[parameters('location')]", "sku": { "name": "[parameters('sku')]" }, "properties": { "displayName": "[parameters('botName')]", "endpoint": "https://your-bot-endpoint.azurewebsites.net/api/messages", "msaAppId": "[parameters('msaAppId')]" } } ] }
这个模板里的核心是Microsoft.BotService/botServices资源类型,你需要提前准备好Microsoft App ID(通过Azure AD注册应用即可获取),再根据实际的Bot服务地址调整endpoint字段。如果要部署关联的Web App或其他附属资源,直接把对应的资源定义加到模板里就行。
问题二:能否通过Azure CLI找到与Azure门户GUI对应的等效操作方法
必须可以!Azure CLI几乎覆盖了门户里所有Bot服务的操作,我整理了几个最常用的对应场景:
创建Bot服务(对应门户「创建资源」→「Bot服务」流程)
使用az bot create命令,示例:az bot create --resource-group your-resource-group --name your-bot-name --kind registration --sku F0 --msa-app-id your-msa-app-id --msa-app-password your-msa-app-password --location eastus参数里的
--kind可以根据Bot类型调整,比如webapp对应Web App托管的Bot,registration对应注册型Bot。查看Bot详情(对应门户里Bot的「概述」页面)
az bot show --resource-group your-resource-group --name your-bot-name更新Bot的消息端点(对应门户里Bot「配置」页面修改端点)
az bot update --resource-group your-resource-group --name your-bot-name --endpoint https://new-bot-endpoint.azurewebsites.net/api/messages删除Bot服务(对应门户里Bot资源的「删除」操作)
az bot delete --resource-group your-resource-group --name your-bot-name
如果要管理Bot的通道(对应门户「通道」页面),可以用az bot channel系列子命令,比如az bot channel create来添加Teams通道,完全和门户操作一一对应。
内容的提问来源于stack exchange,提问作者rustyocean
相关产品推荐
相关产品推荐

