Gallery › API Management › Azure Community Policy
Audit - Sample Products should be removed from API Management
Converted Policy Audit Disabled Mode All Version 1.0.0
API Management includes two sample products Starter and Unlimited. Accidentally adding APIs to these sample products may expose APIs more than intended.
ConvertTo-Bylaw converted this policy, and proved that the file compiles back to the same definition.
Azure Policy JSONazurepolicy.json · 44 lines
{
"name": "06b50e5f-2815-4e79-bc97-02996a363c4d",
"type": "Microsoft.Authorization/policyDefinitions",
"properties": {
"displayName": "Audit - Sample Products should be removed from API Management",
"description": "API Management includes two sample products Starter and Unlimited. Accidentally adding APIs to these sample products may expose APIs more than intended.",
"metadata": {
"category": "API Management",
"version": "1.0.0"
},
"mode": "All",
"parameters": {
"effect": {
"type": "String",
"metadata": {
"displayName": "Effect",
"description": "Audit or Disabled the execution of the Policy"
},
"allowedValues": [
"Audit",
"Disabled"
],
"defaultValue": "Audit"
}
},
"policyRule": {
"if": {
"anyOf": [
{
"field": "Microsoft.ApiManagement/service/products/displayName",
"equals": "Starter"
},
{
"field": "Microsoft.ApiManagement/service/products/displayName",
"equals": "Unlimited"
}
]
},
"then": {
"effect": "[parameters('effect')]"
}
}
}
}Bylaw06b50e5f-2815-4e79-bc97-02996a363c4d.bylaw.ps1 · 31 lines
# Converted from azurepolicy.json by ConvertTo-Bylaw.
Policy '06b50e5f-2815-4e79-bc97-02996a363c4d' {
Properties @{
DisplayName = 'Audit - Sample Products should be removed from API Management'
Description = 'API Management includes two sample products Starter and Unlimited. Accidentally adding APIs to these sample products may expose APIs more than intended.'
Category = 'API Management'
Version = '1.0.0'
Mode = 'All'
}
Parameter Effect @{
AllowedValues = @('Audit', 'Disabled')
Default = 'Audit'
DisplayName = 'Effect'
Description = 'Audit or Disabled the execution of the Policy'
}
Resource * {
Require 'displayName is not Starter' {
Field 'Microsoft.ApiManagement/service/products/displayName' | Must -Not -Be 'Starter' -IfPresent
}
Require 'displayName is not Unlimited' {
Field 'Microsoft.ApiManagement/service/products/displayName' | Must -Not -Be 'Unlimited' -IfPresent
}
}
Effect (Param Effect)
}Source: policyDefinitions/API Management/audit-sample-products-should-be-removed-from-api-management/azurepolicy.json in Azure/Community-Policy, under the MIT licence.
Bylaw