How to force Azure Storage Account as classic
Asked Answered
A

4

6

We recently built a infrastructure and application deployment framework using the Azure Resource Manager and templates. In order to deploy a Cloud Service, it is required to first setup an Azure Storage Account. As of recently, this was accomplished by running:

Switch-AzureMode AzureResourceManager

New-AzureStorageAccount -ResourceGroupName $resourceGroupName -StorageAccountName $storageAccountName -Location $locationName -Type Standard_LRS

This would create a storage account that the New-AzureDeployment cmdlet could use for the deployment. As far as I can remember, the storage account created would be one that the now labeled as "classic" in the UI. However, with recent changes, the storage account that is now created using the script above is non-classic (V2). This V2 storage account is not recognized by the New-AzureDeployment, and it throws this in the Powershell script:

New-AzureDeployment : ResourceNotFound: The storage account 'teststorage' was not found.

If I manually create the classic storage account in the UI, I can use it for my deployment, and it works just fine.

So is it possible to do one of the following:

  1. Force the storage account to be created as classic via Powershell?
  2. Instruct the New-AzureDeployment cmdlet to use the V2 storage account via Powershell?
Anapest answered 7/8, 2015 at 21:3 Comment(0)
P
5

Switch back to asm mode (the v1 api) and create the storage account from there:

switch-azuremode -Name AzureServiceManagement
Proudman answered 7/8, 2015 at 23:19 Comment(0)
U
5

Because someone else may find this helpful with the later versions of Azure resource manager (my version was 1.0.4)....

In the latest versions of AzureRM for PSVersion 5.0.10514.6, this can be done through a powershell cmdlet.

Assuming you have:

a) Authenticated to Azure RM: Login-AzureRMAccount

b) Already have created the resource group: New-AzureRmResourceGroup -Name $resourceGroupName -Location "South Central US"

You can then do something like this to get a classic storage account:

New-AzureRmResource -ResourceName "" -ResourceGroupName $resourceGroupName -ResourceType "Microsoft.ClassicStorage/StorageAccounts" -Location "South Central US" -Properties @{ AccountType = "Standard_LRS" } -ApiVersion "2015-06-01"

Uncommon answered 22/2, 2016 at 18:55 Comment(1)
One more hoop I needed to jump through: The subscription is not registered to use namespace 'Microsoft.ClassicStorage'. Gets fixed with: Register-AzureRmResourceProvider -ProviderNamespace Microsoft.ClassicStorageIrrelevancy
C
3

You can actually use ARM (Azure Resource Manager) to create a "Classic" (i.e. old portal) storage account. To do this, add the below json into your "Resources", adjusting the params as you require. The advantage this has over @Trondh answer is that this will be provisioned as part of your resource group. When you switch back to the ASM your classic storage account will just be added to a random resource group that you cannot move.

       {
            "name": "[concat(parameters('BuildStorageName'), 'classic')]",
            "type": "Microsoft.ClassicStorage/storageAccounts",
            "location": "[parameters('BuildStorageLocation')]",
            "apiVersion": "2015-06-01",
            "dependsOn": [ ],
            "properties": {
                "accountType": "[parameters('BuildStorageType')]"
            }
        }
Christiano answered 18/8, 2015 at 16:17 Comment(0)
A
2

Jason's answer is definitively the best solution..

$resourceGroupName= "myrsgroupp"
$classicStorageName = "myclassicstoragename"
$location = "North Europe"
New-AzureRmResource -ResourceGroupName $resourceGroupName -ResourceName $classicStorageName -ResourceType "Microsoft.ClassicStorage/StorageAccounts" -Location $location -Properties @{AccountType="Standard_LRS"} -ApiVersion "2015-06-01" -Force
Arctic answered 4/1, 2019 at 14:10 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.