Bylaw

Gallery › Dev Test Labs › Azure Community Policy

Allowed DevTestLabs Repo URL prefix

Converted Policy Audit Deny Disabled Mode All Version 1.0.0

need to add description

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

Azure Policy JSONazurepolicy.json · 55 lines
{
  "name": "aca94a15-a131-4a06-ab0e-89f57e28cc5c",
  "type": "Microsoft.Authorization/policyDefinitions",
  "properties": {
    "displayName": "Allowed DevTestLabs Repo URL prefix",
    "description": "need to add description",
    "metadata": {
      "category": "Dev Test Labs",
      "updatedBy": null,
      "updatedOn": null,
      "version": "1.0.0"
    },
    "mode": "All",
    "parameters": {
      "URI": {
        "type": "String",
        "metadata": {
          "displayName": "URI",
          "description": "Allowed URL for the like operator"
        },
        "defaultValue": "https://dev.azure.com/WorkingRemotely/*"
      },
      "effect": {
        "type": "String",
        "metadata": {
          "displayName": "Effect",
          "description": "Deny, Audit or Disabled the execution of the Policy"
        },
        "allowedValues": [
          "Deny",
          "Audit",
          "Disabled"
        ],
        "defaultValue": "Audit"
      }
    },
    "policyRule": {
      "if": {
        "allOf": [
          {
            "field": "type",
            "equals": "Microsoft.DevTestLab/labs/artifactsources"
          },
          {
            "field": "Microsoft.DevTestLab/labs/artifactSources/uri",
            "notLike": "[parameters('URI')]"
          }
        ]
      },
      "then": {
        "effect": "[parameters('effect')]"
      }
    }
  }
}
Bylawaca94a15-a131-4a06-ab0e-89f57e28cc5c.bylaw.ps1 · 33 lines
# Converted from azurepolicy.json by ConvertTo-Bylaw.
Policy 'aca94a15-a131-4a06-ab0e-89f57e28cc5c' {

    Properties @{
        DisplayName = 'Allowed DevTestLabs Repo URL prefix'
        Description = 'need to add description'
        Category    = 'Dev Test Labs'
        Version     = '1.0.0'
        Mode        = 'All'
    }

    Parameter URI @{
        Default     = 'https://dev.azure.com/WorkingRemotely/*'
        DisplayName = 'URI'
        Description = 'Allowed URL for the like operator'
        JsonName    = 'URI'
    }
    Parameter Effect @{
        AllowedValues = @('Deny', 'Audit', 'Disabled')
        Default       = 'Audit'
        DisplayName   = 'Effect'
        Description   = 'Deny, Audit or Disabled the execution of the Policy'
    }

    Resource 'Microsoft.DevTestLab/labs/artifactsources' {

        Require 'uri is like the URI parameter' {
            Field uri | Must -BeLike (Param URI)
        }
    }

    Effect (Param Effect)
}

Source: policyDefinitions/Dev Test Labs/allowed-devtestlabs-repo-url-prefix/azurepolicy.json in Azure/Community-Policy, under the MIT licence.