Gallery › General › Azure built-in policies
Resource requests should not use preview API versions
Converted Policy Audit Deny Disabled Mode All Version 1.0.0
Using generally available (GA) API versions helps ensure that resources are created and updated through stable, supported APIs. Create and update (PUT and PATCH) requests that specify an API version ending in '-preview' are evaluated at request time.
ConvertTo-Bylaw converted this policy, and proved that the file compiles back to the same definition.
Azure Policy JSONPreviewApiVersions_AuditDeny.json · 42 lines
{
"properties": {
"displayName": "Resource requests should not use preview API versions",
"policyType": "BuiltIn",
"mode": "All",
"description": "Using generally available (GA) API versions helps ensure that resources are created and updated through stable, supported APIs. Create and update (PUT and PATCH) requests that specify an API version ending in '-preview' are evaluated at request time.",
"metadata": {
"version": "1.0.0",
"category": "General"
},
"version": "1.0.0",
"parameters": {
"effect": {
"type": "String",
"metadata": {
"displayName": "Effect",
"description": "Enable or disable the execution of the policy"
},
"allowedValues": [
"Audit",
"Deny",
"Disabled"
],
"defaultValue": "Audit"
}
},
"policyRule": {
"if": {
"value": "[requestContext().apiVersion]",
"like": "*-preview"
},
"then": {
"effect": "[parameters('effect')]"
}
},
"versions": [
"1.0.0"
]
},
"id": "/providers/Microsoft.Authorization/policyDefinitions/b7a590ab-7d17-46fa-b4f3-d6f6eca3c3ba",
"name": "b7a590ab-7d17-46fa-b4f3-d6f6eca3c3ba"
}Bylawb7a590ab-7d17-46fa-b4f3-d6f6eca3c3ba.bylaw.ps1 · 28 lines
# Converted from PreviewApiVersions_AuditDeny.json by ConvertTo-Bylaw.
Policy 'b7a590ab-7d17-46fa-b4f3-d6f6eca3c3ba' {
Properties @{
DisplayName = 'Resource requests should not use preview API versions'
Description = 'Using generally available (GA) API versions helps ensure that resources are created and updated through stable, supported APIs. Create and update (PUT and PATCH) requests that specify an API version ending in ''-preview'' are evaluated at request time.'
Version = '1.0.0'
Category = 'General'
PolicyVersion = '1.0.0'
Mode = 'All'
}
Parameter Effect @{
AllowedValues = @('Audit', 'Deny', 'Disabled')
Default = 'Audit'
DisplayName = 'Effect'
Description = 'Enable or disable the execution of the policy'
}
Resource * {
Require 'Requirement 1' {
Arm '[requestContext().apiVersion]' | Must -Not -BeLike '*-preview'
}
}
Effect (Param Effect)
}Source: built-in-policies/policyDefinitions/General/PreviewApiVersions_AuditDeny.json in Azure/azure-policy, under the MIT licence.
Bylaw