使用 ARM 模板部署资源

阿克谢·H

我有一个场景,我需要使用相同的应用服务计划在另一个资源组中部署资源(应用服务)。

应用服务计划驻留在另一个资源组中。

我试过这个,它给出了“应用服务计划未找到错误”。这是 Deployment.json 文件。

参考:https : //docs.microsoft.com/en-us/azure/bot-service/bot-builder-deploy-az-cli?view=azure-bot-service-4.0&tabs=csharp#option-1-existing -应用程序服务计划

当我们尝试在同一资源组中部署应用程序而不创建新计划时,此部署 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."
        }
    },
    "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/"
                    ]
                }
            }
        }
    },
    {
        "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'))]"
        ]
    }
]

}

马基

您必须在resourceId按照文档使用该功能时指定应用服务计划所在的资源组

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

使用ARM模板部署多个资源

使用 ARM 模板在部署 NSG 流日志时自动启用网络观察程序资源

如何增加ARM模板资源的部署延迟?

使用 Octopus Deploy in a Package 部署 ARM 模板

使用ARM模板部署Azure数据工厂

无法使用NotificationHub + ApnsCredentials部署Arm模板

ARM模板部署-资源标识符格式错误

在ARM模板中有条件地部署资源

如何找到ARM模板和实际部署的资源之间的差异?

部署1个包含多个资源的单个ARM模板还是并行部署单独的资源?

使用DevOps部署ARM模板时出现奇怪的错误

使用 arm 模板部署 azure Key Vault Secret 出现错误

如何使用 ARM 模板在存储帐户中部署文件共享

使用 Python SDK 部署 ARM 模板的权限不足

如何使用arm模板部署python azure函数?

Azure。如何使用ARM模板从托管映像部署VM

Azure ARM模板使用cname和证书部署网站

使用ARM模板为容器部署Web App

使用Azure Devops部署Azure策略ARM模板失败

使用ARM模板创建Microsoft.Web / serverfarms资源

ARM 模板:如何引用使用参数设置名称的资源

ARM模板-部署customScriptForLinux

Azure ARM模板嵌套模板部署不会更新资源\无法启动

如何使用 ARM 模板`contentVersion`?

ARM模板-网站部署失败

部署vNet的ARM模板失败

arm模板800资源限制

使用New-AzureRmDeployment和链接的ARM模板创建资源组和资源时如何获取资源组名称?

ARM 模板部署过程中出现“KeyVault 参数‘’的资源标识符无效”错误