Gallery › Network › Azure Community Policy
Audit for Application Gateway without HTTP Redirect
Converted Policy AuditIfNotExists Disabled Mode All Version 1.0.0
This Policy looks to see if an HTTP listener exists. It then checks to see if a routing rule is configured for redirect. If a redirect is not detected then an audit is performed.
ConvertTo-Bylaw converted this policy, and proved that the file compiles back to the same definition.
Azure Policy JSONazurepolicy.json · 55 lines
{
"name": "79de6481-9bec-4094-ae77-416b955f6769",
"type": "Microsoft.Authorization/policyDefinitions",
"properties": {
"displayName": "Audit for Application Gateway without HTTP Redirect",
"description": "This Policy looks to see if an HTTP listener exists. It then checks to see if a routing rule is configured for redirect. If a redirect is not detected then an audit is performed.",
"metadata": {
"version": "1.0.0",
"category": "Network"
},
"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": {
"allOf": [
{
"field": "type",
"equals": "Microsoft.Network/applicationGateways"
},
{
"field": "Microsoft.Network/applicationGateways/httpListeners[*].protocol",
"equals": "http"
}
]
},
"then": {
"effect": "[parameters('effect')]",
"details": {
"type": "Microsoft.Network/applicationGateways/requestRoutingRules",
"existenceCondition": {
"allOf": [
{
"field": "Microsoft.Network/applicationGateways/requestRoutingRules[*].redirectConfiguration.id",
"exists": true
}
]
}
}
}
}
}
}Bylaw79de6481-9bec-4094-ae77-416b955f6769.bylaw.ps1 · 39 lines
# Converted from azurepolicy.json by ConvertTo-Bylaw.
Policy '79de6481-9bec-4094-ae77-416b955f6769' {
Properties @{
DisplayName = 'Audit for Application Gateway without HTTP Redirect'
Description = 'This Policy looks to see if an HTTP listener exists. It then checks to see if a routing rule is configured for redirect. If a redirect is not detected then an audit is performed.'
Version = '1.0.0'
Category = 'Network'
Mode = 'All'
}
Parameter Effect @{
AllowedValues = @('AuditIfNotExists', 'Disabled')
Default = 'AuditIfNotExists'
DisplayName = 'Effect'
Description = 'AuditIfNotExists or Disabled the execution of the Policy'
}
Resource 'Microsoft.Network/applicationGateways' {
Require 'httpListeners and protocol are as required' {
AnyOf {
Field httpListeners | Must -Not -Exist
Count 'httpListeners[*]' -Where {
Field protocol | Must -Not -Be 'http'
} | Must -Not -Be 0
}
}
}
AuditIfNotExists 'Microsoft.Network/applicationGateways/requestRoutingRules' -Effect (Param Effect) {
Require 'requestRoutingRules and redirectConfiguration.id are as required' {
Field 'Microsoft.Network/applicationGateways/requestRoutingRules' | Must -Exist
Each 'Microsoft.Network/applicationGateways/requestRoutingRules[*]' {
Field redirectConfiguration.id | Must -Exist
}
}
}
}Source: policyDefinitions/Network/audit-for-application-gateway-without-http-redirect/azurepolicy.json in Azure/Community-Policy, under the MIT licence.
Bylaw