Anshul Kai
Anshul Kai

Reputation: 4088

Azure: Copy a VM: No storageProfile

I'm using the information here to copy a VM on Azure. I'm unable to get past the first step as my storage profile is coming back empty. I get nothing from the command below. If I remove the query, it displays my VM info. Querying for just storageProfile also doesn't print anything.

az vm show -n myVM -g myRG --query "storageProfile.osDisk.unmanagedDisk.id"

My VM has a blob based VHD. Wondering if I'm barking up the wrong tree. Pardon my ignorance as I'm quite new to Azure and the amount of information out there is a bit overwhelming.

Upvotes: 0

Views: 472

Answers (1)

Jason Ye
Jason Ye

Reputation: 13954

My VM has a blob based VHD.

According to your description, your VM create with Azure blob, unmanaged disk. Unmanaged disk VM information like this, there is no unmanaged property:

"osDisk": {
      "caching": "ReadWrite",
      "createOption": "fromImage",
      "diskSizeGb": null,
      "encryptionSettings": null,
      "image": null,
      "managedDisk": null,
      "name": "jasonvm",
      "osType": "Linux",
      "vhd": {
        "uri": "https://vmdisks909.blob.core.windows.net/vhds/jasonvm20170727093048.vhd"
      }
    }

So we can use this script to show the VHD uri information:

az vm show -g vm -n jasonvm --query "storageProfile.osDisk.vhd.uri" -o tsv

Also, if you want to copy this VHD to another Azure storage account, we can use this script:

# Copy blob from source account to destination account (destcontainer must exist)
az storage blob copy start \
    --account-name destaccountname \
    --account-key destaccountkey \
    --destination-blob destfile.vhd \
    --destination-container destcontainer \
    --source-uri https://sourceaccountname.blob.core.windows.net/sourcecontainer/sourcefile.vhd

More information about copy blob to another container, please refer to this article.

Upvotes: 1

Related Questions