Gallery › API Management › Azure built-in policies
API Management APIs should use only encrypted protocols
Converted Policy Audit Deny Disabled Mode All Version 2.0.2
To ensure security of data in transit, APIs should be available only through encrypted protocols, like HTTPS or WSS. Avoid using unsecured protocols, such as HTTP or WS.
ConvertTo-Bylaw converted this policy, and proved that the file compiles back to the same definition.
Azure Policy JSONHTTPEnabled_AuditDeny.json · 64 lines
{
"properties": {
"displayName": "API Management APIs should use only encrypted protocols",
"policyType": "BuiltIn",
"mode": "All",
"description": "To ensure security of data in transit, APIs should be available only through encrypted protocols, like HTTPS or WSS. Avoid using unsecured protocols, such as HTTP or WS.",
"metadata": {
"version": "2.0.2",
"category": "API Management"
},
"version": "2.0.2",
"policyRule": {
"if": {
"allOf": [
{
"field": "type",
"equals": "Microsoft.ApiManagement/service/apis"
},
{
"count": {
"field": "Microsoft.ApiManagement/service/apis/protocols[*]",
"where": {
"anyOf": [
{
"field": "Microsoft.ApiManagement/service/apis/protocols[*]",
"equals": "http"
},
{
"field": "Microsoft.ApiManagement/service/apis/protocols[*]",
"equals": "ws"
}
]
}
},
"greaterOrEquals": 1
}
]
},
"then": {
"effect": "[parameters('effect')]"
}
},
"parameters": {
"effect": {
"type": "string",
"metadata": {
"displayName": "Effect",
"description": "Enable or disable the execution of the policy"
},
"allowedValues": [
"Audit",
"Disabled",
"Deny"
],
"defaultValue": "Audit"
}
},
"versions": [
"2.0.2"
]
},
"id": "/providers/Microsoft.Authorization/policyDefinitions/ee7495e7-3ba7-40b6-bfee-c29e22cc75d4",
"name": "ee7495e7-3ba7-40b6-bfee-c29e22cc75d4"
}Bylawee7495e7-3ba7-40b6-bfee-c29e22cc75d4.bylaw.ps1 · 34 lines
# Converted from HTTPEnabled_AuditDeny.json by ConvertTo-Bylaw.
Policy 'ee7495e7-3ba7-40b6-bfee-c29e22cc75d4' {
Properties @{
DisplayName = 'API Management APIs should use only encrypted protocols'
Description = 'To ensure security of data in transit, APIs should be available only through encrypted protocols, like HTTPS or WSS. Avoid using unsecured protocols, such as HTTP or WS.'
Version = '2.0.2'
Category = 'API Management'
PolicyVersion = '2.0.2'
Mode = 'All'
}
Parameter Effect @{
Type = 'string'
AllowedValues = @('Audit', 'Disabled', 'Deny')
Default = 'Audit'
DisplayName = 'Effect'
Description = 'Enable or disable the execution of the policy'
}
Resource 'Microsoft.ApiManagement/service/apis' {
Require 'protocols is as required' {
Count 'protocols[*]' -Where {
AnyOf {
Element | Must -Be 'http'
Element | Must -Be 'ws'
}
} | Must -Be 0
}
}
Effect (Param Effect)
}Source: built-in-policies/policyDefinitions/API Management/HTTPEnabled_AuditDeny.json in Azure/azure-policy, under the MIT licence.
Bylaw