Mr_M_Cox
Mr_M_Cox

Reputation: 23

"DiskImageNotReady" error when creating VM in Azure using ARM template and JSON

I am trying to deploy 3 azure Ubuntu vm's using an ARM template. They are being deployed as part of a larger infrastructure deployment of resource groups, storage accounts, SQL servers etc. Everything is working great apart from the VM creation. During testing with a single VM the script worked but with 3 I get the following error -

    New-AzureRmResourceGroupDeployment : 16:52:57 - Resource Microsoft.Compute/virtualMachines 'xxxV3Monitor1' failed with message '{
  "status": "Failed",
  "error": {
    "code": "ResourceDeploymentFailure",
    "message": "The resource operation completed with terminal provisioning state 'Failed'.",
    "details": [
      {
        "code": "DiskImageNotReady",
        "message": "Disk image https://xxxxxx.blob.core.windows.net/rootvhd/v1ubuntudocker.vhd is in Pending state. Please retry when image is ready."
      }

It seems the custom root VHD image we a re using is failing due to be in a "Pending" state, i assume this is some lock on the file as it is being used to create one of the other VMs?

Any help much appreciated. Thanks.

Upvotes: 2

Views: 231

Answers (1)

Richard
Richard

Reputation: 36

I'm assuming that you are moving the VM image prior to creating the VM's from it. If so try this code after the move, and before you start the deployment script: ($blob1 is the variable that you call the Start-AzureStorageBlobCopy command)

### Retrieve the current status of the copy operation ###
$status = $blob1 | Get-AzureStorageBlobCopyState 

### Print out status ### 
$status 

### Loop until complete ###                                    
While($status.Status -eq "Pending"){
  $status = $blob1 | Get-AzureStorageBlobCopyState 
  Start-Sleep -s 60
  ### Print out status ###
  $status
}

This will cycle each minute updating with the status.

Upvotes: 2

Related Questions