Bylaw

Gallery › Machine Learning › Azure built-in policies

Azure Machine Learning compute instances should be recreated to get the latest software updates

Converted Policy Audit Disabled Mode All Version 1.0.3

Ensure Azure Machine Learning compute instances run on the latest available operating system. Security is improved and vulnerabilities reduced by running with the latest security patches. For more information, visit https://aka.ms/azureml-ci-updates/.

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

Azure Policy JSONComputeInstanceUpdates_Audit.json · 53 lines
{
  "properties": {
    "displayName": "Azure Machine Learning compute instances should be recreated to get the latest software updates",
    "description": "Ensure Azure Machine Learning compute instances run on the latest available operating system. Security is improved and vulnerabilities reduced by running with the latest security patches. For more information, visit https://aka.ms/azureml-ci-updates/.",
    "policyType": "BuiltIn",
    "mode": "All",
    "metadata": {
      "version": "1.0.3",
      "category": "Machine Learning"
    },
    "version": "1.0.3",
    "parameters": {
      "effects": {
        "type": "String",
        "metadata": {
          "displayName": "Effect",
          "description": "The effect determines what happens when the policy rule is evaluated to match."
        },
        "allowedValues": [
          "Audit",
          "Disabled"
        ],
        "defaultValue": "Audit"
      }
    },
    "policyRule": {
      "if": {
        "allOf": [
          {
            "field": "type",
            "equals": "Microsoft.MachineLearningServices/workspaces/computes"
          },
          {
            "field": "Microsoft.MachineLearningServices/workspaces/computes/computeType",
            "equals": "ComputeInstance"
          },
          {
            "field": "Microsoft.MachineLearningServices/workspaces/computes/osImageMetadata.isLatestOsImageVersion",
            "equals": "false"
          }
        ]
      },
      "then": {
        "effect": "[parameters('effects')]"
      }
    },
    "versions": [
      "1.0.3"
    ]
  },
  "id": "/providers/Microsoft.Authorization/policyDefinitions/f110a506-2dcb-422e-bcea-d533fc8c35e2",
  "name": "f110a506-2dcb-422e-bcea-d533fc8c35e2"
}
Bylawf110a506-2dcb-422e-bcea-d533fc8c35e2.bylaw.ps1 · 32 lines
# Converted from ComputeInstanceUpdates_Audit.json by ConvertTo-Bylaw.
Policy 'f110a506-2dcb-422e-bcea-d533fc8c35e2' {

    Properties @{
        DisplayName   = 'Azure Machine Learning compute instances should be recreated to get the latest software updates'
        Description   = 'Ensure Azure Machine Learning compute instances run on the latest available operating system. Security is improved and vulnerabilities reduced by running with the latest security patches. For more information, visit https://aka.ms/azureml-ci-updates/.'
        Version       = '1.0.3'
        Category      = 'Machine Learning'
        PolicyVersion = '1.0.3'
        Mode          = 'All'
    }

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

    Resource 'Microsoft.MachineLearningServices/workspaces/computes' {

        When {
            Field computeType | Must -Be 'ComputeInstance'
        }

        Require 'osImageMetadata.isLatestOsImageVersion is not false' {
            Field osImageMetadata.isLatestOsImageVersion | Must -Not -Be 'false' -IfPresent
        }
    }

    Effect (Param Effects)
}

Source: built-in-policies/policyDefinitions/Machine Learning/ComputeInstanceUpdates_Audit.json in Azure/azure-policy, under the MIT licence.