Gallery › Network › Azure Community Policy
deny-app-gateway-only-allowed-in-approved-subnet
Converted Policy Audit Deny Disabled Mode All Version 1.0.0
need to add description
ConvertTo-Bylaw converted this policy, and proved that the file compiles back to the same definition.
Azure Policy JSONazurepolicy.json · 51 lines
{
"name": "5f0b611a-c962-4a81-9530-1c07c9565702",
"type": "Microsoft.Authorization/policyDefinitions",
"properties": {
"displayName": "deny-app-gateway-only-allowed-in-approved-subnet",
"description": "need to add description",
"metadata": {
"version": "1.0.0",
"category": "Network"
},
"mode": "All",
"parameters": {
"allowedSubnetName": {
"type": "String",
"metadata": {
"displayName": "Name of subnet where Applicaiton Gateways are allowed."
}
},
"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"
},
{
"field": "Microsoft.Network/applicationGateways/gatewayIPConfigurations[*].subnet.id",
"notContains": "[parameters('allowedSubnetName')]"
}
]
},
"then": {
"effect": "[parameters('effect')]"
}
}
}
}Bylaw5f0b611a-c962-4a81-9530-1c07c9565702.bylaw.ps1 · 33 lines
# Converted from azurepolicy.json by ConvertTo-Bylaw.
Policy '5f0b611a-c962-4a81-9530-1c07c9565702' {
Properties @{
DisplayName = 'deny-app-gateway-only-allowed-in-approved-subnet'
Description = 'need to add description'
Version = '1.0.0'
Category = 'Network'
Mode = 'All'
}
Parameter AllowedSubnetName @{
Type = 'String'
DisplayName = 'Name of subnet where Applicaiton Gateways are allowed.'
}
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 'gatewayIPConfigurations and subnet.id are as required' {
Count 'gatewayIPConfigurations[*]' -Where {
Field subnet.id | Must -ContainText (Param AllowedSubnetName)
} | Must -Not -Be 0
}
}
Effect (Param Effect)
}Source: policyDefinitions/Network/deny-app-gateway-only-allowed-in-approved-subnet/azurepolicy.json in Azure/Community-Policy, under the MIT licence.
Bylaw