Powershell说存储帐户没有';不存在
在powershell中,我通过调用上下文来验证它是否存在Powershell说存储帐户没有';不存在,powershell,azure,azure-storage,azure-powershell,Powershell,Azure,Azure Storage,Azure Powershell,在powershell中,我通过调用上下文来验证它是否存在 New-AzureStorageContext -StorageAccountName "testdisks401" -StorageAccountKey "...." 结果 StorageAccountName : testdisks401 BlobEndPoint : https://testdisks401.blob.core.windows.net/ TableEndPoint : https://tes
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
已为此提供了一个,这使我来到这里(由于缺少存储帐户错误而卡住)。
Set-AzureSubscription
Cmdlet要求通过-CurrentStorageAccount
参数指定的存储帐户为经典存储帐户
请确保指定的是经典存储帐户的名称,而不是资源管理器存储帐户的名称 如果需要使用ARM创建存储帐户,则可以使用以下命令:
$SubscriptionName = "MySubscription"
$StorageAccountName = "MyStorage"
$ResourceGroup = "MyResourceGroup"
Get-AzureRmSubscription –SubscriptionName $SubscriptionName | Select-AzureRmSubscription
Get-AzureRmStorageAccount -AccountName $StorageAccountName -ResourceGroupName $ResourceGroup
$key = (Get-AzureRmStorageAccountKey -AccountName $StorageAccountName -ResourceGroupName $ResourceGroup).Key1
$Ctx = New-AzureStorageContext –StorageAccountName $StorageAccountName -StorageAccountKey $key
您是如何创建该存储帐户的 如果您将其创建为RM帐户,这将解释您遇到的错误。Antohter选项是testdisks401与您尝试设置的订阅位于同一订阅上 尝试执行以下操作:
Set-AzureSubscription -SubscriptionName 'XXXX'
Get-AzureStorageAccount | ft StorageAccountName
New-AzureStorageContext -StorageAccountName "bla" -StorageAccountKey "askjlksdfjldskgfjflkjdsflksj"
这将为您提供XXXX订阅中的经典存储帐户(非RM)列表
然后对RM帐户执行以下操作:
Login-AzureRmAccount -SubscriptionName 'XXXX'
Get-AzureRMStorageAccount | ft StorageAccountName
如果testdisks401帐户在RM列表中,则需要切换到RM型号,或者需要使用经典型号创建新的存储帐户
编辑:
忘了提到新的azurestoragecontext不会验证任何内容。尝试运行以下命令:
Set-AzureSubscription -SubscriptionName 'XXXX'
Get-AzureStorageAccount | ft StorageAccountName
New-AzureStorageContext -StorageAccountName "bla" -StorageAccountKey "askjlksdfjldskgfjflkjdsflksj"
它还将为您提供一个很好的上下文对象,该对象不会有任何结果:
StorageAccountName : bla
BlobEndPoint : https://bla.blob.core.windows.net/
TableEndPoint : https://bla.table.core.windows.net/
QueueEndPoint : https://bla.queue.core.windows.net/
FileEndPoint : https://bla.file.core.windows.net/
Context : Microsoft.WindowsAzure.Commands.Common.Storage.AzureStorageC
Name :
StorageAccount : BlobEndpoint=https://bla.blob.core.windows.net/;QueueEndpoin
EndPointSuffix : core.windows.net/
请检查您使用的存储帐户是
Classic
存储帐户还是Azure资源管理器
存储帐户。我猜cmdletSet-AzureSubscription
使用了其中一种类型,而您的存储帐户是另一种类型。@GauravMantri存储帐户是Azure资源管理器类型。我不相信Set AzureSubscription会区分不同的类型。据我所知,它的文档中没有提到这样一个案例(),我想是这样的。我创建了一个经典的存储帐户进行测试,就是这样。这很奇怪@GauravMantri请添加它作为我接受的答案是的,我使用这个ctx变量作为命令集的输入-蔚蓝色的订阅但我仍然收到了与找不到存储帐户相同的错误。我真的很想看到这对基于ARM的模型起作用!有一件非常重要的事情可能会遗漏,那就是存储帐户名必须是小写的。每一封信。可能是由于命名约定,根本没有创建存储帐户。你能检查一下情况是否如此吗。此外,如果我能看到一些脚本片段,我可以提供更多帮助。我个人使用了上面的脚本,它确实有效。在获得ctx后,我按照步骤1进行了操作。设置AzureSubscription-订阅ID 4ceb426a-1203-4adb-dc2-b95a372a9e0-上下文$Ctx步骤2。Add-AzureVhd–Destination-LocalFilePath D:\azure.VHD步骤2在shell上出现以下错误:Add-AzureVhd:ResourceNotFound:未找到存储帐户“vmrg001disks388”。CloudException+FullyQualifiedErrorId:Hyak.Common.CloudException,Microsoft.WindowsAzure.Commands.ServiceManagement.StorageServices.AddAzureVHDCommand,我设置了$StorageAccountName=“vmrg001disks388”。。所有的小字母…我知道你的问题。当我在这家公司工作时,我感到很沮丧。Azure资源分为classic和ARM。您使用的是经典命令,您的存储帐户很可能在ARM中。如果您看到我的命令,它将使用selectazurermsubscription而不是setazuresubscription。另外,Add AzureVhd具有和备用Add AzureRmVhd。检查此链接