azure - 从不同区域中的快照创建托管磁盘 (Azure)

标签 azure azure-virtual-machine azure-managed-disk

我从快照创建托管磁盘时似乎遇到问题。

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

这是我使用的 PowerShell 脚本:

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 值更改为“美国东部”或任何其他区域,我会在 PowerShell 中收到错误消息(未找到资源)。

快照本身位于美国西部,但我想在美国东部创建一个磁盘。 我做错了什么?

最佳答案

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

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

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

这里是示例脚本:

#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://learn.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

更多相关信息,请引用这个link .

关于azure - 从不同区域中的快照创建托管磁盘 (Azure),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47759200/

相关文章:

azure - 为什么 Azure IoT 中心将事件中心作为端点?

asp.net - IIS 将请求保留在队列中而不是处理这些请求

azure - 如何知道 AZURE 中虚拟机的所有启动时间?

azure - 创建机器后将负载均衡器附加到多个虚拟机(在这种情况下无法使用可用性集)

azure - 如何使用数据磁盘创建Azure vm,然后通过ansible对其进行格式化

c# - 无法通过 C# 使用 SAS 访问 azure 存储表。适用于 postman 和浏览器

powershell - 下载Azure VHD到本地使用powershell

c# - 保存来自不同区域的日期时间值 ASP.NET

azure - 转换后托管磁盘位于何处?

azure - Azure 中的 Windows VM 卡在 "Hi There"