“NotFound” ARM Template Error

I recently ran into an issue while deploying a VM with an ARM template. The server deployed correctly, but the JoinDomain extension failed with the error below:

 

 

New-AzureRmResourceGroupDeployment : 1:37:12 PM - Resource Microsoft.Compute/virtualMachines/extensions 'SERVER/joindomain' failed with message '{
    "error": {
    "code": "NotFound",
    "target": "vmName",
    "message": "The entity was not found."
  }
}'
At line:1 char:1

After some time troubleshooting I found the issue. Normally I deploy servers and other services in the same location as the resource group. In this instance the Resource Group was in the East US region and the server was deployed to the Central US region. In the section for the JoinDomain Virtual Machine Extension below, you can see that Location is populated by the Resource Group location variable.

 "apiVersion": "2017-12-01",
 "type": "Microsoft.Compute/virtualMachines/extensions",
 "name": "[concat(concat(parameters('virtualMachineNamePrefix'), copyIndex(1)),'/joindomain')]",
 "location": "[resourceGroup().location]",

Essentially, the code was pointing at the Resource Group location of East US when it needed to be Central US. I changed “[resourceGroup().location]” to “centralus” and everything ran fine.

Interestingly enough, my template has a “Location” parameter for the server location. The solution to this is to replace “[resourceGroup().location]” with “[parameters(‘location’)]” so the template always uses the correct location.

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.