Gallery › App Service › Azure Community Policy
Apps Require App Gateway Front End
Uses Condition Policy AuditIfNotExists Disabled Mode All Version 1.0.0
Custom policy requires that HTTP(S) triggered apps require App GW Front-End so that inbound ports are not opened on apps
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 · 52 lines
{
"name": "8431222f-a925-4451-bf45-b68634f61a25",
"type": "Microsoft.Authorization/policyDefinitions",
"properties": {
"displayName": "Apps Require App Gateway Front End",
"description": "Custom policy requires that HTTP(S) triggered apps require App GW Front-End so that inbound ports are not opened on apps",
"metadata": {
"category": "App Service",
"version": "1.0.0"
},
"mode": "All",
"parameters": {
"effect": {
"type": "String",
"metadata": {
"displayName": "Effect",
"description": "AuditIfNotExists or Disabled the execution of the Policy"
},
"allowedValues": [
"AuditIfNotExists",
"Disabled"
],
"defaultValue": "AuditIfNotExists"
}
},
"policyRule": {
"if": {
"field": "type",
"in": [
"Microsoft.Web/sites"
]
},
"then": {
"effect": "[parameters('effect')]",
"details": {
"type": "Microsoft.Network/applicationGateways",
"existenceScope": "subscription",
"existenceCondition": {
"count": {
"field": "Microsoft.Network/applicationGateways/backendAddressPools[*].backendAddresses[*]",
"where": {
"field": "Microsoft.Network/applicationGateways/backendAddressPools[*].backendAddresses[*].fqdn",
"like": "[concat(field('name'),'.','*')]"
}
},
"greaterOrEquals": 1
}
}
}
}
}
}Bylaw8431222f-a925-4451-bf45-b68634f61a25.bylaw.ps1 · 31 lines
# Converted from azurepolicy.json by ConvertTo-Bylaw.
Policy '8431222f-a925-4451-bf45-b68634f61a25' {
Properties @{
DisplayName = 'Apps Require App Gateway Front End'
Description = 'Custom policy requires that HTTP(S) triggered apps require App GW Front-End so that inbound ports are not opened on apps'
Category = 'App Service'
Version = '1.0.0'
Mode = 'All'
}
Parameter Effect @{
AllowedValues = @('AuditIfNotExists', 'Disabled')
Default = 'AuditIfNotExists'
DisplayName = 'Effect'
Description = 'AuditIfNotExists or Disabled the execution of the Policy'
}
Resource * {
Require 'type is not one of 1 value' {
Field type | Must -Not -BeIn @('Microsoft.Web/sites') -IfPresent
}
}
AuditIfNotExists 'Microsoft.Network/applicationGateways' -ExistenceScope Subscription -Effect (Param Effect) {
Require 'name, backendAddressPools.backendAddresses and backendAddressPools.backendAddresses.fqdn are as required' {
Condition -Compliant '{ "count": { "field": "Microsoft.Network/applicationGateways/backendAddressPools[*].backendAddresses[*]", "where": { "field": "Microsoft.Network/applicationGateways/backendAddressPools[*].backendAddresses[*].fqdn", "like": "[concat(field(''name''),''.'',''*'')]" } }, "greaterOrEquals": 1 }'
}
}
}Source: policyDefinitions/App Service/apps-require-app-gateway-front-end/azurepolicy.json in Azure/Community-Policy, under the MIT licence.
Bylaw