azure-policy icon indicating copy to clipboard operation
azure-policy copied to clipboard

Alias request: Microsoft.DocumentDb/databaseAccounts/virtualNetworkRules

Open RichShillingtonMSFT opened this issue 8 years ago • 2 comments

Scenario Enhance the security of Azure CosmosDB Accounts by requiring newly deployed accounts to use Virtual Network Service Endpoints. This is needed in MAG and Commercial Azure

Definition { "properties": { "displayName": "Prevent deployment of Azure CosmosDB Accounts without Virtual Network Service Endpoints", "description": "Enforce use of Virtual Netework Service Endpoint for Azure CosmosDB Accounts by ensuring the deployment contains a virtualNetworkRule", "parameters": {}, "policyRule": { "if": { "allOf": [ { "field": "type", "equals": "Microsoft.DocumentDb/databaseAccounts/virtualNetworkRules" }, { "field": "Microsoft.DocumentDb/databaseAccounts/virtualNetworkRules/[*]", "exists": "false" } ] }, "then": { "effect": "deny" } } } }

RichShillingtonMSFT avatar Oct 05 '18 17:10 RichShillingtonMSFT

The following aliases have been added: Microsoft.DocumentDB/databaseAccounts/virtualNetworkRules, Microsoft.DocumentDB/databaseAccounts/virtualNetworkRules[*].ignoreMissingVNetServiceEndpoint, Microsoft.DocumentDB/databaseAccounts/virtualNetworkRules[*], Microsoft.DocumentDB/databaseAccounts/virtualNetworkRules[*].id. Please try them out.

mentat9 avatar Jan 23 '19 03:01 mentat9

Hi, I am trying to run policy in 'append' mode so if the resource that is getting created does not have any virtual network endpoint, it adds one with the right subnet. Doing something like

"effect": "append", "details": [{

{ "field": "Microsoft.DocumentDB/databaseAccounts/virtualNetworkRules[*].id", "value": "[parameters('approvedCosmosDbSubnets')]" } ]

My variables are like approvedCosmosDbsubnets: subnet1

But it fails with error 'Policy is trying to append fields with different value', EVENTHOUGH i am selecting 'subnet1' when i am creating the DB. Not sure where things are going wrong ?

yasin-amadmia-mck avatar Jun 17 '19 14:06 yasin-amadmia-mck