Bylaw

Gallery › API Management › Azure built-in policies

[Deprecated]: API Management minimum API version should be set to 2019-12-01 or higher

Converted Policy Audit Deny Disabled Mode Indexed Version 1.1.0-deprecated Deprecated

While we continue to recommend using the latest management API versions, configuring a minimum API version no longer affects the security posture of API Management services. Learn more about policy definition deprecation at aka.ms/policydefdeprecation

ConvertTo-Bylaw converted this policy, and proved that the file compiles back to the same definition.

Azure Policy JSONMinimumApiVersion_AuditDeny.json · 64 lines
{
  "properties": {
    "displayName": "[Deprecated]: API Management minimum API version should be set to 2019-12-01 or higher",
    "policyType": "BuiltIn",
    "mode": "Indexed",
    "description": "While we continue to recommend using the latest management API versions, configuring a minimum API version no longer affects the security posture of API Management services. Learn more about policy definition deprecation at aka.ms/policydefdeprecation",
    "metadata": {
      "version": "1.1.0-deprecated",
      "category": "API Management",
      "deprecated": true
    },
    "version": "1.1.0",
    "policyRule": {
      "if": {
        "allOf": [
          {
            "field": "type",
            "equals": "Microsoft.ApiManagement/service"
          },
          {
            "field": "Microsoft.ApiManagement/service/apiVersionConstraint.minApiVersion",
            "notMatch": "2019-12-01"
          },
          {
            "field": "Microsoft.ApiManagement/service/apiVersionConstraint.minApiVersion",
            "notMatch": "202#-##-##-preview"
          },
          {
            "field": "Microsoft.ApiManagement/service/apiVersionConstraint.minApiVersion",
            "notMatch": "202#-##-##"
          },
          {
            "field": "Microsoft.ApiManagement/service/sku.name",
            "notEquals": "Consumption"
          }
        ]
      },
      "then": {
        "effect": "[parameters('effect')]"
      }
    },
    "parameters": {
      "effect": {
        "type": "string",
        "metadata": {
          "displayName": "Effect",
          "description": "Enable or disable the execution of the policy"
        },
        "allowedValues": [
          "Audit",
          "Deny",
          "Disabled"
        ],
        "defaultValue": "Disabled"
      }
    },
    "versions": [
      "1.1.0",
      "1.0.1"
    ]
  },
  "id": "/providers/Microsoft.Authorization/policyDefinitions/549814b6-3212-4203-bdc8-1548d342fb67",
  "name": "549814b6-3212-4203-bdc8-1548d342fb67"
}
Bylaw549814b6-3212-4203-bdc8-1548d342fb67.bylaw.ps1 · 36 lines
# Converted from MinimumApiVersion_AuditDeny.json by ConvertTo-Bylaw.
Policy '549814b6-3212-4203-bdc8-1548d342fb67' {

    Properties @{
        DisplayName   = '[Deprecated]: API Management minimum API version should be set to 2019-12-01 or higher'
        Description   = 'While we continue to recommend using the latest management API versions, configuring a minimum API version no longer affects the security posture of API Management services. Learn more about policy definition deprecation at aka.ms/policydefdeprecation'
        Version       = '1.1.0-deprecated'
        Category      = 'API Management'
        Deprecated    = $true
        PolicyVersion = '1.1.0'
        Mode          = 'Indexed'
    }

    Parameter Effect @{
        Type          = 'string'
        AllowedValues = @('Audit', 'Deny', 'Disabled')
        Default       = 'Disabled'
        DisplayName   = 'Effect'
        Description   = 'Enable or disable the execution of the policy'
    }

    Resource 'Microsoft.ApiManagement/service' {

        When {
            Field apiVersionConstraint.minApiVersion | Must -Not -MatchCase '2019-12-01'
            Field apiVersionConstraint.minApiVersion | Must -Not -MatchCase '202#-##-##-preview'
            Field apiVersionConstraint.minApiVersion | Must -Not -MatchCase '202#-##-##'
        }

        Require 'sku.name is Consumption' {
            Field sku.name | Must -Be 'Consumption'
        }
    }

    Effect (Param Effect)
}

Source: built-in-policies/policyDefinitions/API Management/MinimumApiVersion_AuditDeny.json in Azure/azure-policy, under the MIT licence.