Bylaw

Gallery › Automanage › Azure built-in policies

[Preview]: Automanage Configuration Profile Assignment should be Conformant

Converted Policy AuditIfNotExists Disabled Mode Indexed Version 1.0.0-preview Preview

Resources managed by Automanage should have a status of Conformant or ConformantCorrected.

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

Azure Policy JSONConformance_AINE.json · 56 lines
{
  "properties": {
    "policyType": "BuiltIn",
    "mode": "Indexed",
    "displayName": "[Preview]: Automanage Configuration Profile Assignment should be Conformant",
    "description": "Resources managed by Automanage should have a status of Conformant or ConformantCorrected.",
    "metadata": {
      "version": "1.0.0-preview",
      "category": "Automanage",
      "preview": true
    },
    "version": "1.0.0-preview",
    "parameters": {
      "effect": {
        "type": "String",
        "metadata": {
          "displayName": "Effect",
          "description": "Enable or disable the execution of the policy"
        },
        "allowedValues": [
          "AuditIfNotExists",
          "Disabled"
        ],
        "defaultValue": "AuditIfNotExists"
      }
    },
    "policyRule": {
      "if": {
        "field": "type",
        "in": [
          "Microsoft.Compute/virtualMachines",
          "Microsoft.HybridCompute/machines",
          "Microsoft.AzureStackHci/clusters"
        ]
      },
      "then": {
        "effect": "[parameters('effect')]",
        "details": {
          "type": "Microsoft.Automanage/configurationProfileAssignments",
          "existenceCondition": {
            "field": "Microsoft.Automanage/configurationProfileAssignments/status",
            "in": [
              "Conformant",
              "ConformantCorrected"
            ]
          }
        }
      }
    },
    "versions": [
      "1.0.0-PREVIEW"
    ]
  },
  "id": "/providers/Microsoft.Authorization/policyDefinitions/fd4726f4-a5fc-4540-912d-67c96fc992d5",
  "name": "fd4726f4-a5fc-4540-912d-67c96fc992d5"
}
Bylawfd4726f4-a5fc-4540-912d-67c96fc992d5.bylaw.ps1 · 33 lines
# Converted from Conformance_AINE.json by ConvertTo-Bylaw.
Policy 'fd4726f4-a5fc-4540-912d-67c96fc992d5' {

    Properties @{
        DisplayName   = '[Preview]: Automanage Configuration Profile Assignment should be Conformant'
        Description   = 'Resources managed by Automanage should have a status of Conformant or ConformantCorrected.'
        Version       = '1.0.0-preview'
        Category      = 'Automanage'
        Preview       = $true
        PolicyVersion = '1.0.0-preview'
        Mode          = 'Indexed'
    }

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

    Resource * {

        Require 'type is not one of 3 values' {
            Field type | Must -Not -BeIn @('Microsoft.Compute/virtualMachines', 'Microsoft.HybridCompute/machines', 'Microsoft.AzureStackHci/clusters') -IfPresent
        }
    }

    AuditIfNotExists 'Microsoft.Automanage/configurationProfileAssignments' -Effect (Param Effect) {
        Require 'status is one of 2 values' {
            Field status | Must -BeIn @('Conformant', 'ConformantCorrected')
        }
    }
}

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