azureazure-powershellazure-bicep

Error: Code=InvalidTemplateDeployment; Message=The template deployment 'StAccDeployment' is not valid according to the validation procedure


PowerShell Command:

New-AzResourceGroupDeployment -Name 'StAccDeployment' -TemplateFile '.\CreateStorageAccount.bicep' -ResourceGroupName 'bicepworks' -Mode Incremental

CreateStorageAccount.bicep:

resource storageAccount 'Microsoft.Storage/storageAccounts@2023-05-01' = {
  name: 'rajstaccprc01'
  location: 'centralindia'
  sku: {
    name: 'Standard_LRS'
  }
  kind: 'BlobStorage'
}

The above bicep template is a basic one. When I see some udemy course video, the tutor succeeded the provisioning of the storage account using above basic template.

I know the video is from long ago. So, Do I miss any parameters in the above bicep code.

Correct me where I missed the code:

Error details:

New-AzResourceGroupDeployment: 15:25:52 - Error: Code=InvalidTemplateDeployment; Message=The template deployment 'StAccDeployment' is not valid according to the validation procedure. The tracking id is 'fb97bd7c-328a5a3c995b'. See inner errors for details.
New-AzResourceGroupDeployment: 15:25:52 - Error: Code=PreflightValidationCheckFailed; Message=Preflight validation failed. Please refer to the details for the specific errors.
New-AzResourceGroupDeployment: 15:25:52 - Error: Code=MissingRequiredAccountProperty; Message=Account property accessTier is required for the request.
New-AzResourceGroupDeployment: The deployment validation failed

Solution

  • As @jitter answered, if using kind = BlobStorage, the accessTier in properties is required. reference

    resource storageAccount1 'Microsoft.Storage/storageAccounts@2023-05-01' = {
      name: 'satest111'
      location: 'westus'
      sku: {
        name: 'Standard_LRS'
      }
      kind: 'BlobStorage'
      properties: {
        accessTier: 'Cold'
      }
    }
    
    

    enter image description here

    Try to use kind = 'StorageV2' to make it easy if the kind not mandatory, v2 type is also recommanded.

    resource storageAccount2 'Microsoft.Storage/storageAccounts@2023-05-01' = {
      name: 'satest222'
      location: 'westus'
      sku: {
        name: 'Standard_LRS'
      }
      kind: 'StorageV2'
    }
    

    here is a sample reference