top of page

Use Bicep result as ARM 

{

  "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",

  "contentVersion": "1.0.0.0",

  "metadata": {

    "_generator": {

      "name": "bicep",

      "version": "0.4.1008.15138",

      "templateHash": "16480585462615677917"

    }

  },

  "parameters": {

    "storageAccountName": {

      "type": "string",

      "metadata": {

        "description": "Specifies the name of the Azure Storage account."

      }

    },

    "location": {

      "type": "string",

      "defaultValue": "[resourceGroup().location]",

      "metadata": {

        "description": "Specifies the location in which the Azure Storage resources should be deployed."

      }

    },

    "containerName": {

      "type": "array",

      "defaultValue": [

        "cont-1",

        "cont-2",

        "cont-3"

      ],

      "metadata": {

        "description": "Specifies array of Container params"

      }

    },

    "storageSKU": {

      "type": "string",

      "defaultValue": "Standard_LRS",

      "allowedValues": [

        "Standard_LRS",

        "Standard_GRS",

        "Standard_ZRS",

        "Premium_LRS"

      ],

      "metadata": {

        "description": "Secifies SKU(Stock Keeping Unit) for StorageAccount"

      }

    },

    "accessTier": {

      "type": "string",

      "defaultValue": "Hot",

      "allowedValues": [

        "Hot",

        "Cool"

      ],

      "metadata": {

        "description": "Specifies accessTier"

      }

    },

    "isHnsEnabled": {

      "type": "bool",

      "defaultValue": true,

      "metadata": {

        "description": "Specifies Hierarchical namespace true or false Bool"

      }

    },

    "allowBlobPublicAccess": {

      "type": "bool",

      "defaultValue": true,

      "metadata": {

        "description": "specifie allowBlobPublicAccess true or fale bool"

      }

    },

    "softDeleteOn": {

      "type": "bool",

      "defaultValue": false,

      "metadata": {

        "description": "Specifies Soft delete true or false bool"

      }

    },

    "retentionDays": {

      "type": "int",

      "defaultValue": 7,

      "metadata": {

        "description": "Specifies retention policy on soft delete in days"

      }

    },

    "containerDeleteRetentionPolicy": {

      "type": "bool",

      "defaultValue": false,

      "metadata": {

        "description": "Specifies Soft delete true or false bool"

      }

    },

    "containerRetentionDays": {

      "type": "int",

      "defaultValue": 7,

      "metadata": {

        "description": "Specifies retention policy on soft delete in days"

      }

    },

    "IsVersioningEnabled": {

      "type": "bool",

      "defaultValue": false,

      "metadata": {

        "description": "Specifies If versioning is enabled true or false bool"

      }

    },

    "minimumTlsVersion": {

      "type": "string",

      "defaultValue": "TLS1_2",

      "metadata": {

        "description": "Specifies minimumTlsVersion (Transport Layer Security)"

      }

    }

  },

  "functions": [],

  "resources": [

    {

      "type": "Microsoft.Storage/storageAccounts",

      "apiVersion": "2021-04-01",

      "name": "[parameters('storageAccountName')]",

      "location": "[parameters('location')]",

      "kind": "StorageV2",

      "sku": {

        "name": "[parameters('storageSKU')]"

      },

      "properties": {

        "accessTier": "[parameters('accessTier')]",

        "isHnsEnabled": "[parameters('isHnsEnabled')]",

        "allowBlobPublicAccess": "[parameters('allowBlobPublicAccess')]",

        "minimumTlsVersion": "[parameters('minimumTlsVersion')]"

      }

    },

    {

      "type": "Microsoft.Storage/storageAccounts/blobServices",

      "apiVersion": "2019-06-01",

      "name": "[format('{0}/{1}', parameters('storageAccountName'), 'default')]",

      "properties": {

        "cors": {

          "corsRules": []

        },

        "deleteRetentionPolicy": {

          "enabled": "[parameters('softDeleteOn')]",

          "days": "[parameters('retentionDays')]"

        },

        "containerDeleteRetentionPolicy": {

          "enabled": "[parameters('containerDeleteRetentionPolicy')]",

          "days": "[parameters('containerRetentionDays')]"

        },

        "isVersioningEnabled": "[parameters('IsVersioningEnabled')]"

      },

      "dependsOn": [

        "[resourceId('Microsoft.Storage/storageAccounts', parameters('storageAccountName'))]"

      ]

    },

    {

      "copy": {

        "name": "storageAccountName_default_containerName",

        "count": "[length(range(0, length(range(0, length(parameters('containerName'))))))]"

      },

      "type": "Microsoft.Storage/storageAccounts/blobServices/containers",

      "apiVersion": "2021-04-01",

      "name": "[format('{0}/default/{1}', parameters('storageAccountName'), parameters('containerName')[range(0, length(range(0, length(parameters('containerName')))))[copyIndex()]])]",

      "dependsOn": [

        "[resourceId('Microsoft.Storage/storageAccounts', parameters('storageAccountName'))]"

      ]

    }

  ]

}

FullCode
bottom of page