azure policy - Force administrators to use standard plan and not premium

19 views Asked by At

Hi Im trying to write up a Policy in Azure to prevent admins to create new app services using any premium_plan and only allow 'standard plans' to be used.

Any help would be great.

App service plan = Standard

Here is what i current have but dont believe it wright:

{
  "properties": {
    "displayName": "App Service Environment should be provisioned with latest versions",
    "policyType": "BuiltIn",
    "mode": "Indexed",
    "description": "Only allow App Service Environment version 2 or version 3 to be provisioned. Older versions of App Service Environment require manual management of Azure resources and have greater scaling limitations.",
    "metadata": {
      "version": "1.0.0",
      "category": "App Service"
    },
    "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"
      }
    },
    "policyRule": {
      "if": {
        "allOf": [
          {
            "field": "type",
            "equals": "Microsoft.Web/hostingEnvironments"
          },
          {
            "field": "kind",
            "equals": "ASEV1"
          }
        ]
      },
      "then": {
        "effect": "[parameters('effect')]"
      }
    },
    "versions": [
      "1.0.0"
    ]
  },
  "id": "/providers/Microsoft.Authorization/policyDefinitions/eb4d34ab-0929-491c-bbf3-61e13da19f9a",
  "type": "Microsoft.Authorization/policyDefinitions",
  "name": "eb4d34ab-0929-491c-bbf3-61e13da19f9a"
}

Can someone pelase correct the and let me know

1

There are 1 answers

0
Niclas On

This policy definition will deploy. But I am not sure it will do what you want. ASEv1 and ASEv2 is on deprecation path.

{
  "properties": {
    "displayName": "App Service Environment should be provisioned with latest versions",
    "policyType": "Custom",
    "mode": "Indexed",
    "description": "Only allow App Service Environment version 2 or version 3 to be provisioned. Older versions of App Service Environment require manual management of Azure resources and have greater scaling limitations.",
    "metadata": {
      "version": "1.0.0",
      "category": "App Service"
    },
    "parameters": {
      "effect": {
        "type": "String",
        "metadata": {
          "displayName": "Effect",
          "description": "Enable or disable the execution of the policy"
        },
        "allowedValues": [
          "Audit",
          "Deny",
          "Disabled"
        ],
        "defaultValue": "Audit"
      }
    },
    "policyRule": {
      "if": {
        "allOf": [
          {
            "field": "type",
            "equals": "Microsoft.Web/hostingEnvironments"
          },
          {
            "field": "kind",
            "equals": "ASEV1"
          }
        ]
      },
      "then": {
        "effect": "[parameters('effect')]"
      }
    }
  }
}

You might want to just replace the kind with this to block v1 and v2.

  {
    "field": "kind",
    "notEquals": "ASEV3"
  }