Failed to trigger deployment for Azure Local instance

Problem

I was recently test deploying Azure Local instances in my lab and hit an error were the deployment failed to trigger. This was after the validation stage where I wanted to kick off the cloud deployment, but I couldn’t proceed due to this error.

Error Message

Cause

This was caused by me and the way I was testing, and using the same instance naming scheme each time. I manually closed and deleted a previous deployment attempt, part way through, as I wanted to make a change to some configuration. I did this by simply closing out of the ‘Deployments’ view in the the ‘Azure Local’ resource and deleted all the related resources from the resource group in the portal. The Azure Local [cluster] resource took the longest to delete, but after a few minutes it was gone and so I thought I would be able to continue and re-use the same resource name. As it turns out, however, manually killing the deployment and deleting the Azure resources in this way doesn’t stop and remove the running deployment job.

As you can see from the above error message, I was using an instance name of ‘azloc-c3‘. When I rebuilt the nodes, and went through the deployment wizard, I used the same instance name and since a deployment job was still running with the same name, the deployment could not be triggered.

Resolution

To resolve this issue so you can trigger a deployment using this same instance name, you can use Azure CLI or Azure PowerShell commands to cancel and delete the existing deployment job. I chose to use the Azure CLI, as per below:

#Login the Azure

#Set Subscription ID and Resource Group parameter
$SubscriptionId = "<<subscriptionid>>"
$RG = "<<resourcegroupname>>"

#Log into Azure
az login --use-device-code

#Set subscription context
az account set --subscription $SubscriptionId

#View deployment groups
az deployment group list --resource-group $RG -o table

#Cancel deployment group
az deployment group cancel --name azloc-c3 --resource-group $RG

#Delete deployment group
az deployment group delete --name azloc-c3 --resource-group $RG

Example:

After the job group was deleted, I was then able to trigger the deployment:

Conclusion

I hope the above is helpful should you find yourself hitting this error. In my case I know why the issue occurred, but there maybe occasions where you experience issues with deployments and need to re-use the same naming scheme and can’t trigger a deployment as one with the same name is stuck running. If so then perhaps the above will help?

Leave a Reply

Your email address will not be published. Required fields are marked *