Gallery › General › Azure built-in policies
Do Not Allow M365 resources
Uses Condition Policy Audit Deny Disabled Mode All Version 1.0.0
Block creation of M365 resources.
ConvertTo-Bylaw converted this policy, and proved it compiles back to the same definition. Conditions the language can't express yet are written as raw JSON with Condition.
Azure Policy JSONNotAllowM365_Deny.json · 50 lines
{
"properties": {
"displayName": "Do Not Allow M365 resources",
"policyType": "BuiltIn",
"mode": "All",
"description": "Block creation of M365 resources.",
"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": "Deny"
}
},
"policyRule": {
"if": {
"allOf": [
{
"field": "type",
"like": "Microsoft.SaaSHub/*"
},
{
"value": "[field('type')]",
"exists": true
}
]
},
"then": {
"effect": "[parameters('effect')]"
}
},
"versions": [
"1.0.0"
]
},
"id": "/providers/Microsoft.Authorization/policyDefinitions/176b7c36-ac64-4f15-a296-50bd7fafab12",
"name": "176b7c36-ac64-4f15-a296-50bd7fafab12"
}Bylaw176b7c36-ac64-4f15-a296-50bd7fafab12.bylaw.ps1 · 32 lines
# Converted from NotAllowM365_Deny.json by ConvertTo-Bylaw.
Policy '176b7c36-ac64-4f15-a296-50bd7fafab12' {
Properties @{
DisplayName = 'Do Not Allow M365 resources'
Description = 'Block creation of M365 resources.'
Version = '1.0.0'
Category = 'General'
PolicyVersion = '1.0.0'
Mode = 'All'
}
Parameter Effect @{
AllowedValues = @('Audit', 'Deny', 'Disabled')
Default = 'Deny'
DisplayName = 'Effect'
Description = 'Enable or disable the execution of the policy'
}
Resource * {
When {
Field type | Must -BeLike 'Microsoft.SaaSHub/*'
}
Require 'type is as required' {
Condition -Violation '{ "value": "[field(''type'')]", "exists": true }'
}
}
Effect (Param Effect)
}Source: built-in-policies/policyDefinitions/General/NotAllowM365_Deny.json in Azure/azure-policy, under the MIT licence.
Bylaw