AnotherOperationInProgress when deploying multiple Azure virtual networks and subnets with ARM at once

Viewed 2463

I want to deploy a virtual network setup with these vnets / subnets

  • frontend
    • firewall
    • appgw
    • api
    • jump
  • cluster
    • ingress
    • agents

each of the subnets is included in the "resources": [...] array of the corresponding virtual network and each of the subnets has the vnet as dependency like this:

            {
                "apiVersion": "2020-04-01",
                "type": "subnets",
                "location": "[parameters('location')]",
                "name": "ingress",
                "dependsOn": [
                    "[parameters('vnetNameCluster')]"
                ],
                "properties": {
                    "addressPrefix": "[parameters('subnetPrefixIngress')]"
                }
            }

However when deploying the virtual networks, very often a conflict is raised:

{
    "error": {
        "code": "AnotherOperationInProgress",
        "message": "Another operation on this or dependent resource is in progress. To retrieve status of the operation use uri: https://management.azure.com/subscriptions/xxxxxx/providers/Microsoft.Network/locations/westus/operations/yyyyyyyyyyyyyyy?api-version=2020-04-01.",
        "details": []
    }
}

What dependency can I add to avoid this conflict?

1 Answers

After some trial and error I avoided the conflict by adding the previous subnet within a virtual network as a dependency - hence the first subnet still only having a dependency on the virtual network:

            {
                "apiVersion": "2020-04-01",
                "type": "subnets",
                "location": "[parameters('location')]",
                "name": "agents",
                "dependsOn": [
                    "[parameters('vnetNameCluster')]",
                    "[resourceId('Microsoft.Network/virtualNetworks/subnets',parameters('vnetNameCluster'),'ingress')]"
                ],
Related