Gallery › Network › Azure Community Policy
App Gateway can only have a VM's or VMSS in its backend pool.
Uses Condition Policy Audit Deny Disabled Mode All Version 1.0.0
need to add description
ConvertTo-Bylaw converted this policy, and proved it compiles back to the same definition. Conditions the language can't express yet are written as raw JSON with Condition.
Azure Policy JSONazurepolicy.json · 47 lines
{
"name": "09acf097-b60e-42d5-98a1-e37e9ede66fe",
"type": "Microsoft.Authorization/policyDefinitions",
"properties": {
"displayName": "App Gateway can only have a VM's or VMSS in its backend pool.",
"description": "need to add description",
"metadata": {
"version": "1.0.0",
"category": "Network"
},
"mode": "All",
"parameters": {
"effect": {
"type": "String",
"metadata": {
"displayName": "Effect",
"description": "Deny, Audit or Disabled the execution of the Policy"
},
"allowedValues": [
"Deny",
"Audit",
"Disabled"
],
"defaultValue": "Audit"
}
},
"policyRule": {
"if": {
"allOf": [
{
"field": "type",
"equals": "Microsoft.Network/applicationGateways"
},
{
"count": {
"field": "Microsoft.Network/applicationGateways/backendAddressPools[*].backendAddresses[*]"
},
"greater": 0
}
]
},
"then": {
"effect": "[parameters('effect')]"
}
}
}
}Bylaw09acf097-b60e-42d5-98a1-e37e9ede66fe.bylaw.ps1 · 27 lines
# Converted from azurepolicy.json by ConvertTo-Bylaw.
Policy '09acf097-b60e-42d5-98a1-e37e9ede66fe' {
Properties @{
DisplayName = 'App Gateway can only have a VM''s or VMSS in its backend pool.'
Description = 'need to add description'
Version = '1.0.0'
Category = 'Network'
Mode = 'All'
}
Parameter Effect @{
AllowedValues = @('Deny', 'Audit', 'Disabled')
Default = 'Audit'
DisplayName = 'Effect'
Description = 'Deny, Audit or Disabled the execution of the Policy'
}
Resource 'Microsoft.Network/applicationGateways' {
Require 'backendAddressPools.backendAddresses is as required' {
Condition -Violation '{ "count": { "field": "Microsoft.Network/applicationGateways/backendAddressPools[*].backendAddresses[*]" }, "greater": 0 }'
}
}
Effect (Param Effect)
}Source: policyDefinitions/Network/app-gateway-can-only-have-a-vm's-or-vmss-in-its-backend-pool/azurepolicy.json in Azure/Community-Policy, under the MIT licence.
Bylaw