Save-AzureRmVMImage 强制创建无效的 blob 容器名称
Save-AzureRmVMImage mandatorily creates invalid blob container name
我正在捕获 ARM VM 映像以在从映像创建操作中使用它。
然而,Save-AzureRmVMImage 命令强制创建(或者只是默认?)这样一个容器和 blob 名称似乎对其他命令无效。
容器名称中的“/Microsoft.Compute/和blob名称中的"osDisk.xxxx"部分是Save-AzureRmVMImage命令隐式放置的。
澄清一下:
我使用了 Save-AzureRmVMImage -DestinationContainerName 'vhds' -VHDNamePrefix 'template'...
但该命令创建了容器 system/Microsoft.Compute/Images/vhds + "invents" 包含 [=30= 的 blobname ]osdisk。 (点) 部分。这两个都不是我出的...而且无法阻止-
首先这个名字好像不能用在New-AzureRmVM操作中。 (请参阅我在 Creating new ARM VM from captured image: Blob name in URL must end with '.vhd' extension error
的详细说明
作为上述错误的解决方法,我发现我会将图像复制到另一个不包含 . (点)。然而,事实证明,我经过全面测试且可以正常工作的复制脚本也会针对该 blob 名称抛出错误...
复制源代码(同样,它对其他 blob 具有完整的功能)
(注意:这个问题是关于 Save-AzureRmVMImage 的问题,或者在后续操作中如何解决它奇怪和无效的名称。所以问题不是关于这个复制脚本。这里的脚本只是演示诊断经验.
Login-AzureRmAccount
Select-AzureRmSubscription -SubscriptionName "Visual Studio Premium with MSDN"
$sourceRgName = "rg-wp"
$sourceName = "mystorage"
$sourceContainerName = "system/Microsoft.Compute/Images/vhds" #the dots seems to be invalid
$sourceBlobName = "template-osDisk.be7b0cf4-a28b-47f9-89c7-43887f1570ab.vhd" #the dots seems to be invalid
$destinationRgName = "rg-wp"
$destinationName = "mystorage"
$destinationContainerName = "vhds"
$destinationBlobName = "template.vhd"
$sourceKeys = Get-AzureRmStorageAccountKey -Name $sourceName -ResourceGroupName $sourceRgName
$destinationKeys = Get-AzureRmStorageAccountKey -Name $destinationName -ResourceGroupName $destinationRgName
$contextSource = New-AzureStorageContext -StorageAccountName $sourceName -StorageAccountKey $sourceKeys.Key1
$contextDestination = New-AzureStorageContext -StorageAccountName $destinationName -StorageAccountKey $destinationKeys.Key1
Start-AzureStorageBlobCopy -Context $contextSource -SrcContainer $sourceContainerName -SrcBlob $sourceBlobName -DestContext $contextDestination -DestContainer $destinationContainerName -DestBlob $destinationBlobName
# Wait for copy to complete
Get-AzureStorageBlobCopyState -Context $contextDestination -Container $destinationContainerName -Blob $destinationBlobName -WaitForComplete
完整错误信息:
[ERROR] Start-AzureStorageBlobCopy : Container name 'system/Microsoft.Compute/Images/vh
[ERROR] ds' is invalid. Valid names start and end with a lower case letter or a number
[ERROR] and has in between a lower case letter, number or dash with no consecutive dash
[ERROR] es and is 3 through 63 characters long.
[ERROR] At D:\work\.vsonline\Azure\PowerShell\PowerShell\copy blob.ps1:40 char:1
[ERROR] + Start-AzureStorageBlobCopy -Context $contextSource -SrcContainer $sourceConta
[ERROR] ine ...
[ERROR] + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[ERROR] ~~~
[ERROR] + CategoryInfo : NotSpecified: (:) [Start-AzureStorageBlobCopy],
[ERROR] ArgumentException
[ERROR] + FullyQualifiedErrorId : System.ArgumentException,Microsoft.WindowsAzure.
[ERROR] Commands.Storage.Blob.Cmdlet.StartAzureStorageBlobCopy
[ERROR]
您的代码失败的原因是您在脚本中指定的容器名称无效。请参阅此 link 以获得有效的容器名称:https://msdn.microsoft.com/en-us/library/azure/dd135715.aspx.
根据您在上述评论中提供的信息,请尝试以下操作:
$sourceContainerName = "system"
$sourceBlobName = "Microsoft.Compute/Images/vhds/template-osDisk.be7b0cf4-a28b-47f9-89c7-43887f1570ab.vhd
我正在捕获 ARM VM 映像以在从映像创建操作中使用它。 然而,Save-AzureRmVMImage 命令强制创建(或者只是默认?)这样一个容器和 blob 名称似乎对其他命令无效。
容器名称中的“/Microsoft.Compute/和blob名称中的"osDisk.xxxx"部分是Save-AzureRmVMImage命令隐式放置的。
澄清一下:
我使用了 Save-AzureRmVMImage -DestinationContainerName 'vhds' -VHDNamePrefix 'template'...
但该命令创建了容器 system/Microsoft.Compute/Images/vhds + "invents" 包含 [=30= 的 blobname ]osdisk。 (点) 部分。这两个都不是我出的...而且无法阻止-
首先这个名字好像不能用在New-AzureRmVM操作中。 (请参阅我在 Creating new ARM VM from captured image: Blob name in URL must end with '.vhd' extension error
的详细说明作为上述错误的解决方法,我发现我会将图像复制到另一个不包含 . (点)。然而,事实证明,我经过全面测试且可以正常工作的复制脚本也会针对该 blob 名称抛出错误...
复制源代码(同样,它对其他 blob 具有完整的功能)
(注意:这个问题是关于 Save-AzureRmVMImage 的问题,或者在后续操作中如何解决它奇怪和无效的名称。所以问题不是关于这个复制脚本。这里的脚本只是演示诊断经验.
Login-AzureRmAccount
Select-AzureRmSubscription -SubscriptionName "Visual Studio Premium with MSDN"
$sourceRgName = "rg-wp"
$sourceName = "mystorage"
$sourceContainerName = "system/Microsoft.Compute/Images/vhds" #the dots seems to be invalid
$sourceBlobName = "template-osDisk.be7b0cf4-a28b-47f9-89c7-43887f1570ab.vhd" #the dots seems to be invalid
$destinationRgName = "rg-wp"
$destinationName = "mystorage"
$destinationContainerName = "vhds"
$destinationBlobName = "template.vhd"
$sourceKeys = Get-AzureRmStorageAccountKey -Name $sourceName -ResourceGroupName $sourceRgName
$destinationKeys = Get-AzureRmStorageAccountKey -Name $destinationName -ResourceGroupName $destinationRgName
$contextSource = New-AzureStorageContext -StorageAccountName $sourceName -StorageAccountKey $sourceKeys.Key1
$contextDestination = New-AzureStorageContext -StorageAccountName $destinationName -StorageAccountKey $destinationKeys.Key1
Start-AzureStorageBlobCopy -Context $contextSource -SrcContainer $sourceContainerName -SrcBlob $sourceBlobName -DestContext $contextDestination -DestContainer $destinationContainerName -DestBlob $destinationBlobName
# Wait for copy to complete
Get-AzureStorageBlobCopyState -Context $contextDestination -Container $destinationContainerName -Blob $destinationBlobName -WaitForComplete
完整错误信息:
[ERROR] Start-AzureStorageBlobCopy : Container name 'system/Microsoft.Compute/Images/vh
[ERROR] ds' is invalid. Valid names start and end with a lower case letter or a number
[ERROR] and has in between a lower case letter, number or dash with no consecutive dash
[ERROR] es and is 3 through 63 characters long.
[ERROR] At D:\work\.vsonline\Azure\PowerShell\PowerShell\copy blob.ps1:40 char:1
[ERROR] + Start-AzureStorageBlobCopy -Context $contextSource -SrcContainer $sourceConta
[ERROR] ine ...
[ERROR] + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[ERROR] ~~~
[ERROR] + CategoryInfo : NotSpecified: (:) [Start-AzureStorageBlobCopy],
[ERROR] ArgumentException
[ERROR] + FullyQualifiedErrorId : System.ArgumentException,Microsoft.WindowsAzure.
[ERROR] Commands.Storage.Blob.Cmdlet.StartAzureStorageBlobCopy
[ERROR]
您的代码失败的原因是您在脚本中指定的容器名称无效。请参阅此 link 以获得有效的容器名称:https://msdn.microsoft.com/en-us/library/azure/dd135715.aspx.
根据您在上述评论中提供的信息,请尝试以下操作:
$sourceContainerName = "system"
$sourceBlobName = "Microsoft.Compute/Images/vhds/template-osDisk.be7b0cf4-a28b-47f9-89c7-43887f1570ab.vhd