Gallery › Policy › Azure Community Policy
Deny policy exemption without given info
Converted Policy Audit Deny Disabled Mode All Version 1.0.0
Deny policy exemption if expiration date is not set, if an expiration date greater than given days, or if description is empty
ConvertTo-Bylaw converted this policy, and proved that the file compiles back to the same definition.
Azure Policy JSONazurepolicy.json · 64 lines
{
"name": "517a46a1-0a34-4c1d-b641-78182524b05c",
"type": "Microsoft.Authorization/policyDefinitions",
"properties": {
"displayName": "Deny policy exemption without given info",
"description": "Deny policy exemption if expiration date is not set, if an expiration date greater than given days, or if description is empty",
"metadata": {
"version": "1.0.0",
"category": "Policy"
},
"mode": "All",
"parameters": {
"maxExpirationDays": {
"type": "integer",
"defaultValue": 182,
"metadata": {
"description": "Days from current datetime that a policy exemption date can maximum be. Time is UTC. 182 is approx. 6 months."
}
},
"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.Authorization/policyExemptions"
},
{
"anyOf": [
{
"field": "Microsoft.Authorization/policyExemptions/expiresOn",
"exists": false
},
{
"field": "Microsoft.Authorization/policyExemptions/expiresOn",
"greaterOrEquals": "[addDays(utcNow(), parameters('maxExpirationDays'))]"
},
{
"field": "Microsoft.Authorization/policyExemptions/description",
"exists": false
}
]
}
]
},
"then": {
"effect": "[parameters('effect')]"
}
}
}
}Bylaw517a46a1-0a34-4c1d-b641-78182524b05c.bylaw.ps1 · 40 lines
# Converted from azurepolicy.json by ConvertTo-Bylaw.
Policy '517a46a1-0a34-4c1d-b641-78182524b05c' {
Properties @{
DisplayName = 'Deny policy exemption without given info'
Description = 'Deny policy exemption if expiration date is not set, if an expiration date greater than given days, or if description is empty'
Version = '1.0.0'
Category = 'Policy'
Mode = 'All'
}
Parameter MaxExpirationDays @{
Type = 'integer'
Default = 182
Description = 'Days from current datetime that a policy exemption date can maximum be. Time is UTC. 182 is approx. 6 months.'
}
Parameter Effect @{
AllowedValues = @('Deny', 'Audit', 'Disabled')
Default = 'Audit'
DisplayName = 'Effect'
Description = 'Deny, Audit or Disabled the execution of the Policy'
}
Resource 'Microsoft.Authorization/policyExemptions' {
Require 'expiresOn exists' {
Field expiresOn | Must -Exist
}
Require 'expiresOn is less than (Arm ''[addDays(utcNow(), parameters(''''maxExpirationDays''''))]'')' {
Field expiresOn | Must -BeLessThan (Arm '[addDays(utcNow(), parameters(''maxExpirationDays''))]')
}
Require 'description exists' {
Field description | Must -Exist
}
}
Effect (Param Effect)
}Source: policyDefinitions/Policy/deny-policy-exemption-without-given-info/azurepolicy.json in Azure/Community-Policy, under the MIT licence.
Bylaw