arm-artifacts/shared-templates/storage-account.json

{
  "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
    "storageAccountType": {
      "type": "string",
      "defaultValue": "Standard_LRS",
      "allowedValues": [
        "Standard_LRS",
        "Standard_ZRS",
        "Standard_GRS",
        "Standard_RAGRS",
        "Premium_LRS"
      ]
    },
    "storageAccessTier": {
      "type": "string",
      "defaultValue": "Hot",
      "allowedValues": [
        "Cool",
        "Hot"
      ]
    },
    "storageAccountName": {
      "type": "string",
      "minLength": 1
    },
    "storageAccountLocation": {
      "type": "string",
      "defaultValue": "[resourceGroup().location]"
    },
    "storageContainerNames": {
      "type": "array",
      "metadata": {
          "description": "Array of names to create storage containers."
      },
      "defaultValue": []
    },
    "supportsHttpsTrafficOnly": {
      "type": "bool",
      "defaultValue": true
    },
    "isHnsEnabled": {
        "type": "bool",
        "defaultValue": false
    },
    "tagValues": {
      "type": "object",
      "defaultValue": {}
    }
  },
  "variables": {
    "ownerRoleId": "[concat('/subscriptions/', subscription().subscriptionId, '/providers/Microsoft.Authorization/roleDefinitions/', '8e3af657-a8ff-443c-a75c-2fe8c4bcb635')]",
    "localTags": {
      "displayName": "[parameters('storageAccountName')]"
    },
    "isHnsEnabledBackwardsCompatValue": "[if(equals(parameters('isHnsEnabled'),json('false')), '', parameters('isHnsEnabled'))]",
    "tags": "[union(parameters('tagValues'), variables('localTags'))]"
  },
  "resources": [
    {
      "name": "[parameters('storageAccountName')]",
      "type": "Microsoft.Storage/storageAccounts",
      "location": "[parameters('storageAccountLocation')]",
      "apiVersion": "2018-07-01",
      "sku": {
        "name": "[parameters('storageAccountType')]"
      },
      "properties": {
        "accessTier": "[parameters('storageAccessTier')]",
        "supportsHttpsTrafficOnly": "[parameters('supportsHttpsTrafficOnly')]",
        "isHnsEnabled": "[variables('isHnsEnabledBackwardsCompatValue')]"
      },
      "dependsOn": [],
      "tags": "[variables('tags')]",
      "kind": "StorageV2"
    },
    {
      "condition": "[not(empty(parameters('storageContainerNames')))]",
      "name": "[concat(parameters('storageAccountName'), '/default/', if(not(empty(parameters('storageContainerNames'))), parameters('storageContainerNames')[copyIndex()], 'null'))]",
      "type": "Microsoft.Storage/storageAccounts/blobServices/containers",
      "apiVersion": "2018-07-01",
      "dependsOn": [
          "[parameters('storageAccountName')]"
      ],
      "copy": {
          "name": "storageContainers",
          "count": "[if(not(empty(parameters('storageContainerNames'))), length(parameters('storageContainerNames')), 1)]"
      }
    }
  ],
  "outputs": {
    "storageAccountKey": {
      "type": "string",
      "value": "[listKeys(parameters('storageAccountName'), '2019-04-01').keys[0].value]"
    },
    "storageAccountConnectionString": {
      "type": "string",
      "value": "[concat('DefaultEndpointsProtocol=https;AccountName=',parameters('storageAccountName'),';AccountKey=', listKeys(parameters('storageAccountName'), '2019-04-01').keys[0].value)]"
    }
  }
}