-
|
Hello all, The issueI've tried to deploy following template: targetScope = 'subscription'
resource CloudPosturePricing 'Microsoft.Security/pricings@2022-03-01' = {
name: 'CloudPosture'
properties: {
pricingTier: 'Free'
}
}
resource VirtualMachinesPricing 'Microsoft.Security/pricings@2022-03-01' = {
name: 'VirtualMachines'
properties: {
pricingTier: 'Standard'
subPlan: 'P2'
}
}
resource AppServicesPricing 'Microsoft.Security/pricings@2022-03-01' = {
name: 'AppServices'
properties: {
pricingTier: 'Free'
}
}
resource SqlServersPricing 'Microsoft.Security/pricings@2022-03-01' = {
name: 'SqlServers'
properties: {
pricingTier: 'Free'
}
}
resource SqlServerVirtualMachinesPricing 'Microsoft.Security/pricings@2022-03-01' = {
name: 'SqlServerVirtualMachines'
properties: {
pricingTier: 'Free'
}
}
resource OpenSourceRelationalDatabasesPricing 'Microsoft.Security/pricings@2022-03-01' = {
name: 'OpenSourceRelationalDatabases'
properties: {
pricingTier: 'Free'
}
}
resource CosmosDbsPricing 'Microsoft.Security/pricings@2022-03-01' = {
name: 'CosmosDbs'
properties: {
pricingTier: 'Free'
}
}
resource StorageAccountsPricing 'Microsoft.Security/pricings@2022-03-01' = {
name: 'StorageAccounts'
properties: {
pricingTier: 'Standard'
subPlan: 'PerTransaction'
}
}
resource ContainersPricing 'Microsoft.Security/pricings@2022-03-01' = {
name: 'Containers'
properties: {
pricingTier: 'Free'
}
}
resource KeyVaultsPricing 'Microsoft.Security/pricings@2022-03-01' = {
name: 'KeyVaults'
properties: {
pricingTier: 'Standard'
subPlan: 'PerTransaction'
}
}
resource ArmPricing 'Microsoft.Security/pricings@2022-03-01' = {
name: 'Arm'
properties: {
pricingTier: 'Standard'
subPlan: 'PerApiCall'
}
}
resource ApiPricing 'Microsoft.Security/pricings@2022-03-01' = {
name: 'Api'
properties: {
pricingTier: 'Free'
}
}So the template is:
When I try to deploy that template 1-4 resources fail to deploy with following error messages: This happened for me at least on two tenants and three subscriptions. Related workAzure landing zone templating is using dependsOn two deploy {
"type": "Microsoft.Security/pricings",
"apiVersion": "2018-06-01",
"name": "SqlServers",
"dependsOn": [
"[concat('Microsoft.Security/pricings/VirtualMachines')]"
],
"properties": {
"pricingTier": "[parameters('pricingTierSqlServers')]"
}
},
{
"type": "Microsoft.Security/pricings",
"apiVersion": "2018-06-01",
"name": "AppServices",
"dependsOn": [
"[concat('Microsoft.Security/pricings/SqlServers')]"
],
"properties": {
"pricingTier": "[parameters('pricingTierAppServices')]"
}
}I have earlier deployed similar templates without any errors.
Azure Support
BicepIf this is a well-known issue this should be documented by PG and then maybe Bicep should have linting rule to check if template has well-known issues. |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 2 replies
-
|
Hi @jikuja, This is not a Bicep issue, this is just how the Azure Security Center API behaves. Some APIs have intelligence built-in to handle multiple requests at once, some don't. The way to solve this is to add the batchSize decorator. Ex: @batchSize(1)This will make sure the request to the Security Center API is done sequentially and not in parallel. Create a loop to iterate over the plans to simplify your code. |
Beta Was this translation helpful? Give feedback.
-
Any known documentation for this behaviour? I feel like IaC using deployment API endpoint is being neglected or left fully untested :(
I'm not sure if loop would simplify the code. Because I'm setting different settings for plans and even some subplans:
Copying behaviour of the landing zone resources might be cleaner solution even it will create linter warnings. |
Beta Was this translation helpful? Give feedback.
-
|
I was facing the same issue, and find out the way that works as expected by creating a module for security/pricings. the main bicep looks like this: |
Beta Was this translation helpful? Give feedback.
-
|
@alex-frankel Do you happen to have a good instructions who to get through first support tiers when opening issues about missing Those can be solved only by the PG and honestly I don't want to use 4-x weeks with level 1 support and their workarounds. Should I try |
Beta Was this translation helpful? Give feedback.
-
|
Defender for cloud bicep worked fine for years, this workaround can't be perceived as designed behavior |
Beta Was this translation helpful? Give feedback.
Hi @jikuja,
This is not a Bicep issue, this is just how the Azure Security Center API behaves. Some APIs have intelligence built-in to handle multiple requests at once, some don't.
The way to solve this is to add the batchSize decorator. Ex:
This will make sure the request to the Security Center API is done sequentially and not in parallel.
https://learn.microsoft.com/en-us/azure/azure-resource-manager/bicep/file#resource-and-module-decorators
Create a loop to iterate over the plans to simplify your code.