Deny policy

moti jirata 25 Reputation points
2026-05-28T11:15:45.3233333+00:00

Can you give me an example for a deny policy for webapps that doesnt have the latest minTls version?

Azure Application Gateway
Azure Application Gateway

An Azure service that provides a platform-managed, scalable, and highly available application delivery controller as a service.


3 answers

Sort by: Most helpful
  1. Bharath Y P 10,355 Reputation points Microsoft External Staff Moderator
    2026-06-01T02:08:19.4766667+00:00

    Hello moti jirata! To give you the right “deny” policy example, I need a bit more context. Could you help me clarify:

    1. Which resource are you targeting?
      • Azure App Service (Web App) TLS setting?
      • Application Gateway WAF TLS policy?
      • Another service altogether?
    2. How are you enforcing it today?
      • Via Azure Policy definitions?
      • Custom WAF rules on App Gateway?
      • ARM template or Bicep?
    3. What exactly do you consider “latest” TLS?
      • TLS 1.2 as the minimum?
      • TLS 1.3 requirement?
    4. Do you already have an existing policy that you want to modify, or should we craft one from scratch?

    Once I know those details, I can whip up a precise deny-rule example for you!

    Was this answer helpful?


  2. Jerald Felix 17,640 Reputation points Volunteer Moderator
    2026-05-28T11:19:26.3566667+00:00

    Hello moti jirata,

    Greetings! Thanks for raising this question in Q&A forum.

    The Deny effect in Azure Policy is used to block resource requests that don't comply with your defined governance standards. When a resource creation or update request matches a deny policy, it is blocked before it even reaches the Resource Provider and returns a 403 (Forbidden) error.

    Why the Deny Policy Triggers

    Azure Policy evaluates every resource create/update request. The deny effect is processed before audit, so any non-compliant resource is blocked immediately. Common reasons this happens:

    • The resource doesn't meet location restrictions (e.g., only eastus is allowed)

    The resource type isn't permitted in your subscription or resource group

    Required tags are missing on the resource

    SKU or pricing tier doesn't match the policy rules

    How Deny Policy Evaluation Works

    Azure Policy uses a cumulative most restrictive model — if multiple policies apply to the same resource and both have a deny effect, the resource is blocked regardless of scope. The evaluation order is:

    disabled (checked first — skips evaluation if disabled)

    append and modify (can alter the request)

    deny (blocks the request if matched)

    audit (logs non-compliance)

    auditIfNotExists / deployIfNotExists (evaluated last)

    How to Fix or Bypass a Deny Policy

    Check which policy is blocking: Go to Azure Portal → Resource Group / Subscription → Policies → Compliance and look for non-compliant assignments

    Add an exclusion: If a specific resource or resource group should be exempt, add it as an exclusion in the policy assignment scope

    Update the policy rule: If the policy condition is too restrictive, modify the if condition in the policy definition to narrow its scope

    Use the correct values: Ensure your resource properties (location, SKU, tags) align with what the policy expects

    Deny vs. DenyAction

    These are two different effects — don't confuse them:

    Effect Blocks Use Case
    deny Create / Update requests Enforce standards on resource configuration
    deny Create / Update requests Enforce standards on resource configuration
    denyAction Delete requests Protect critical resources from accidental deletion

    If you share the specific error message or the policy rule that is blocking you, I can help narrow down the exact fix!

    If this answer helps you kindly accept the answer which will help others who have similar questions.

    Best Regards,

    Jerald Felix.

    Was this answer helpful?

    0 comments No comments

  3. AI answer

    2026-05-28T11:16:04.8833333+00:00

    Below is an example Azure Policy definition that denies web apps whose minimum TLS version is not the latest (for example, anything less than 1.2). Adjust the field and equals values to match the specific resource type and latest TLS version used in the environment.

    {
      "properties": {
        "displayName": "Deny web apps that do not use latest minimum TLS version",
        "policyType": "Custom",
        "mode": "All",
        "description": "Denies creation or update of web apps where minTlsVersion is less than the required version.",
        "metadata": {
          "category": "App Service"
        },
        "parameters": {
          "requiredMinTlsVersion": {
            "type": "String",
            "metadata": {
              "displayName": "Required minimum TLS version",
              "description": "Minimum TLS version that web apps must use."
            },
            "allowedValues": [
              "1.0",
              "1.1",
              "1.2",
              "1.3"
            ],
            "defaultValue": "1.2"
          }
        },
        "policyRule": {
          "if": {
            "allOf": [
              {
                "field": "type",
                "equals": "Microsoft.Web/sites"
              },
              {
                "field": "Microsoft.Web/sites/config/minTlsVersion",
                "notEquals": "[parameters('requiredMinTlsVersion')]"
              }
            ]
          },
          "then": {
            "effect": "deny"
          }
        }
      }
    }
    

    This follows the same pattern as the minimum TLS enforcement examples in the context: a deny effect that blocks create/update operations when the configured minimum TLS version is lower than the required one.


    References:

    AI-generated content may be incorrect. Read our transparency notes for more information.

    Was this answer helpful?

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.