Creating Container using Azure Resource Manager Template

Viewed 3001

Is there a way to create a container when creating a Azure storage account using ARM template?

If this construct is not available, is there a way to write any extension that can do it at ARM deployment time?

3 Answers

Possible now (don't know since when):

{
  "$schema": "http://schema.management.azure.com/schemas/2014-04-01-preview/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "parameters": { ...  },
  "variables": { ... },
  "resources": [
    {
      "type": "Microsoft.Storage/storageAccounts",
      "name": "[variables('accountName')]",
      "apiVersion": "2018-02-01",
      "location": "westeurope",
      "kind": "BlobStorage",
      "sku": {
        "name": "Standard_LRS",
        "tier": "Standard"
      },
      "tags": {},
      "dependsOn": [],
      "properties": {
        "accessTier": "Cool"
      }
    },
    {
      "type": "Microsoft.Storage/storageAccounts/blobServices/containers",
      "apiVersion": "2018-03-01-preview",
      "name": "[concat(variables('accountName'), '/default/', variables('containerName')]",
      "dependsOn": [
        "[variables('accountName')]"
      ]
    }
  ]
}

I am pretty sure this can be done as a subresource inside the storage account and be further refined.

You can now create blob containers using ARM templates.

See this answer here .

Related