Bylaw

Gallery › App Service › Azure built-in policies

[Deprecated]: Ensure that Register with Azure Active Directory is enabled on API app

Converted Policy AuditIfNotExists Disabled Mode Indexed Version 1.0.0-deprecated Deprecated

This policy is a duplicate of the respective Managed Identity policies. Please use /providers/Microsoft.Authorization/policyDefinitions/c4d441f8-f9d9-4a9e-9cef-e82117cb3ee instead.

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

Azure Policy JSONApiApp_Audit_AD_Enabled.json · 58 lines
{
  "properties": {
    "displayName": "[Deprecated]: Ensure that Register with Azure Active Directory is enabled on API app",
    "policyType": "BuiltIn",
    "mode": "Indexed",
    "description": "This policy is a duplicate of the respective Managed Identity policies. Please use /providers/Microsoft.Authorization/policyDefinitions/c4d441f8-f9d9-4a9e-9cef-e82117cb3ee instead.",
    "metadata": {
      "version": "1.0.0-deprecated",
      "category": "App Service",
      "deprecated": true
    },
    "version": "1.0.0",
    "parameters": {
      "effect": {
        "type": "string",
        "defaultValue": "AuditIfNotExists",
        "allowedValues": [
          "AuditIfNotExists",
          "Disabled"
        ],
        "metadata": {
          "displayName": "Effect",
          "description": "Enable or disable the execution of the policy"
        }
      }
    },
    "policyRule": {
      "if": {
        "allOf": [
          {
            "field": "type",
            "equals": "Microsoft.Web/sites"
          },
          {
            "field": "kind",
            "like": "*api"
          }
        ]
      },
      "then": {
        "effect": "[parameters('effect')]",
        "details": {
          "type": "Microsoft.Web/sites/config",
          "name": "web",
          "existenceCondition": {
            "field": "Microsoft.Web/sites/config/web.managedServiceIdentityId",
            "exists": "true"
          }
        }
      }
    },
    "versions": [
      "1.0.0"
    ]
  },
  "id": "/providers/Microsoft.Authorization/policyDefinitions/86d97760-d216-4d81-a3ad-163087b2b6c3",
  "name": "86d97760-d216-4d81-a3ad-163087b2b6c3"
}
Bylaw86d97760-d216-4d81-a3ad-163087b2b6c3.bylaw.ps1 · 34 lines
# Converted from ApiApp_Audit_AD_Enabled.json by ConvertTo-Bylaw.
Policy '86d97760-d216-4d81-a3ad-163087b2b6c3' {

    Properties @{
        DisplayName   = '[Deprecated]: Ensure that Register with Azure Active Directory is enabled on API app'
        Description   = 'This policy is a duplicate of the respective Managed Identity policies. Please use /providers/Microsoft.Authorization/policyDefinitions/c4d441f8-f9d9-4a9e-9cef-e82117cb3ee instead.'
        Version       = '1.0.0-deprecated'
        Category      = 'App Service'
        Deprecated    = $true
        PolicyVersion = '1.0.0'
        Mode          = 'Indexed'
    }

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

    Resource 'Microsoft.Web/sites' {

        Require 'kind is not like *api' {
            Field kind | Must -Not -BeLike '*api' -IfPresent
        }
    }

    AuditIfNotExists 'Microsoft.Web/sites/config' -Name 'web' -Effect (Param Effect) {
        Require 'web.managedServiceIdentityId exists' {
            Field web.managedServiceIdentityId | Must -Exist
        }
    }
}

Source: built-in-policies/policyDefinitions/App Service/ApiApp_Audit_AD_Enabled.json in Azure/azure-policy, under the MIT licence.