'Unable to create container in Azure Storage via ARM Template

Using arm templates, I am able to create a storage account, queues, file services. But the azure devops task fails when I also try to create container.

  "resources": [
    {
      "name": "[parameters('storageAccountName')]",
      "type": "Microsoft.Storage/storageAccounts",
      "apiVersion": "2021-08-01",
      "location": "[parameters('location')]",
      "properties": {
        "accessTier": "[parameters('accessTier')]",
        "minimumTlsVersion": "TLS1_2",
        "supportsHttpsTrafficOnly": true,
        "allowBlobPublicAccess": true,
        "allowSharedKeyAccess": true,
        "allowCrossTenantReplication": true,
        "defaultToOAuthAuthentication": false,
        "networkAcls": {
          "bypass": "AzureServices",
          "defaultAction": "Allow",
          "ipRules": []
        },
        "isHnsEnabled": "[parameters('isHnsEnabled')]"
      },
      "dependsOn": [],
      "sku": {
        "name": "[parameters('accountType')]"
      },
      "kind": "[parameters('kind')]",
      "tags": {
        "InstanceId": "[parameters('instanceId')]"
      }
    },
    {
      "name": "[concat(parameters('storageAccountName'), '/default')]",
      "type": "Microsoft.Storage/storageAccounts/blobServices",
      "apiVersion": "2021-08-01",
      "properties": {
        "restorePolicy": {
          "enabled": false
        },
        "deleteRetentionPolicy": {
          "enabled": true,
          "days": 7
        },
        "containerDeleteRetentionPolicy": {
          "enabled": true,
          "days": 7
        },
        "changeFeed": {
          "enabled": false
        },
        "isVersioningEnabled": false
      },
      "dependsOn": [
        "[concat('Microsoft.Storage/storageAccounts/', parameters('storageAccountName'))]"
      ]
    },
    {
      "name": "[concat(parameters('storageAccountName'), '/default')]",
      "type": "Microsoft.Storage/storageAccounts/fileservices",
      "apiVersion": "2021-08-01",
      "properties": {
        "shareDeleteRetentionPolicy": {
          "enabled": true,
          "days": 7
        }
      },
      "dependsOn": [
        "[concat('Microsoft.Storage/storageAccounts/', parameters('storageAccountName'))]",
        "[concat(concat('Microsoft.Storage/storageAccounts/', parameters('storageAccountName')), '/blobServices/default')]"
      ]
    },
    {
      "type": "Microsoft.Storage/storageAccounts/blobServices/containers",
      "apiVersion": "2021-08-01",
      "name": "[concat(parameters('storageAccountName'), '/default/builds')]",
      "dependsOn": [
        "[concat('Microsoft.Storage/storageAccounts/', parameters('storageAccountName'))]",
        "[concat(concat('Microsoft.Storage/storageAccounts/', parameters('storageAccountName')), '/blobServices/default')]"
      ],
      "properties": {
          "immutableStorageWithVersioning": {
              "enabled": false
          },
          "defaultEncryptionScope": "$account-encryption-key",
          "denyEncryptionScopeOverride": false,
          "publicAccess": "None"
      }
    }
  ]

All the above resources get created except the one related to container Microsoft.Storage/storageAccounts/blobServices/containers. This is the error message:

##[error]At least one resource deployment operation failed. Please list deployment operations for details. Please see https://aka.ms/DeployOperations for usage details.
##[error]Details:
##[error]FeatureNotSupportedForAccount: ImmutableStorageWithVersioning is not supported for the account.
##[error]Check out the troubleshooting guide to see if your issue is addressed: https://docs.microsoft.com/en-us/azure/devops/pipelines/tasks/deploy/azure-resource-group-deployment?view=azure-devops#troubleshooting
##[error]Task failed while creating or updating the template deployment.

Here is also what I tried. From the portal I created a storage account and container. Then I exported the arm-template, and tried creating another storage account with the same template. It again fails with the same error. Looks like there may be a bug with the one that is exported by portal.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source