【问题标题】:Can we move an image in Azure to a different location (region) using UI/Command or through any other way?我们可以使用 UI/Command 或任何其他方式将 Azure 中的图像移动到不同的位置(区域)吗?
【发布时间】:2020-08-13 09:14:57
【问题描述】:

我有一张图片,比如说在“英国南部”。我想把它移到说“美国东部”,我该怎么做?是否有 AZ CLI 命令、UI 上的某些选项或任何其他方式?我已经使用了“az image copy”,但出现错误。

【问题讨论】:

  • 使用az image copy会出现什么错误?请显示错误和您的完整命令,包括参数。
  • 我没有源盘,所以不能用。

标签: image azure azure-powershell azure-cli az


【解决方案1】:

如果是这样,您可以按照以下步骤操作。

1.在位于目标资源组East US 的门户中创建一个存储帐户。

2.在门户中导航到源镜像->Create VM,创建VM后,导航到VM->Disks->复制OS磁盘名称。

3.确保您已安装Az powershell 模块,然后使用以下命令将磁盘作为.vhd 文件复制到存储中。

#Source Disk
$rgName ="xxxxx"
$location ="UK South"
$diskName ="<diskname copied in step 2>"

#Dest Blob
$destrgName ="xxxx"
$destlocation ="East US"
$deststorageAccountName ="<storage account name in step 1>"
$destdiskName ="destDisk.vhd" 
    
#Grant the read access for the disk
$sas =Grant-AzDiskAccess -ResourceGroupName $rgName -DiskName $diskName -DurationInSecond 3600 -Access Read

$saKey =Get-AzStorageAccountKey -ResourceGroupName $destrgName -Name $deststorageAccountName
$storageContext =New-AzStorageContext –StorageAccountName $deststorageAccountName -StorageAccountKey $saKey[0].Value

#Create a new container vhds2 in the storage account
New-AzStorageContainer -Context $storageContext -Name vhds2

#Start copy, my disk size is 30GB, just takes several minutes
Start-AzStorageBlobCopy -AbsoluteUri $sas.AccessSAS -DestContainer vhds2 -DestContext $storageContext -DestBlob $destdiskName

稍等片刻,查看复制状态,如果Status为Success,则表示复制完成。

Get-AzureStorageBlobCopyState -Context $storageContext -Blob $destdiskName -Container vhds2 

4.完成上述步骤后,您已经在blob中拥有.vhd文件,然后您可以直接在门户中从blob URL中创建图像。

【讨论】:

  • 谢谢乔伊。我无法尝试这样做,因为创建存储需要获得客户的批准。我们暂时使用共享图片库来解决问题。
  • @Chaitanya 是的,共享图片库也是一种解决方法。
猜你喜欢
  • 2018-08-13
  • 2019-01-08
  • 1970-01-01
  • 1970-01-01
  • 2019-03-15
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多