Bylaw

Gallery › Communication › Azure built-in policies

Communication service resource should use a managed identity

Converted Policy Audit Deny Disabled Mode Indexed Version 1.0.0

Assigning a managed identity to your Communication service resource helps ensure secure authentication. This identity is used by this Communication service resource to communicate with other Azure services, like Azure Storage, in a secure way without you having to manage any credentials.

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

Azure Policy JSONCommunication_ManagedIdentity_Audit.json · 58 lines
{
  "properties": {
    "displayName": "Communication service resource should use a managed identity",
    "policyType": "BuiltIn",
    "mode": "Indexed",
    "description": "Assigning a managed identity to your Communication service resource helps ensure secure authentication. This identity is used by this Communication service resource to communicate with other Azure services, like Azure Storage, in a secure way without you having to manage any credentials.",
    "metadata": {
      "version": "1.0.0",
      "category": "Communication"
    },
    "version": "1.0.0",
    "parameters": {
      "effect": {
        "type": "string",
        "defaultValue": "Audit",
        "allowedValues": [
          "Audit",
          "Deny",
          "Disabled"
        ],
        "metadata": {
          "displayName": "Effect",
          "description": "The effect determines what happens when the policy rule is evaluated to match"
        }
      }
    },
    "policyRule": {
      "if": {
        "allOf": [
          {
            "field": "type",
            "equals": "microsoft.communication/communicationservices"
          },
          {
            "anyOf": [
              {
                "field": "identity.type",
                "exists": "false"
              },
              {
                "field": "identity.type",
                "equals": "None"
              }
            ]
          }
        ]
      },
      "then": {
        "effect": "[parameters('effect')]"
      }
    },
    "versions": [
      "1.0.0"
    ]
  },
  "id": "/providers/Microsoft.Authorization/policyDefinitions/bcff6755-335b-484d-b435-d1161db39cdc",
  "name": "bcff6755-335b-484d-b435-d1161db39cdc"
}
Bylawbcff6755-335b-484d-b435-d1161db39cdc.bylaw.ps1 · 33 lines
# Converted from Communication_ManagedIdentity_Audit.json by ConvertTo-Bylaw.
Policy 'bcff6755-335b-484d-b435-d1161db39cdc' {

    Properties @{
        DisplayName   = 'Communication service resource should use a managed identity'
        Description   = 'Assigning a managed identity to your Communication service resource helps ensure secure authentication. This identity is used by this Communication service resource to communicate with other Azure services, like Azure Storage, in a secure way without you having to manage any credentials.'
        Version       = '1.0.0'
        Category      = 'Communication'
        PolicyVersion = '1.0.0'
        Mode          = 'Indexed'
    }

    Parameter Effect @{
        Type          = 'string'
        AllowedValues = @('Audit', 'Deny', 'Disabled')
        Default       = 'Audit'
        DisplayName   = 'Effect'
        Description   = 'The effect determines what happens when the policy rule is evaluated to match'
    }

    Resource 'microsoft.communication/communicationservices' {

        Require 'identity.type exists' {
            Field identity.type | Must -Exist
        }

        Require 'identity.type is not None' {
            Field identity.type | Must -Not -Be 'None' -IfPresent
        }
    }

    Effect (Param Effect)
}

Source: built-in-policies/policyDefinitions/Communication/Communication_ManagedIdentity_Audit.json in Azure/azure-policy, under the MIT licence.