Bylaw

Gallery › Data Factory › Azure built-in policies

Azure Data Factory integration runtime should have a limit for number of cores

Converted Policy Audit Deny Disabled Mode All Version 1.0.0

To manage your resources and costs, limit the number of cores for an integration runtime.

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

Azure Policy JSONIR_Core_Count_Exceeds_Audit.json · 66 lines
{
  "properties": {
    "displayName": "Azure Data Factory integration runtime should have a limit for number of cores",
    "policyType": "BuiltIn",
    "mode": "All",
    "description": "To manage your resources and costs, limit the number of cores for an integration runtime.",
    "metadata": {
      "version": "1.0.0",
      "category": "Data Factory"
    },
    "version": "1.0.0",
    "parameters": {
      "effect": {
        "type": "String",
        "metadata": {
          "displayName": "Effect",
          "description": "Enable or disable the execution of the policy"
        },
        "allowedValues": [
          "Audit",
          "Deny",
          "Disabled"
        ],
        "defaultValue": "Audit"
      },
      "maxCores": {
        "type": "Integer",
        "metadata": {
          "displayName": "Allowed max number of cores",
          "description": "The max number of cores allowed for dataflow."
        },
        "defaultValue": 32
      }
    },
    "policyRule": {
      "if": {
        "allOf": [
          {
            "field": "type",
            "equals": "Microsoft.DataFactory/factories/integrationRuntimes"
          },
          {
            "field": "Microsoft.DataFactory/factories/integrationruntimes/type",
            "equals": "Managed"
          },
          {
            "field": "Microsoft.DataFactory/factories/integrationRuntimes/Managed.typeProperties.computeProperties.dataFlowProperties.coreCount",
            "exists": "true"
          },
          {
            "field": "Microsoft.DataFactory/factories/integrationRuntimes/Managed.typeProperties.computeProperties.dataFlowProperties.coreCount",
            "greater": "[parameters('maxCores')]"
          }
        ]
      },
      "then": {
        "effect": "[parameters('effect')]"
      }
    },
    "versions": [
      "1.0.0"
    ]
  },
  "id": "/providers/Microsoft.Authorization/policyDefinitions/85bb39b5-2f66-49f8-9306-77da3ac5130f",
  "name": "85bb39b5-2f66-49f8-9306-77da3ac5130f"
}
Bylaw85bb39b5-2f66-49f8-9306-77da3ac5130f.bylaw.ps1 · 39 lines
# Converted from IR_Core_Count_Exceeds_Audit.json by ConvertTo-Bylaw.
Policy '85bb39b5-2f66-49f8-9306-77da3ac5130f' {

    Properties @{
        DisplayName   = 'Azure Data Factory integration runtime should have a limit for number of cores'
        Description   = 'To manage your resources and costs, limit the number of cores for an integration runtime.'
        Version       = '1.0.0'
        Category      = 'Data Factory'
        PolicyVersion = '1.0.0'
        Mode          = 'All'
    }

    Parameter Effect @{
        AllowedValues = @('Audit', 'Deny', 'Disabled')
        Default       = 'Audit'
        DisplayName   = 'Effect'
        Description   = 'Enable or disable the execution of the policy'
    }
    Parameter MaxCores @{
        Type        = 'Integer'
        Default     = 32
        DisplayName = 'Allowed max number of cores'
        Description = 'The max number of cores allowed for dataflow.'
    }

    Resource 'Microsoft.DataFactory/factories/integrationRuntimes' {

        When {
            Field 'Microsoft.DataFactory/factories/integrationruntimes/type' | Must -Be 'Managed'
            Field Managed.typeProperties.computeProperties.dataFlowProperties.coreCount | Must -Exist
        }

        Require 'Managed.typeProperties.computeProperties.dataFlowProperties.coreCount is as required' {
            Field Managed.typeProperties.computeProperties.dataFlowProperties.coreCount | Must -BeLessOrEqual (Param MaxCores) -IfPresent
        }
    }

    Effect (Param Effect)
}

Source: built-in-policies/policyDefinitions/Data Factory/IR_Core_Count_Exceeds_Audit.json in Azure/azure-policy, under the MIT licence.