Gallery › Cosmos DB › Azure Community Policy
Audit automatic failover for Azure Cosmos DB
Converted Policy Audit Disabled Mode all Version 1.0.0
This policy validates that automatic failover is enabled for an Azure Cosmos DB account.
ConvertTo-Bylaw converted this policy, and proved that the file compiles back to the same definition.
Azure Policy JSONazurepolicy.json · 44 lines
{
"name": "520f0cb0-e25c-417a-a919-7530acb05e13",
"type": "Microsoft.Authorization/policyDefinitions",
"properties": {
"displayName": "Audit automatic failover for Azure Cosmos DB",
"description": "This policy validates that automatic failover is enabled for an Azure Cosmos DB account.",
"metadata": {
"version": "1.0.0",
"category": "Cosmos DB"
},
"mode": "all",
"parameters": {
"effect": {
"type": "String",
"metadata": {
"displayName": "Effect",
"description": "Audit or Disabled the execution of the Policy"
},
"allowedValues": [
"Audit",
"Disabled"
],
"defaultValue": "Audit"
}
},
"policyRule": {
"if": {
"allOf": [
{
"field": "type",
"equals": "Microsoft.DocumentDB/databaseAccounts"
},
{
"field": "Microsoft.DocumentDB/databaseAccounts/enableAutomaticFailover",
"equals": "false"
}
]
},
"then": {
"effect": "[parameters('effect')]"
}
}
}
}Bylaw520f0cb0-e25c-417a-a919-7530acb05e13.bylaw.ps1 · 27 lines
# Converted from azurepolicy.json by ConvertTo-Bylaw.
Policy '520f0cb0-e25c-417a-a919-7530acb05e13' {
Properties @{
DisplayName = 'Audit automatic failover for Azure Cosmos DB'
Description = 'This policy validates that automatic failover is enabled for an Azure Cosmos DB account.'
Version = '1.0.0'
Category = 'Cosmos DB'
Mode = 'All'
}
Parameter Effect @{
AllowedValues = @('Audit', 'Disabled')
Default = 'Audit'
DisplayName = 'Effect'
Description = 'Audit or Disabled the execution of the Policy'
}
Resource 'Microsoft.DocumentDB/databaseAccounts' {
Require 'enableAutomaticFailover is not false' {
Field enableAutomaticFailover | Must -Not -Be 'false' -IfPresent
}
}
Effect (Param Effect)
}Source: policyDefinitions/Cosmos DB/audit-automatic-failover-for-azure-cosmos-db/azurepolicy.json in Azure/Community-Policy, under the MIT licence.
Bylaw