Powershell显示存储帐户不存在

标签 powershell azure azure-storage azure-powershell

在 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 创建现有光盘的副本(使用第一个命令的上下文使其工作)。但现在我尝试使用以下命令创建虚拟机配置:

 $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已经为此提供了信息,这将我带到了这里(卡在丢失存储帐户错误上)。

最佳答案

Set-AzureSubscription Cmdlet 期望通过 -CurrentStorageAccount 参数指定的存储帐户为经典存储帐户。

请确保您指定的是经典存储帐户的名称,而不是资源管理器存储帐户的名称。

关于Powershell显示存储帐户不存在,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39409523/

相关文章:

Azure Blob - 创建子文件夹或创建多个容器

c# - 不支持流读取器异常 URI 格式

azure - 如何使用 az 存储实体查询在 powershell 中获取排序结果?

azure - 我有 PowerShell 哈希表,其中包含多个值。每 3 个键都有共同的前缀,我需要在 foreach 循环中使用它来运行某些任务

regex - 仅当行不是以某个特定字符开头时,powershell才替换文件中的行

azure - 如何将 HTTPS 添加到 Azure Linux VM 上运行的包含 Docker 的网站?

azure - 重写应用程序网关 azure 上的规则

azure - Azure 中新存储帐户和经典存储帐户之间的区别

python - 如何在 powershell 和 python 脚本中保护 API 身份验证详细信息

node.js - 在 Docker 中支持 .net core 2.1+ 和( Node 或 PowerShell?)的 .NET Core 镜像