Data/ARMTemplates/storageaccount.json

{
    "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "storageAccountName": {
            "type": "string",
            "defaultValue": "[concat('st', uniquestring(resourceGroup().id))]",
            "metadata": {
                "description": "Storage Account Name"
            }
        },
        "location": {
            "type": "string",
            "defaultValue": "[resourceGroup().location]",
            "metadata": {
                "description": "App Service Deployment Location."
            }
        },
        "accountType": {
            "type": "string",
            "defaultValue": "Standard_GRS",
            "metadata": {
                "description": "Storage Account Type"
            }
        },
        "minimumTlsVersion": {
            "type": "string",
            "defaultValue": "TLS1_2",
            "metadata": {
                "description": "Minimum TLS Version"
            }
        },
        "allowBlobPublicAccess": {
            "type": "bool",
            "defaultValue": false,
            "metadata": {
                "description": "Allow Blob Public Access"
            }
        },
        "kind": {
            "type": "string",
            "defaultValue": "StorageV2",
            "metadata": {
                "description": "Kind of Storage."
            }
        },
        "networkAcls": {
            "type": "object",
            "defaultValue": {
                "defaultAction": "allow",
                "bypass": "AzureServices",
                "ipRules": [],
                "virtualNetworkRules": []
            },
            "metadata": {
                "description": "Network ACLS"
            }
        },
        "containerNames": {
            "type": "array",
            "defaultValue": [
                {
                    "name": "default",
                    "publicAccess": "None"
                }
            ]
        }
    },
    "variables": {},
    "resources": [
        {
            "name": "[parameters('storageAccountName')]",
            "type": "Microsoft.Storage/storageAccounts",
            "apiVersion": "2019-06-01",
            "location": "[parameters('location')]",
            "sku": {
                "name": "[parameters('accountType')]"
            },
            "properties": {
                "supportsHttpsTrafficOnly": true,
                "minimumTlsVersion": "[parameters('minimumTlsVersion')]",
                "allowBlobPublicAccess": "[parameters('allowBlobPublicAccess')]",
                "networkAcls": "[parameters('networkAcls')]",
                "encryption": {
                    "services": {
                        "file": {
                            "keyType": "Account",
                            "enabled": true
                        },
                        "blob": {
                            "keyType": "Account",
                            "enabled": true
                        }
                    },
                    "keySource": "Microsoft.Storage"
                },
                "allowSharedKeyAccess": false
            },
            "kind": "[parameters('kind')]"
        },
        {
            "type": "Microsoft.Storage/storageAccounts/blobServices",
            "apiVersion": "2019-06-01",
            "name": "[concat(parameters('storageAccountName'), '/default')]",
            "dependsOn": [
                "[resourceId('Microsoft.Storage/storageAccounts', parameters('storageAccountName'))]"
            ],
            "sku": {
                "name": "[parameters('accountType')]"
            },
            "properties": {
                "cors": {
                    "corsRules": []
                },
                "deleteRetentionPolicy": {
                    "enabled": false
                }
            }
        },
        {
            "apiVersion": "2019-05-01",
            "name": "[concat('StorageAccoutContainers-', parameters('storageAccountName'), '-', parameters('containerNames')[copyIndex()].name)]",
            "type": "Microsoft.Resources/deployments",
            "dependsOn": [
                "[resourceId('Microsoft.Storage/storageAccounts/blobServices', parameters('storageAccountName'), 'default')]",
                "[resourceId('Microsoft.Storage/storageAccounts', parameters('storageAccountName'))]"
            ],
            "copy": {
                "name": "containercopy",
                "count": "[length(parameters('containerNames'))]"
            },
            "properties": {
                "mode": "Incremental",
                "template": {
                    "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
                    "contentVersion": "1.0.0.0",
                    "resources": [
                        {
                            "type": "Microsoft.Storage/storageAccounts/blobServices/containers",
                            "apiVersion": "2019-06-01",
                            "name": "[concat(parameters('storageAccountName'), '/default/', parameters('containerNames')[copyIndex()].name)]",
                            "properties": {
                                "publicAccess": "[parameters('containerNames')[copyIndex()].publicAccess]"
                            }
                        }
                    ]
                }
            }
        },
        {
            "type": "Microsoft.Storage/storageAccounts/fileServices",
            "apiVersion": "2019-06-01",
            "name": "[concat(parameters('storageAccountName'), '/default')]",
            "dependsOn": [
                "[resourceId('Microsoft.Storage/storageAccounts', parameters('storageAccountName'))]"
            ],
            "sku": {
                "name": "[parameters('accountType')]"
            },
            "properties": {
                "cors": {
                    "corsRules": []
                }
            }
        },
        {
            "type": "Microsoft.Storage/storageAccounts/queueServices",
            "apiVersion": "2019-06-01",
            "name": "[concat(parameters('storageAccountName'), '/default')]",
            "dependsOn": [
                "[resourceId('Microsoft.Storage/storageAccounts', parameters('storageAccountName'))]"
            ],
            "properties": {
                "cors": {
                    "corsRules": []
                }
            }
        },
        {
            "type": "Microsoft.Storage/storageAccounts/tableServices",
            "apiVersion": "2019-06-01",
            "name": "[concat(parameters('storageAccountName'), '/default')]",
            "dependsOn": [
                "[resourceId('Microsoft.Storage/storageAccounts', parameters('storageAccountName'))]"
            ],
            "properties": {
                "cors": {
                    "corsRules": []
                }
            }
        }
    ],
    "outputs": {
        "storageAccountName": {
            "type": "string",
            "value": "[parameters('storageAccountName')]"
        },
        "storageAccountResourceId": {
            "type": "string",
            "value": "[resourceId('Microsoft.Storage/storageAccounts', parameters('storageAccountName'))]"
        }
    }
}