Azure:复制虚拟机:无存储配置文件

Azure: Copy a VM: No storageProfile

我正在使用信息 here 在 Azure 上复制 VM。我无法通过第一步,因为我的存储配置文件返回时为空。我从下面的命令中什么也得不到。如果我删除查询,它会显示我的 VM 信息。仅查询 storageProfile 也不会打印任何内容。

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

我的 VM 有一个基于 blob 的 VHD。想知道我是不是找错人了。请原谅我的无知,因为我对 Azure 还很陌生,而且那里的信息量有点大。

My VM has a blob based VHD.

根据您的描述,您的 VM 使用 Azure blob、非托管磁盘创建。 非托管磁盘VM信息是这样的,有no unmanaged 属性:

"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"
      }
    }

所以我们可以使用这个脚本来显示VHD uri信息:

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

另外,如果你想将这个VHD复制到另一个Azure存储账户,我们可以使用这个脚本:

# 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

有关将 blob 复制到另一个容器的更多信息,请参阅此 article