Skip to content

Instantly share code, notes, and snippets.

@cloudchristoph
Created April 11, 2024 09:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cloudchristoph/7c533d31e4973ae3a3b1f65d55739e34 to your computer and use it in GitHub Desktop.
Save cloudchristoph/7c533d31e4973ae3a3b1f65d55739e34 to your computer and use it in GitHub Desktop.
Azure Policy: Deny Service Endpoints on subnets
{
"name": "Deny Service Endpoints on subnets",
"description": "This Policy will deny the enablement of Service Endpoints on subnets. This will also prevent PaaS resources such as Azure Storage from being able to add this subnet to their firewall allowed list.",
"mode": "All",
"policyRule": {
"if": {
"anyOf": [
{
"allOf": [
{
"field": "type",
"equals": "Microsoft.Network/virtualNetworks"
},
{
"count": {
"field": "Microsoft.Network/virtualNetworks/subnets[*]",
"where": {
"not": {
"field": "Microsoft.Network/virtualNetworks/subnets[*].serviceEndpoints[*].service",
"notLike": "*"
}
}
},
"greater": 0
}
]
},
{
"allOf": [
{
"field": "type",
"equals": "Microsoft.Network/virtualNetworks/subnets"
},
{
"not": {
"field": "Microsoft.Network/virtualNetworks/subnets/serviceEndpoints[*].service",
"notLike": "*"
}
}
]
}
]
},
"then": { "effect": "[parameters('effect')]" }
},
"parameters": {
"effect": {
"type": "String",
"metadata": {
"displayName": "Effect",
"description": "Enable or disable the execution of the policy"
},
"allowedValues": ["Deny", "Disabled"],
"defaultValue": "Deny"
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment