【问题标题】:Azure Resource Manager ResourceGroups deploymentAzure 资源管理器资源组部署
【发布时间】:2020-12-09 14:02:51
【问题描述】:

是否支持在资源组级别部署单个 ARM 文件,但仍部署另一个资源组和资源? 如果是的话,如何解决dependsOn参数的resourceId?

我正在部署如下(我需要在资源组级别部署 - 不要问)。

New-AzResourceGroupDeployment -Templatefile deploy.json -Location 'xx' -ResourceGroupName 'firstResourceGroup'

在这个 ARM 文件中,有一个资源组部署

{
    "type": "Microsoft.Resources/resourceGroups",
    "apiVersion": "2020-06-01",
    "location": "[parameters('location')]",
    "name": "[parameters('SecondResourceGroup')]",
    "properties": {}
}

并指定对该资源组的进一步部署 (Microsoft.Resources/deployments)。

{
      "type": "Microsoft.Resources/deployments",
      "name":"deployment-to-secondResourceGroup",
      "apiVersion": "2020-06-01",
      "resourceGroup": "[parameters('secondResourceGroup')]",
      "properties": {
        "mode": "Incremental",
        "templateLink": {
          "uri": "https://xyz"
        }
      }
}

如果资源组已经部署,这可以正常工作,也就是说。但实际上,资源组还没有准备好部署到。所以我需要设置一个dependsOn。 但是当我尝试使用 dependsOn 参数时,我无法解决资源组部署问题。 "dependsOn": []

【问题讨论】:

    标签: azure azure-resource-manager arm-template azure-resource-group


    【解决方案1】:

    这是我在部署资源组时定义dependsOn,然后在同一模板文件中定义资源的方式。

    {
          "type": "Microsoft.Resources/deployments",
          "name":"deployment-to-secondResourceGroup",
          "apiVersion": "2020-06-01",
          "resourceGroup": "[parameters('secondResourceGroup')]",
          "dependsOn": [
                "[resourceId('Microsoft.Resources/resourceGroups/', variables('secondResourceGroup'))]"
          ],
          "properties": {
            "mode": "Incremental",
            "templateLink": {
              "uri": "https://xyz"
            }
          }
    }
    

    【讨论】:

      猜你喜欢
      • 2018-01-29
      • 2015-11-20
      • 2014-05-21
      • 2020-06-25
      • 1970-01-01
      • 2016-04-10
      • 1970-01-01
      • 2017-05-31
      相关资源
      最近更新 更多