简体   繁体   中英

Azure Resource Manager ResourceGroups deployment

Is it supported to have a single ARM file that is deployed on a resource-group level and still deploy another resource group, and resource to it? And if yes, how does one have to address the resourceId for the dependsOn parameter?

I'm deploying like the following (I need to deploy on a resource group level - don't ask).

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

And have, in this ARM file, a resource group deployment

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

and specify a further deployment (Microsoft.Resources/deployments) to this resource group.

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

This works fine if the resource group is already deployed, that is. But in reality, the resource group won't be ready to deploy to. So I need to set a dependsOn. But when I try to use the dependsOn parameters I can't address the resource-group deployment. "dependsOn": []

Here is how I define the dependsOn when deploying resources groups and then resources within the same template file.

{
      "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"
        }
      }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM