【发布时间】:2017-01-17 11:36:15
【问题描述】:
在 powershell 中,我通过调用上下文来验证它是否存在。
New-AzureStorageContext -StorageAccountName "testdisks401" -StorageAccountKey "...."
结果
StorageAccountName : testdisks401
BlobEndPoint : https://testdisks401.blob.core.windows.net/
TableEndPoint : https://testdisks401.table.core.windows.net/
QueueEndPoint : https://testdisks401.queue.core.windows.net/
FileEndPoint : https://testdisks401.file.core.windows.net/
Context : Microsoft.WindowsAzure.Commands.Common.Storage.AzureStorageContext
Name :
StorageAccount : BlobEndpoint=https://testdisks401.blob.core.windows.net/;QueueEndpoint=https://testdisks401.queue.core.windows.net/;TableEndpoint=https://testdi
sks401.table.core.windows.net/;FileEndpoint=https://testdisks401.file.core.windows.net/;AccountName=testdisks401;AccountKey=[key hidden]
EndPointSuffix : core.windows.net/
当我尝试在此处设置时:
Set-AzureSubscription -SubscriptionName 'XXXX' -CurrentStorageAccount "testdisks401"
我明白了
Set-AzureSubscription : ResourceNotFound: The storage account 'testdisks401' was not found.
At line:1 char:1
+ Set-AzureSubscription -SubscriptionName 'XXX
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : CloseError: (:) [Set-AzureSubscription], CloudException
+ FullyQualifiedErrorId : Microsoft.WindowsAzure.Commands.Profile.SetAzureSubscriptionCommand
卡了好久。我基本上想编写 shellscript 来从现有的操作系统光盘创建一个虚拟机。我设法使用 powershell 创建了现有光盘的副本(使用第一个命令的上下文使其工作)。但现在我正在尝试使用以下方法创建 VM 配置:
$vmI1 = New-AzureVMConfig -Name "TestRecover" -InstanceSize Small -AvailabilitySetName 'RDGW' -DiskName 'MY-OS-Disk-Name'
我收到此错误:
New-AzureVMConfig : Must specify MediaLocation or set a current storage account using Set-AzureSubscription.
At line:1 char:9
+ $vmI1 = New-AzureVMConfig -Name "TestRecover" -InstanceSize Small -Av ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [New-AzureVMConfig], ArgumentException
+ FullyQualifiedErrorId : System.ArgumentException,Microsoft.WindowsAzure.Commands.ServiceManagement.IaaS.NewAzureVMConfigCommand
已经为此提供了solution,这将我带到了这里(卡在缺少存储帐户错误)。
【问题讨论】:
-
请检查您使用的存储帐户是
Classic存储帐户还是Azure Resource Manager存储帐户。我的猜测是 cmdletSet-AzureSubscription使用其中一种类型,而您的存储帐户是另一种类型。 -
@GauravMantri 存储帐户是 Azure 资源管理器类型。我不相信 Set-AzureSubscription 区分类型。据我所知,它的文档没有提到这种情况 (msdn.microsoft.com/library/dn790376.aspx)
-
或者我认为不是这样。我创建了一个经典的存储帐户来测试,情况就是这样。这很奇怪。 @GauravMantri 请添加它作为我接受的答案
标签: powershell azure azure-storage azure-powershell