-3

I want to create 100 containers in two storage account. It is tedious if we select manual process. One is classic and other is RM storage account. (Seriously sometimes I think why I am doing this on Azure)

How to do this. 1) with powershell For PS I am getting error on add-azureaccount command popup asenter image description here

Can any one help.

And 2) With Azure Cloud Shell How can I do this with Azure Cloud Shell

Kunal
  • 77
  • 12
  • 1
    Sadly there's more "rant" than content in your question. That said: Seems like you're having tool installation issues (powershell, cli), vs actual container creation issues. And there's really nothing to go on, in your question, to help with that. FYI no difference, when creating containers, whether using classic vs RM storage accounts. Also, all the language-specific SDKs for storage support creating a container, so you could do that in a few lines of code, looping through container names). Or create within your app, as needed (on the container class, there's a 'create if not exists' method) – David Makogon Jun 24 '18 at 12:33
  • @DavidMakogonthanks. I have edited question again. Hope this help to understand question. – Kunal Jun 24 '18 at 12:42
  • It might help if you posted the script you're attempting to use – Mick Jun 25 '18 at 04:30

2 Answers2

0

@Kunal

If you know your storage account key, you can do it without "add-azureaccount".

$ctx = New-AzureStorageContext -StorageAccountName $accountName -StorageAccountKey $accountKey
New-AzureStorageContainer $containerName -Context $ctx

For the errorof "add-azureaccount", you might don't install Azure Powershell correctly. Can you reinstall latest Azure PowerShell and try again: https://github.com/Azure/azure-powershell/releases/tag/v6.3.0-June2018

0

I did This creation of 100 Containers from the azure cli Script.

Its output will be in other commandlist and run this commandlist

<code>foreach($line in [System.IO.File]::ReadLines("D:BlobNames.txt"))
{
      $arr=$line
foreach ($i in $arr )
{
$k=echo "az storage container create -n $i --account-name <Storageaccount>--account-key <accountKey> --output table" 
Out-File -FilePath D:\commandlist -InputObject $k -Encoding ASCII -Append -NoClobber
}
}
</code>  

Hope this helps

Kunal
  • 77
  • 12