通过ARM模板创建Azure blob / fileshare容器

时间:2016-12-06 20:59:22

标签: azure azure-storage azure-storage-blobs azure-resource-manager azure-storage-files

我正在寻找一种在Azure blob& amp;中创建容器的方法。通过ARM模板进行文件共享存储。

目前我有ARM模板来配置存储帐户,但我想在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
              }
        }
      }
    }
  }

2 个答案:

答案 0 :(得分:10)

不,你不能这样做,consult this feedback item

您现在可以创建容器了。 https://stackoverflow.com/a/51608344/6067741

答案 1 :(得分:6)

有可能。 Azure管理REST Api现在具有Blob容器的终结点:https://docs.microsoft.com/en-us/rest/api/storagerp/blobcontainers/create

由于ARM模板映射到REST请求,因此我们可以创建以下模板,其中包含Blob容器作为存储帐户下方的嵌套资源。当然,您还可以按照通常的规则在顶级资源数组中描述Blob容器。

{
  "$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"
          }
        }
      ]
    }
  ]
}