Azure / bicep

Bicep is a declarative language for describing and deploying Azure resources
MIT License
3.2k stars 742 forks source link

Is there such a thing as a count operator (for policy rules) in Bicep? #8851

Closed BartDecker closed 1 year ago

BartDecker commented 1 year ago

Is there such a thing as a count operator (for policy rules) in Bicep?

Such as described here for ARM -> https://learn.microsoft.com/en-us/azure/governance/policy/samples/pattern-count-operator

I'm trying to put the deployment of the following policy definition in a bicep template -> /providers/Microsoft.Authorization/policyDefinitions/ffb6f416-7bd2-4488-8828-56585fef2be9 / Enable export to Log Analytics workspace of Microsoft Defender for Cloud data.

But have a hard time in bringing the policy rule logic related to the existence condition to a bicep template.

alex-frankel commented 1 year ago

Can you share a bit more of the code you would like to write that is not working today? Bicep/ARM Templates does not have a count() function like policy, but depending on what you are trying to achieve, there may be a workaround.

BartDecker commented 1 year ago

@alex-frankel I solved it by using the built-in policy definition. My question was also asked in the wrong way. I was looking to get the policy rule within the Bicep template, but used the built in policy instead of it (only passing parameters to he policy via the bicep template)