An Azure NoSQL database service for app development.
Hi @Christophe Humbert,
Thanks for the question and using MS Q&A platform.
It seems that you're trying to create an Azure Policy to ensure that Azure Cosmos DB resources are in Continuous Backup Mode. However, the policy you're currently using is returning the opposite result of what you expect.
Your policy uses the "equals" condition to check if the backupPolicy.type is set to "Continuous". This is fine for checking the compliance of resources, but the non-compliant message you're seeing suggests that the policy logic isn't behaving as expected.
You should use the notEquals condition to check that the backupPolicy.type is not "Continuous". This way, if the backupPolicy.type is anything other than "Continuous", the resource will be flagged as non-compliant.
Please try this updated Policy rule
"policyRule": {
"if": {
"allOf": [
{
"field": "type",
"equals": "Microsoft.DocumentDB/databaseAccounts"
},
{
"field": "Microsoft.DocumentDB/databaseAccounts/backupPolicy.type",
"notEquals": "Continuous"
}
]
},
"then": {
"effect": "[parameters('policyEffect')]"
}
}
Hope this helps. Do let us know if you any further queries. If this answers your query, do click Accept Answer and Yes for was this answer helpful. And, if you have any further query do let us know.