Creating VM from automation script results in 'Provisioning failed...TargetDiskBlobAlreadyExists'

New Contributor

I downloaded the automation script for a VM, deleted the VM and connected the OS disk as a data disk on a secondary VM for troubleshooting. After completing troubleshooting steps and detaching the OS disk, I ran the deploy.ps1 script from the automation script archive, to re-create the original VM. The script erred out with, "New-AzureRmResourceGroupDeployment : 8:25:12 AM - Error: Code=InvalidDeploymentParameterValue; Message=The value of deployment parameter 'virtualMachines_VMNAME_name' is null. Please specify the value or use the parameter reference."

After renaming parameters.json and re-running deploy.ps1, the process continued further than before, but eventually returned, "New-AzureRmResourceGroupDeployment : 8:37:48 AM - Resource Microsoft.Compute/virtualMachines 'VMNAME'
failed with message '{
"status": "Failed",
"error": {
"code": "ResourceDeploymentFailure",
"message": "The resource operation completed with terminal provisioning state 'Failed'.",
"details": [
{
"code": "TargetDiskBlobAlreadyExists",
"message": "Blob https://mystorageaccount.blob.core.windows.net/vhds/OSDISK.vhd
already exists. Please provide a different blob URI as target for disk 'OSDISK'."
}
]
}
}'"

 

The VM was re-created, but status is failed. Error information language in the Azure Portal is similar/identical to the error returned by the deploy.ps1 script.

 

From the system used to run deploy.ps1:

 

Name            Value
----                -----
PSVersion      5.1.14393.206

 

Name                             Version
----                                 -------
AzureRM                        3.7.0

AzureRM.Resources       3.7.0

 

Any ideas/suggestions?

 

Thank you,

 

-- 

Ron

3 Replies

Hi Ronald,

 

This is due to the in storage account VM creating has the same name as the VMs VHD. I assume you have create a VM before and delete it but didnot delete the VHD. Go to the VM storage account click blob then go to the VHDS container then you will see the "OSDISK.vhd" Move it to another container if you want it or delete it. Re run the PS script.

 

Thanks

Hi Kasun, I'm not sure what you mean by this:

 


@Kasun Rajapakse wrote:

 

This is due to the in storage account VM creating has the same name as the VMs VHD.

I deleted a test VM, without deleting the associated OS VHD. I connected the orphaned VHD as a data disk for a second VM, for troubleshooting purposes. After completing troubleshooting, I removed the data disk VHD from the second VM. I tried running deploy.ps1 from the automation script archive I had downloaded for the deleted VM. That's where I'm stuck. The VM is re-created, but in the failed state, TargetDiskBlobAlreadyExists.

I also tried deleting the failed VM--without deleting the VHD, creating a new storage account and container, and copying the orphaned VHD to the new storage account / container, as described in the post Moving VHDs from one Storage Account to Another, on www.azurefieldnotes.com. Updating template.json for the new storage account / container and copied VHD, and running deploy.ps1 produces the same result. The VM is re-created in the failed state, TargetDiskBlobAlreadyExists.

 

Thank you,

 

-- 

Ron

the script you are running expects to create a new vm from a blank disk.

have a look here for a powershell script that shows examples of how you can achieve your goal.