Bicep stopped deploying with this error
I’m trying to deploy a resource group which has two storage accounts in it with this PowerShell command using a bicep template:
New-AzResourceGroupDeployment -ResourceGroupName $resourcegroupName -TemplateFile .\azuredeploy.bicep -TemplateParameterFile .\azuredeploy.test.parameters.json
Error
I haven’t made any code changes, just not deployed this resource for a while. I decided to update bicep to the latest version (at the time of writing is Bicep CLI version 0.4.412 (f1169d063e)).
I still get the same error, so I update the PowerShell Az
module to the latest version too. Now when I try my command again, getting a different error:
Error
I check my bicep template and all is fine. However I look up the storage accounts documentation and check the API versions. I see that there’s a later API version than the one I’m using so update to the latest.
I just had to change line 1 in the code below
Code before
resource saResources 'Microsoft.Storage/storageAccounts@2021-01-01' = [for sa in storageAccounts: {
name: '${sa.namePrefix}${uniqueString(resourceGroup().id)}'
location: location
tags: tags
sku: {
name: 'Standard_LRS'
}
kind: 'StorageV2'
properties: {
accessTier: sa.accessTier
}
}]
Code after
resource saResources 'Microsoft.Storage/storageAccounts@2021-02-01' = [for sa in storageAccounts: {
name: '${sa.namePrefix}${uniqueString(resourceGroup().id)}'
location: location
tags: tags
sku: {
name: 'Standard_LRS'
}
kind: 'StorageV2'
properties: {
accessTier: sa.accessTier
}
}]
Now when I deploy, it works fine.