如何将azure VM映像移动到其他位置
我在美国东部有一个带有托管磁盘的azure VM映像,我想将其移动/复制到西欧 有没有简单的方法 我看到有一个名为az image copy的azure cli扩展,但它不适用于我,因为它输出一个错误,表示找不到操作系统磁盘(即使资源ID正确,我可以在azure门户中看到它) 错误:未找到资源服务器Linux_OsDisk_1_C208679747734937B1OA1525AA84A7D7如何将azure VM映像移动到其他位置,azure,powershell,azure-storage,azure-virtual-machine,azure-cli,Azure,Powershell,Azure Storage,Azure Virtual Machine,Azure Cli,我在美国东部有一个带有托管磁盘的azure VM映像,我想将其移动/复制到西欧 有没有简单的方法 我看到有一个名为az image copy的azure cli扩展,但它不适用于我,因为它输出一个错误,表示找不到操作系统磁盘(即使资源ID正确,我可以在azure门户中看到它) 错误:未找到资源服务器Linux_OsDisk_1_C208679747734937B1OA1525AA84A7D7 那么还有其他方法吗?如果资源在同一订阅下,那么您可以将资源从资源组01(美国东部)移动到资源组02(西欧
那么还有其他方法吗?如果资源在同一订阅下,那么您可以将资源从资源组01(美国东部)移动到资源组02(西欧)。 您可以查看以下文档以获取帮助:
最后一个链接是关于MigAz工具的,它允许迁移Azure上的资源。您可以使用Azure powershell复制托管映像,创建快照并将其复制到另一个区域,然后创建映像。这是一本书 创建快照:
<# -- Create a snapshot of the OS (and optionally data disks) from the generalized VM -- #>
$vm = Get-AzureRmVM -ResourceGroupName $resourceGroupName -Name $vmName
$disk = Get-AzureRmDisk -ResourceGroupName $resourceGroupName -DiskName $vm.StorageProfile.OsDisk.Name
$snapshot = New-AzureRmSnapshotConfig -SourceUri $disk.Id -CreateOption Copy -Location $region
$snapshotName = $imageName + "-" + $region + "-snap"
New-AzureRmSnapshot -ResourceGroupName $resourceGroupName -Snapshot $snapshot -SnapshotName $snapshotName
# Create the name of the snapshot, using the current region in the name.
$snapshotName = $imageName + "-" + $region + "-snap"
# Get the source snapshot
$snap = Get-AzureRmSnapshot -ResourceGroupName $resourceGroupName -SnapshotName $snapshotName
# Create a Shared Access Signature (SAS) for the source snapshot
$snapSasUrl = Grant-AzureRmSnapshotAccess -ResourceGroupName $resourceGroupName -SnapshotName $snapshotName -DurationInSecond 3600 -Access Read
# Set up the target storage account in the other region
$targetStorageContext = (Get-AzureRmStorageAccount -ResourceGroupName $resourceGroupName -Name $storageAccountName).Context
New-AzureStorageContainer -Name $imageContainerName -Context $targetStorageContext -Permission Container
# Use the SAS URL to copy the blob to the target storage account (and thus region)
Start-AzureStorageBlobCopy -AbsoluteUri $snapSasUrl.AccessSAS -DestContainer $imageContainerName -DestContext $targetStorageContext -DestBlob $imageBlobName
Get-AzureStorageBlobCopyState -Container $imageContainerName -Blob $imageBlobName -Context $targetStorageContext -WaitForComplete
# Get the full URI to the blob
$osDiskVhdUri = ($targetStorageContext.BlobEndPoint + $imageContainerName + "/" + $imageBlobName)
# Build up the snapshot configuration, using the target storage account's resource ID
$snapshotConfig = New-AzureRmSnapshotConfig -AccountType StandardLRS `
-OsType Windows `
-Location $targetRegionName `
-CreateOption Import `
-SourceUri $osDiskVhdUri `
-StorageAccountId "/subscriptions/${sourceSubscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.Storage/storageAccounts/${storageAccountName}"
# Create the new snapshot in the target region
$snapshotName = $imageName + "-" + $targetRegionName + "-snap"
$snap2 = New-AzureRmSnapshot -ResourceGroupName $resourceGroupName -SnapshotName $snapshotName -Snapshot $snapshotConfig
创建图像:
<# -- In the second subscription, create a new Image from the copied snapshot --#>
Select-AzureRmSubscription -SubscriptionId $targetSubscriptionId
$snap = Get-AzureRmSnapshot -ResourceGroupName $resourceGroupName -SnapshotName $snapshotName
$imageConfig = New-AzureRmImageConfig -Location $destinationRegion
Set-AzureRmImageOsDisk -Image $imageConfig `
-OsType Windows `
-OsState Generalized `
-SnapshotId $snap.Id
New-AzureRmImage -ResourceGroupName $resourceGroupName `
-ImageName $imageName `
-Image $imageConfig
选择AzureRmSubscription-SubscriptionId$targetSubscriptionId
$snap=Get-AzureRmSnapshot-ResourceGroupName$ResourceGroupName-SnapshotName$SnapshotName
$imageConfig=新AzureRmImageConfig-位置$destinationRegion
设置AzureRmImageOsDisk-Image$imageConfig`
-OsType窗口`
-全身骨状态`
-SnapshotId$snap.Id
新AzureRmImage-ResourceGroupName$ResourceGroupName`
-ImageName$ImageName`
-图像$imageConfig
有关更多详细信息,请参阅此