通过Powershell在新门户中创建Azure存储容器 [英] Create azure storage container through powershell in new portal

查看:51
本文介绍了通过Powershell在新门户中创建Azure存储容器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想通过powershell在现有存储帐户中创建一个Azure存储容器,我尝试了以下命令:

I want to create an azure storage container in an existing storage account, through powershell.I have tried the following commands:

Set-AzureSubscription -CurrentStorageAccountName "storageaccountv1" -SubscriptionId $SubscriptionId
New-AzureStorageContainer -Name $ContainerName -Permission Off

对于那些知道的人,Azure有两种类型的存储帐户:v1,v2. v1帐户是通过 http://manage.windowsazure.com/可用的帐户,而v2可以在 http://portal.azure.com/中创建.当命令New-AzureStorageContainer使用v1中的存储帐户时,该命令不适用于v2中的存储帐户.它给出了以下错误:

For those who know, Azure has two types of storage accounts: v1, v2. v1 accounts are the ones that are available through the http://manage.windowsazure.com/ and v2 that can be created in http://portal.azure.com/. While the command New-AzureStorageContainer is working with a storage account in v1, the command is not working for a storage account in v2. It is giving the following error:

New-AzureStorageContainer : ResourceNotFound: The storage account 'storageaccountv2' was not found.
At CreateStorageContainer.ps1:31 char:1
+ New-AzureStorageContainer -Name $ContainerName -Permission Off
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : CloseError: (:) [New-AzureStorageContainer], CloudException
    + FullyQualifiedErrorId : CloudException,Microsoft.WindowsAzure.Commands.Storage.Blob.Cmdlet.NewAzureStorageContainerCommand

谁能说出如何通过Powershell在v2中创建一个Azure存储容器吗?

Can anyone tell how to create an azure storage container in v2 through powershell?

推荐答案

如果可以选择使用StorageAccountContext,则可以尝试以下操作:

If using StorageAccountContext is an option, you can try the following:

$ctx = New-AzureStorageContext -StorageAccountName "account-name" -StorageAccountKey "account-key" 
New-AzureStorageContainer -Name "container-name" -Context $ctx

这篇关于通过Powershell在新门户中创建Azure存储容器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆