1,first we need to create a source storage account for migration.
rgName=”roger02”
location =”East Asia”
storageAccountName=”roger1026”New−AzureRmResourceGroup−Name
rgName -Location
locationNew−AzureRmStorageAccount−Name
storageAccountName -Location
location−SkuNamePremiumLRS−ResourceGroupName
rgName
2,create a new storage account in the region we want to move to.
rgName=”roger01”
location =”West Europe”
storageAccountName=”roger109”New−AzureRmResourceGroup−Name
rgName -Location
locationNew−AzureRmStorageAccount−Name
storageAccountName -Location
location−SkuNamePremiumLRS−ResourceGroupName
rgName
3,create a managed disk under the resource group “roger02” within portal
4,execute the rest commands to copy the blob and get a status.
Source storage account
rgName=”roger02”
location =”East Asia”
storageAccountName=”roger1026”
diskName =”rogerdisk”
Target storage account
destrgName=”roger01”
destlocation =”West Europe”
deststorageAccountName=”roger109”
destdiskName =”destrogerdisk”
Assign access to the source disk
sas=Grant−AzureRmDiskAccess−ResourceGroupName rgName -DiskName $diskName -DurationInSecond 3600 -Access Read
saKey=Get−AzureRmStorageAccountKey−ResourceGroupName
destrgName -Name
deststorageAccountName
storageContext =New-AzureStorageContext –StorageAccountName
deststorageAccountName−StorageAccountKey
saKey[0].Value
New-AzureStorageContainer -Context $storageContext -Name vhds10261
Start-AzureStorageBlobCopy -AbsoluteUri sas.AccessSAS−DestContainervhds10261−DestContext storageContext -DestBlob $destdiskName
Get-AzureStorageBlobCopyState -Context storageContext−Blob destdiskName -Container vhds10261
Now we only need to wait for the replication process to complete. The above is the steps to migrate the managed disk through the powershell command.
Note:
If the managed disk is attached to the VM, stop the VM and copy it to the storage account.