我从快照创建托管磁盘时似乎遇到问题。
看来我只能在美国西部的一个区域创建磁盘。
这是我使用的 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/