Botframework Azure模板取决于MsTeamsChannel CLI的部署模板验证失败

时间:2020-06-30 11:20:44

标签: azure deployment azure-cli azure-deployment azure-template

我正在尝试执行Azure CLI的以下指令:

az deployment sub create --name  "ThisIsATest"  --location northeurope
--template-file /Users/muzcateg/Documents/TeaBotframeworkVIP/DeploymentTemplates/template-with-new-rg.json
--parameters appId="7450874d-a8cb-4613-b021-621a34b21bbb" appSecret="ThisIsATest123456789" botId="ThisIsATest" botSku=F0 newAppServicePlanName="ThisIsATestServicePlan" newWebAppName="ThisIsATestWebApp" groupName="ThisIsATestResources" groupLocation="northeurope" newAppServicePlanLocation="northeurope" 
--output json

我收到此错误:

{
    'additionalProperties': {},
    'code': 'InvalidTemplate',
    'message': "Deployment template validation failed: 'The resource '/subscriptions/63c45336-738e-4431-b8cd-21097fd6a9f4/resourceGroups/ThisIsATestResources/providers/Microsoft.BotService/botServices/ThisIsATest/channels/MsTeamsChannel' at line '1' and column '2080' doesn't depend on parent resource '/subscriptions/63c45336-738e-4431-b8cd-21097fd6a9f4/resourceGroups/ThisIsATestResources/providers/Microsoft.BotService/botServices/ThisIsATest'. Please add dependency explicitly using the 'dependsOn' syntax. Please see https://aka.ms/arm-template/#resources for usage details.'.",
    'target': None,
    'details': None,
    'additionalInfo': [{
        'additionalProperties': {},
        'type': 'TemplateViolation',
        'info': {
            'lineNumber': 1,
            'linePosition': 2080,
            'path': 'properties.template.resources[2].resources[0]'
        }
    }]
}

我使用的是Botframework GIT示例中的标准模板(template-with-new-rg.json),我尝试了很多更改以查看是否可以使它工作但没有成功。

我的一位同事正在她的PC上正确执行指令,她正在使用CLI 2.7.0,我正在使用2.8.0,并且我也将其更改为2.7.0,我们应该在Azure中具有相同的权限

以防万一,这是模板代码:

{
    "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "groupLocation": {
            "type": "string",
            "metadata": {
                "description": "Specifies the location of the Resource Group."
            }
        },
        "groupName": {
            "type": "string",
            "metadata": {
                "description": "Specifies the name of the Resource Group."
            }
        },
        "appId": {
            "type": "string",
            "metadata": {
                "description": "Active Directory App ID, set as MicrosoftAppId in the Web App's Application Settings."
            }
        },
        "appSecret": {
            "type": "string",
            "metadata": {
                "description": "Active Directory App Password, set as MicrosoftAppPassword in the Web App's Application Settings."
            }
        },
        "botId": {
            "type": "string",
            "metadata": {
                "description": "The globally unique and immutable bot ID. Also used to configure the displayName of the bot, which is mutable."
            }
        },
        "botSku": {
            "type": "string",
            "metadata": {
                "description": "The pricing tier of the Bot Service Registration. Acceptable values are F0 and S1."
            }
        },
        "newAppServicePlanName": {
            "type": "string",
            "metadata": {
                "description": "The name of the App Service Plan."
            }
        },
        "newAppServicePlanSku": {
            "type": "object",
            "defaultValue": {
                "name": "S1",
                "tier": "Standard",
                "size": "S1",
                "family": "S",
                "capacity": 1
            },
            "metadata": {
                "description": "The SKU of the App Service Plan. Defaults to Standard values."
            }
        },
        "newAppServicePlanLocation": {
            "type": "string",
            "metadata": {
                "description": "The location of the App Service Plan. Defaults to \"westus\"."
            }
        },
        "newWebAppName": {
            "type": "string",
            "defaultValue": "",
            "metadata": {
                "description": "The globally unique name of the Web App. Defaults to the value passed in for \"botId\"."
            }
        }
    },
    "variables": {
        "appServicePlanName": "[parameters('newAppServicePlanName')]",
        "resourcesLocation": "[parameters('newAppServicePlanLocation')]",
        "webAppName": "[if(empty(parameters('newWebAppName')), parameters('botId'), parameters('newWebAppName'))]",
        "siteHost": "[concat(variables('webAppName'), '.azurewebsites.net')]",
        "botEndpoint": "[concat('https://', variables('siteHost'), '/api/messages')]"
    },
    "resources": [
        {
            "name": "[parameters('groupName')]",
            "type": "Microsoft.Resources/resourceGroups",
            "apiVersion": "2018-05-01",
            "location": "[parameters('groupLocation')]",
            "properties": {
            }
        },
        {
            "type": "Microsoft.Resources/deployments",
            "apiVersion": "2018-05-01",
            "name": "storageDeployment",
            "resourceGroup": "[parameters('groupName')]",
            "dependsOn": [
                "[resourceId('Microsoft.Resources/resourceGroups/', parameters('groupName'))]"
            ],
            "properties": {
                "mode": "Incremental",
                "template": {
                    "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
                    "contentVersion": "1.0.0.0",
                    "parameters": {},
                    "variables": {},
                    "resources": [
                        {
                            "comments": "Create a new App Service Plan",
                            "type": "Microsoft.Web/serverfarms",
                            "name": "[variables('appServicePlanName')]",
                            "apiVersion": "2018-02-01",
                            "location": "[variables('resourcesLocation')]",
                            "sku": "[parameters('newAppServicePlanSku')]",
                            "properties": {
                                "name": "[variables('appServicePlanName')]"
                            }
                        },
                        {
                            "comments": "Create a Web App using the new App Service Plan",
                            "type": "Microsoft.Web/sites",
                            "apiVersion": "2015-08-01",
                            "location": "[variables('resourcesLocation')]",
                            "kind": "app",
                            "dependsOn": [
                                "[resourceId('Microsoft.Web/serverfarms/', variables('appServicePlanName'))]"
                            ],
                            "name": "[variables('webAppName')]",
                            "properties": {
                                "name": "[variables('webAppName')]",
                                "serverFarmId": "[variables('appServicePlanName')]",
                                "siteConfig": {
                                    "appSettings": [
                                        {
                                            "name": "WEBSITE_NODE_DEFAULT_VERSION",
                                            "value": "10.14.1"
                                        },
                                        {
                                            "name": "MicrosoftAppId",
                                            "value": "[parameters('appId')]"
                                        },
                                        {
                                            "name": "MicrosoftAppPassword",
                                            "value": "[parameters('appSecret')]"
                                        }
                                    ],
                                    "cors": {
                                        "allowedOrigins": [
                                            "https://botservice.hosting.portal.azure.net",
                                            "https://hosting.onecloud.azure-test.net/"
                                        ]
                                    }
                                }
                            }
                        },
                      {
                        "apiVersion": "2017-12-01",
                        "type": "Microsoft.BotService/botServices",
                        "name": "[parameters('botId')]",
                        "location": "global",
                        "kind": "bot",
                        "sku": {
                          "name": "[parameters('botSku')]"
                        },
                        "properties": {
                          "name": "[parameters('botId')]",
                          "displayName": "[parameters('botId')]",
                          "endpoint": "[variables('botEndpoint')]",
                          "msaAppId": "[parameters('appId')]",
                          "developerAppInsightsApplicationId": null,
                          "developerAppInsightKey": null,
                          "publishingCredentials": null,
                          "storageResourceId": null
                        },
                        "resources": [
                          {
                            "name": "MsTeamsChannel",
                            "type": "channels",
                            "location": "global",
                            "apiVersion": "2018-07-12",
                            "kind": "bot",
                            "properties": {
                              "channelName": "MsTeamsChannel"
                            },
                            "dependsOn": [
                              "[resourceId('Microsoft.BotService/botServices', parameters('botId'))]"
                            ]
                          }
                        ],
                        "dependsOn": [
                          "[resourceId('Microsoft.Web/sites/', variables('webAppName'))]"
                        ]
                      }
                    ],
                    "outputs": {}
                }
            }
        }
    ]
}

在此先感谢您的帮助。

1 个答案:

答案 0 :(得分:0)

在我们的案例2.0.7中,该模板仅适用于旧版本的de Azure CLI,因此经过大量测试和阅读之后,我们最终使用Azure CLI 2.7.0和2.8.0部署了此JSON文件

{
    "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "appId": {
            "type": "string",
            "metadata": {
                "description": "Active Directory App ID, set as MicrosoftAppId in the Web App's Application Settings."
            }
        },
        "appSecret": {
            "type": "string",
            "metadata": {
                "description": "Active Directory App Password, set as MicrosoftAppPassword in the Web App's Application Settings. Defaults to \"\"."
            }
        },
        "botId": {
            "type": "string",
            "metadata": {
                "description": "The globally unique and immutable bot ID. Also used to configure the displayName of the bot, which is mutable."
            }
        },
        "botSku": {
            "defaultValue": "F0",
            "type": "string",
            "metadata": {
                "description": "The pricing tier of the Bot Service Registration. Acceptable values are F0 and S1."
            }
        },
        "newAppServicePlanName": {
            "type": "string",
            "defaultValue": "",
            "metadata": {
                "description": "The name of the new App Service Plan."
            }
        },
        "newAppServicePlanSku": {
            "type": "object",
            "defaultValue": {
                "name": "S1",
                "tier": "Standard",
                "size": "S1",
                "family": "S",
                "capacity": 1
            },
            "metadata": {
                "description": "The SKU of the App Service Plan. Defaults to Standard values."
            }
        },
        "appServicePlanLocation": {
            "type": "string",
            "metadata": {
                "description": "The location of the App Service Plan."
            }
        },
        "existingAppServicePlan": {
            "type": "string",
            "defaultValue": "",
            "metadata": {
                "description": "Name of the existing App Service Plan used to create the Web App for the bot."
            }
        },
        "existingAppServicePlanResourceGroup": {
            "type": "string",
            "defaultValue": "",
            "metadata": {
                "description": "Name of the resource group for the existing App Service Plan used to create the Web App for the bot."
            }
        },        
        "newWebAppName": {
            "type": "string",
            "defaultValue": "",
            "metadata": {
                "description": "The globally unique name of the Web App. Defaults to the value passed in for \"botId\"."
            }
        }
    },
    "variables": {
        "defaultAppServicePlanName": "[if(empty(parameters('existingAppServicePlan')), 'createNewAppServicePlan', parameters('existingAppServicePlan'))]",
        "useExistingAppServicePlan": "[not(equals(variables('defaultAppServicePlanName'), 'createNewAppServicePlan'))]",
        "servicePlanName": "[if(variables('useExistingAppServicePlan'), parameters('existingAppServicePlan'), parameters('newAppServicePlanName'))]",
        "resourcesLocation": "[parameters('appServicePlanLocation')]",
        "webAppName": "[if(empty(parameters('newWebAppName')), parameters('botId'), parameters('newWebAppName'))]",
        "siteHost": "[concat(variables('webAppName'), '.azurewebsites.net')]",
        "botEndpoint": "[concat('https://', variables('siteHost'), '/api/messages')]"
    },
    "resources": [
        {
            "comments": "Create a new App Service Plan if no existing App Service Plan name was passed in.",
            "type": "Microsoft.Web/serverfarms",
            "condition": "[not(variables('useExistingAppServicePlan'))]",
            "name": "[variables('servicePlanName')]",
            "apiVersion": "2018-02-01",
            "location": "[variables('resourcesLocation')]",
            "sku": "[parameters('newAppServicePlanSku')]",
            "properties": {
                "name": "[variables('servicePlanName')]"
            }
        },
        {
            "comments": "Create a Web App using an App Service Plan",
            "type": "Microsoft.Web/sites",
            "apiVersion": "2015-08-01",
            "location": "[variables('resourcesLocation')]",
            "kind": "app",
            "dependsOn": [
                "[resourceId('Microsoft.Web/serverfarms', variables('servicePlanName'))]"
            ],
            "name": "[variables('webAppName')]",
            "properties": {
                "name": "[variables('webAppName')]",
                "serverFarmId": "[resourceId('Microsoft.Web/serverfarms', variables('servicePlanName'))]",
                "siteConfig": {
                    "appSettings": [
                        {
                            "name": "WEBSITE_NODE_DEFAULT_VERSION",
                            "value": "10.14.1"
                        },
                        {
                            "name": "MicrosoftAppId",
                            "value": "[parameters('appId')]"
                        },
                        {
                            "name": "MicrosoftAppPassword",
                            "value": "[parameters('appSecret')]"
                        }
                    ],
                    "cors": {
                        "allowedOrigins": [
                            "https://botservice.hosting.portal.azure.net",
                            "https://hosting.onecloud.azure-test.net/"
                        ]
                    },
                    "webSocketsEnabled": true
                }
            }
        },
        {
            "apiVersion": "2017-12-01",
            "type": "Microsoft.BotService/botServices",
            "name": "[parameters('botId')]",
            "location": "global",
            "kind": "bot",
            "sku": {
                "name": "[parameters('botSku')]"
            },
            "properties": {
                "name": "[parameters('botId')]",
                "displayName": "[parameters('botId')]",
                "endpoint": "[variables('botEndpoint')]",
                "msaAppId": "[parameters('appId')]",
                "developerAppInsightsApplicationId": null,
                "developerAppInsightKey": null,
                "publishingCredentials": null,
                "storageResourceId": null
            },
            "dependsOn": [
                "[resourceId('Microsoft.Web/sites/', variables('webAppName'))]"
            ]
        }
    ]
}

感谢所有人。

相关问题