Gallery › App Service › Azure Community Policy
Web app configure always on
Converted Policy AuditIfNotExists DeployIfNotExists Disabled Mode Indexed Version 1.1.0
Configures the web app to always be on.
ConvertTo-Bylaw converted this policy, and proved that the file compiles back to the same definition.
Azure Policy JSONazurepolicy.json · 89 lines
{
"name": "61709510-5903-484e-86b8-311d2a52836c",
"type": "Microsoft.Authorization/policyDefinitions",
"properties": {
"displayName": "Web app configure always on",
"description": "Configures the web app to always be on.",
"metadata": {
"version": "1.1.0",
"category": "App Service"
},
"mode": "Indexed",
"parameters": {
"effect": {
"type": "String",
"metadata": {
"displayName": "Effect",
"description": "DeployIfNotExists, AuditIfNotExists or Disabled the execution of the Policy"
},
"allowedValues": [
"DeployIfNotExists",
"AuditIfNotExists",
"Disabled"
],
"defaultValue": "DeployIfNotExists"
}
},
"policyRule": {
"if": {
"allOf": [
{
"field": "type",
"equals": "Microsoft.Web/sites"
}
]
},
"then": {
"effect": "[parameters('effect')]",
"details": {
"type": "Microsoft.Web/sites/config",
"roleDefinitionIds": [
"/providers/microsoft.authorization/roleDefinitions/b24988ac-6180-42a0-ab88-20f7382dd24c"
],
"existenceCondition": {
"field": "Microsoft.Web/sites/config/web.alwaysOn",
"equals": "true"
},
"deployment": {
"properties": {
"mode": "incremental",
"template": {
"$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"appName": {
"type": "string"
},
"location": {
"type": "string"
}
},
"resources": [
{
"name": "[parameters('appName')]",
"type": "Microsoft.Web/sites",
"apiVersion": "2016-08-01",
"location": "[parameters('location')]",
"properties": {
"siteConfig": {
"alwaysOn": "true"
}
}
}
]
},
"parameters": {
"appName": {
"value": "[field('name')]"
},
"location": {
"value": "[field('location')]"
}
}
}
}
}
}
}
}
}Bylaw61709510-5903-484e-86b8-311d2a52836c.bylaw.ps1 · 30 lines
# Converted from azurepolicy.json by ConvertTo-Bylaw.
Policy '61709510-5903-484e-86b8-311d2a52836c' {
Properties @{
DisplayName = 'Web app configure always on'
Description = 'Configures the web app to always be on.'
Version = '1.1.0'
Category = 'App Service'
Mode = 'Indexed'
}
Parameter Effect @{
AllowedValues = @('DeployIfNotExists', 'AuditIfNotExists', 'Disabled')
Default = 'DeployIfNotExists'
DisplayName = 'Effect'
Description = 'DeployIfNotExists, AuditIfNotExists or Disabled the execution of the Policy'
}
Resource 'Microsoft.Web/sites'
DeployIfNotExists 'Microsoft.Web/sites/config' -Role 'Contributor' -Effect (Param Effect) {
Require 'web.alwaysOn is true' {
Field web.alwaysOn | Must -Be 'true'
}
Deployment -TemplateFile './templates/61709510-5903-484e-86b8-311d2a52836c.json' -Parameters ([ordered]@{
appName = (Arm '[field(''name'')]')
location = (Arm '[field(''location'')]')
})
}
}Its deployment templates are written beside it:
templates/61709510-5903-484e-86b8-311d2a52836c.json
Source: policyDefinitions/App Service/web-app-configure-always-on/azurepolicy.json in Azure/Community-Policy, under the MIT licence.
Bylaw