Search code examples
azurecommand-line-interfaceazure-storageazure-bicep

Bicep Validation Error: Storage account does not accept BlockBlobStorage ask SKU


Im trying to create a storage account with bicep in West Europe.

I get the following error:

{"code": "InvalidTemplateDeployment", "message": "The template deployment 'bicep-deployment-from-ground-up' is not valid according to the validation procedure. The tracking id is '1a94c0f3-1bf2-4b71-8f03-0a2689129899'. See inner errors for details."}

Inner Errors:
{"code": "PreflightValidationCheckFailed", "message": "Preflight validation failed. Please refer to the details for the specific errors."}

Inner Errors:
{"code": "InvalidValuesForRequestParameters", "target": "dtcontent", "message": "Values for request parameters are invalid: kind, sku. For more information, see - https://aka.ms/storageaccounttypes"}

Inner Errors:
{"code": "InvalidValuesForRequestParameters", "target": "dtcontent", "message": "Values for request parameters are invalid: kind."}

The bicep looks like this:

param location string = resourceGroup().location

resource dtcontent 'Microsoft.Storage/storageAccounts@2023-01-01' = {
  name: 'dtcontent'
  location: location
  kind: 'BlockBlobStorage'
  sku: {
    name: 'Premium_LRS'
  }
  properties: {
    minimumTlsVersion: 'TLS1_2'
    publicNetworkAccess: 'Enabled'
    allowBlobPublicAccess: true
    accessTier: 'Hot'
  }

  resource blobService 'blobServices@2023-01-01' = {
    name: 'default'

    resource content 'containers@2023-01-01' = {
      name: 'content'
      properties: {
        publicAccess: 'Container'        
      }
    }
  }
}

Im using az cli with 2.57.0 and bicep version 0.25.53. Does someone now how to fix this error?


Solution

  • In my environment, I'm using the az cli with version 2.56.0 and bicep version 0.25.53.

    According to this MS-Document, the Premium access tier is the default value for premium block blob storage account type and cannot be changed for the premium block blob storage account type.

    You don't need to pass the access tier in the bicep code and also make sure your deployment resource group is in the same location.

    In my environment, I tried with the script below using the westeurope location.

    Code:

    param location string = resourceGroup().location
    
    resource dtcontent 'Microsoft.Storage/storageAccounts@2023-01-01' = {
      name: 'dtcontent2'
      location: location
      kind: 'BlockBlobStorage'
      sku: {
        name: 'Premium_LRS'
      }
      properties: {
        minimumTlsVersion: 'TLS1_2'
        publicNetworkAccess: 'Enabled'
        allowBlobPublicAccess: true
      }
    
      resource blobService 'blobServices@2023-01-01' = {
        name: 'default'
    
        resource content 'containers@2023-01-01' = {
          name: 'content'
          properties: {
            publicAccess: 'Container'        
          }
        }
      }
    }
    

    Deployment command:

    az deployment group create --resource-group v-venkat --template-file ./sample.bicep
    

    Here, v-venkat is a resource group with a westeurope location.

    Output: enter image description here

    Portal: enter image description here

    Reference:

    Microsoft.Storage/storageAccounts - Bicep, ARM template & Terraform AzAPI reference | Microsoft Learn