azure - 如何使用 cloningInfo 创建 azure 插槽?

标签 azure azure-web-app-service azure-resource-manager azure-rm-template

我正在尝试向我的模板添加一个插槽,并且希望让它克隆生产插槽的配置(就像门户提供的那样)。似乎 cloningInfo 是执行此操作的方法,但 sourceWebAppId 似乎不足以完成此操作。当我只指定该属性时,我收到一个 HTTP 错误,这没有帮助。我找不到任何使用 cloningInfo 复制插槽的示例模板。

这是我的网站资源:

                {
                "apiVersion": "2016-08-01",
                "name": "staging",
                "type": "slots",
                "location": "[resourceGroup().location]",
                "dependsOn": [
                    "[resourceId('Microsoft.Web/Sites/', variables('webSiteName'))]"
                ],
                "properties": {
                    "cloningInfo":{
                        "sourceWebAppId": "[reference(concat('Microsoft.Web/Sites/', variables('webSiteName')), '2016-08-01')]"
                    }
                },
                "tags": {}
            }

最佳答案

如果您有一个通过高级应用服务计划托管的 Web 应用。

我们可以使用以下 ARM 模板来克隆 WebApp。 sourceWebAppId是 WebApp 的资源 ID。我们还需要 serverfarm id。

注意:

  • 广告位名称为WebsiteName/xxxx

  • 如何扩大您的定价等级,请参阅此 document .

ARM 模板:

{
  "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
    "webSiteName": {
      "type": "string",
      "metadata": {
        "description": "The site name. To use the default value, do not specify a new value."
      }
    },
    "ServicePlanName": {
      "type": "string",
      "metadata": {
        "description": "The host name. To use the default value, do not specify a new value."
      }
    }
  },
  "variables": {
  },

  "resources": [
    {
      "name": "[concat(parameters('webSiteName'), '/staging')]",
      "type": "Microsoft.Web/sites/slots",
      "apiVersion": "2016-08-01",
      "location": "[resourceGroup().location]",
      "tags": {},
      "properties": {
        "serverFarmId": "[resourceId('Microsoft.Web/serverfarms/', parameters('ServicePlanName'))]",
        "cloningInfo": {
          "sourceWebAppId": "[resourceId('Microsoft.Web/Sites/', parameters('webSiteName'))]"

        }
      },
      "resources": [
      ]
    }
  ],

  "outputs": {}
}

enter image description here

关于azure - 如何使用 cloningInfo 创建 azure 插槽?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47824538/

相关文章:

azure - 当我有应用程序网关时,为什么要使用 azure APIM

azure - 将 docker secret 传递给 azure web 应用程序时出错 'No such file or directory: '/run/secrets/'

azure - 如何在Azure Web App盒子上执行appcmd?

azure - 使用 ARM 在 Azure Web App 上配置 SSL。参数 {0} 的值无效。扩展代码 51008,

azure - Kafka 连接器可以与事件中心代理一起使用吗?

c# - Azure表存储: adding item if it does not exist

ios - Swift Azure Mobile 快速入门 - 添加和同步 PNG 图像

powershell - 从 WebJob/WebApp 访问注册表

Azure Bicep/ARM 建议使用的 API 版本(预览版与稳定版)

使用 Bicep 的 Azure SQL 故障转移组