Create Azure blob/fileshare container through ARM template

核能气质少年 提交于 2020-02-01 14:12:58

问题


I am looking a way to create a container in Azure blob & file-share storage through ARM template.

At present I have ARM template to provision the storage accounts, but I want to create containers also in ARM.

{
    "name": "[parameters('storageAccountName')]",
    "type": "Microsoft.Storage/storageAccounts",
    "location": "[resourceGroup().location]",
    "apiVersion": "[variables('storageApiVersion')]",
    "sku": {
        "name": "[variables('storageAccountType')]"
    },
    "dependsOn": [ ],
    "tags": {
      "Environment": "[parameters('Environment')]",
      "Project": "[parameters('ProjectName')]",
      "Contact": "[parameters('ContactName')]"
    },
    "kind": "Storage",
    "properties": {
      "encryption": {
        "keySource": "Microsoft.Storage",
        "services": {
              "blob": {
                "enabled": true
              }
        }
      }
    }
  }

回答1:


No, you cant do that, consult this feedback item.

you can now create containers. https://stackoverflow.com/a/51608344/6067741




回答2:


It is possible. Azure Management REST Api now has endpoints for Blob Containers: https://docs.microsoft.com/en-us/rest/api/storagerp/blobcontainers/create.

Since ARM Templates map to REST requests, we can create the following Template, containing a Blob Container as a nested resource below the Storage Account. Of course, you can also describe the Blob container in the toplevel resource array, following the usual rules.

{
  "$schema": "http://schema.management.azure.com/schemas/2014-04-01-preview/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {},
  "variables": {
    "accountName": "accountname",
    "containerName": "containername"
  },
  "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"
      },
      "resources": [
        {
          "type": "blobServices/containers",
          "apiVersion": "2018-03-01-preview",
          "name": "[concat('default/', variables('containerName'))]",
          "dependsOn": [
            "[variables('accountName')]"
          ],
          "properties": {
            "publicAccess": "None"
          }
        }
      ]
    }
  ]
}


来源:https://stackoverflow.com/questions/41004779/create-azure-blob-fileshare-container-through-arm-template

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!