I'm trying to setup a new resource group complete with a storage account and a container. All steps work except the container part. From resources online I've read that this API functionality is not ported to the new ARM cmdlets -- are there workarounds available?
Attempt #1
Login-AzureRmAccount
Set-AzureRmContext -SubscriptionName "Visual Studio Professional"
$resourceGroup = "MyResourceGroup4"
$location = "West Europe"
New-AzureRmResourceGroup -Name $resourceGroup -Location $location
Write-Host "Created resource group"
New-AzureRmStorageAccount -ResourceGroupName $resourceGroup -AccountName "xzcczxda" -Type Standard_RAGRS -Location $location -AccessTier Cool -Kind BlobStorage
New-AzureStorageContainer -Name "images" -Permission Off
Error:
New-AzureStorageContainer : The term 'New-AzureStorageContainer' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
Attempt #2 (based on this)
same as before but adding Import-Module AzureRM.Storage
and using New-AzureRmStorageContainer
instead.
Error:
New-AzureRmStorageContainer : The term 'New-AzureRmStorageContainer' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
Attempt #3 (based on this and this)
Login-AzureRmAccount
Set-AzureRmContext -SubscriptionName "Visual Studio Professional"
$resourceGroup = "MyResourceGroup9"
$location = "West Europe"
$storageAccountName = "teststorageaccount"
New-AzureRmResourceGroup -Name $resourceGroup -Location $location
Write-Host "Created resource group"
New-AzureRmStorageAccount -ResourceGroupName $resourceGroup -AccountName $storageAccountName -Type Standard_RAGRS -Location $location -AccessTier Cool -Kind BlobStorage
Write-Host "Fetching storage account information"
$storageKey = (Get-AzureStorageKey -StorageAccountName $storageAccountName).Primary
$storageContext = New-AzureStorageContext -StorageAccountName $storageAccountName -StorageAccountKey $storageKey
New-AzureStorageContainer -Name "images" -Permission Off -Context $storageContext
Error:
Get-AzureStorageKey : ResourceNotFound: The storage account 'teststorageaccount' was not found. New-AzureStorageContext : Cannot validate argument on parameter 'StorageAccountKey'. The argument is null or empty. Provide an argument that is not null or empty, and then try the command again. New-AzureStorageContainer : The term 'New-AzureStorageContainer' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
Attempt #4 (based on this)
Login-AzureRmAccount
Set-AzureRmContext -SubscriptionName "Visual Studio Professional"
$resourceGroup = "MyResourceGroup10"
$location = "West Europe"
$storageAccountName = "dasdaaadmb"
New-AzureRmResourceGroup -Name $resourceGroup -Location $location
Write-Host "Created resource group"
New-AzureRmStorageAccount -ResourceGroupName $resourceGroup -AccountName $storageAccountName -Type Standard_RAGRS -Location $location -AccessTier Cool -Kind BlobStorage
Write-Host "Fetching storage account information"
$storageKey = (Get-AzureRmStorageAccountKey -Name $storageAccountName -ResourceGroupName $resourceGroup).Value[0]
$storageContext = New-AzureStorageContext -StorageAccountName $storageAccountName -StorageAccountKey $storageKey
New-AzureStorageContainer -Name "images" -Permission Off -Context $storageContext
Error:
New-AzureStorageContainer : The term 'New-AzureStorageContainer' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
Attempt #5 (based on this)
Login-AzureRmAccount
Set-AzureRmContext -SubscriptionName "Visual Studio Professional"
$resourceGroup = "MyResourceGroup11"
$location = "West Europe"
$storageAccountName = "addadadsadad"
New-AzureRmResourceGroup -Name $resourceGroup -Location $location
Write-Host "Created resource group"
New-AzureRmStorageAccount -ResourceGroupName $resourceGroup -AccountName $storageAccountName -Type Standard_RAGRS -Location $location -AccessTier Cool -Kind BlobStorage
Set-AzureRmCurrentStorageAccount -StorageAccountName $storageAccountName -ResourceGroupName $resourceGroup
New-AzureStorageContainer -Name "images" -Permission Off
Error:
New-AzureStorageContainer : The term 'New-AzureStorageContainer' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At this point I'm out of ideas. How can I create a storage container from an ARM context? This seems to indicate the issue is because I'm mixing ASM and ARM which I hoped would've been resolved by passing around the context (see attempt 3 & 4)