Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Creating Container using Azure Resource Manager Template

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?

like image 580
TechnoFobic Avatar asked Mar 13 '23 21:03

TechnoFobic


2 Answers

As of today, no. You cannot create a container through ARM template. This is because ARM is for managing control plane for Azure Resources like creating/updating/deleting storage accounts while creating containers come under managing data plane and you would need to use Storage REST API for that.

like image 90
Gaurav Mantri Avatar answered Mar 23 '23 00:03

Gaurav Mantri


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.

like image 21
clericc Avatar answered Mar 22 '23 22:03

clericc