根据不同区域的快照创建托管磁盘(Azure) [英] Creating a managed disk from snapshot in different region (Azure)

查看:123
本文介绍了根据不同区域的快照创建托管磁盘(Azure)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我似乎无法从快照创建托管磁盘.

I seem to have a problem creating a managed disk from a snapshot.

看来我只能在美国西部的一个地区创建磁盘.

It appears that I can only create a disk in one region which is West US.

这是我使用的PowerShell脚本:

Here is the PowerShell script I use:

Get-AzureRmSubscription –SubscriptionName 'MySubscription' | Select-AzureRmSubscription

$resourceGroupName = 'MyResourceGroup';
$diskName = 'MyNewDisk';
$location = 'West US';

$snapshotName = 'MySnapshot';
$snapshot = Get-AzureRmSnapshot -ResourceGroupName $resourceGroupName -SnapshotName $snapshotName;

$diskConfig = New-AzureRmDiskConfig -AccountType $storageType -Location $location -SourceResourceId $snapshot.Id -CreateOption Copy;
$disk = New-AzureRmDisk -Disk $diskConfig -ResourceGroupName $resourceGroupName -DiskName $diskName;

如果我将变量$ region值更改为'East US'或任何其他区域,则在PowerShell中会出现en错误(找不到资源).

If I change the variable $region value to 'East US' or any other region, I get en error in PowerShell (resource not found).

快照本身在美国西部,但是我想在美国东部创建磁盘. 我在做什么错了?

The snapshot itself is in West US but I want to create a disk in East US. What am I doing wrong?

推荐答案

快照本身在美国西部,但我想在美国东部创建磁盘 我们.我在做什么错了?

The snapshot itself is in West US but I want to create a disk in East US. What am I doing wrong?

我们无法创建从快照到另一个位置的托管磁盘.

We can't create a managed disk from snapshot to another location.

如果要创建从快照到另一个位置的托管磁盘,我们应该使用PowerShell将托管快照作为VHD导出/复制到不同区域的存储帐户.

If you want to create a managed disk from snapshot to another location, we should export/Copy managed snapshots as VHD to a storage account in different region with PowerShell.

这里是示例脚本:

#Provide the subscription Id of the subscription where snapshot is created
$subscriptionId = "yourSubscriptionId"

#Provide the name of your resource group where snapshot is created
$resourceGroupName ="yourResourceGroupName"

#Provide the snapshot name 
$snapshotName = "yourSnapshotName"

#Provide Shared Access Signature (SAS) expiry duration in seconds e.g. 3600.
#Know more about SAS here: https://docs.microsoft.com/en-us/azure/storage/storage-dotnet-shared-access-signature-part-1
$sasExpiryDuration = "3600"

#Provide storage account name where you want to copy the snapshot. 
$storageAccountName = "yourstorageaccountName"

#Name of the storage container where the downloaded snapshot will be stored
$storageContainerName = "yourstoragecontainername"

#Provide the key of the storage account where you want to copy snapshot. 
$storageAccountKey = 'yourStorageAccountKey'

#Provide the name of the VHD file to which snapshot will be copied.
$destinationVHDFileName = "yourvhdfilename"


# Set the context to the subscription Id where Snapshot is created
Select-AzureRmSubscription -SubscriptionId $SubscriptionId

#Generate the SAS for the snapshot 
$sas = Grant-AzureRmSnapshotAccess -ResourceGroupName $ResourceGroupName -SnapshotName $SnapshotName  -DurationInSecond $sasExpiryDuration -Access Read 

#Create the context for the storage account which will be used to copy snapshot to the storage account 
$destinationContext = New-AzureStorageContext –StorageAccountName $storageAccountName -StorageAccountKey $storageAccountKey  

#Copy the snapshot to the storage account 
Start-AzureStorageBlobCopy -AbsoluteUri $sas.AccessSAS -DestContainer $storageContainerName -DestContext $destinationContext -DestBlob $destinationVHDFileName

#Monitor status
Get-AzureStorageBlobCopyState -Context $destinationContext -Blob $destinationVHDFileName -Container $storageContainerName

有关它的更多信息,请参考此

More information about it, please refer to this link.

这篇关于根据不同区域的快照创建托管磁盘(Azure)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆