azureazure-vm-scale-setazure-vm-templates

Azure Provisioning state fails for VMSS with custom image & elb


I am getting below error for VMSS with custom image & elb

My template link: https://github.com/linuxgambler/azure/blob/master/vmss_elb.json

Error: "error": { "details": [ { "code": "NotFound", "message": "Resource /subscriptions/6793721a-ea46-406d-ac42-d4488d1a5c0d/resourceGroups/EMC-US-WEST/providers/Microsoft.Network/loadBalancers/AZURE-TESLB not found." } ], "code": "InvalidResourceReference", "message": "Resource /subscriptions/6793721a-ea46-406d-ac42-d4488d1a5c0d/resourceGroups/EMC-US-WEST/providers/Microsoft.Network/loadBalancers/AZURE-TESLB referenced by resource /subscriptions/6793721a-ea46-406d-ac42-d4488d1a5c0d/resourceGroups/EMC-US-West/providers/Microsoft.Compute/virtualMachineScaleSets/azure-tes was not found. Please make sure that the referenced resource exists, and that both resources are in the same region." } }


Solution

  • You need to add dependsOn property to VMSS definition.

    "type": "Microsoft.Compute/virtualMachineScaleSets",
    "name": "[variables('vmssName')]",
    "location": "[resourceGroup().location]",
    "apiVersion": "2016-04-30-preview",
    "dependsOn": [
        "[variables('lbID')]"
    ],
    "sku": {
        "name": "[parameters('vmSku')]",
        "tier": "Standard",
        "capacity": "[parameters('instanceCount')]"
    },
    

    Right now its getting created before the load balancer, that's why its erroring out.