I have following issue: I want to deploy storage account, only if it does not exist.
I check the existence with az cli deployment script:
resource checkStorageAccountExistence 'Microsoft.Resources/deploymentScripts@2020-10-01' = {
name: 'checkStorageAccountExistenceScript'
location: location
kind: 'AzurePowerShell'
identity: identity
properties: {
arguments: '-storageAccountName \'${string(name)}\' -resourceGroupName \'${string(resourceGroupName)}\''
azPowerShellVersion: '3.0'
scriptContent: '''
param([string]$storageAccountName, [string]$resourceGroupName)
$provisioningState = az storage account show --name $storageAccountName --resource-group $resourceGroupName --output tsv --query 'provisioningState'
if ($provisioningState -eq "Succeeded") {$output = $true} else {$output = $false}
Write-Output $output
$DeploymentScriptOutputs = @{}
$DeploymentScriptOutputs['storageAccountExists'] = $output
'''
forceUpdateTag: utcValue
retentionInterval: 'P1D'
}
}
and I want to deploy conditionally storage account:
resource storageAccount 'Microsoft.Storage/storageAccounts@2022-09-01' = if (checkStorageAccountExistence.properties.outputs.storageAccountExists == true){
}
But I get error:
This expression is being used in the if-condition expression, which requires a value that can be calculated at the start of the deployment. Properties of checkStorageAccountExistence which can be calculated at the start include "apiVersion", "id", "name", "type".bicep(BCP177)