Help with creating Azure policy to deny storage account creation if no private link is configured

Guo, Jianning 40 Reputation points
2025-06-16T15:09:50.4666667+00:00

I have trying to create an Azure enforcement policy which will deny storage account to be created if a private endpoint is not configured for the account. I have the following policy rule:

    "policyRule": {
      "if": {
        "allOf": [
          {
            "field": "type",
            "equals": "Microsoft.Storage/storageAccounts"
          },
          {
            "field": "Microsoft.Storage/storageAccounts/privateEndpointConnections",
            "exists": "false"
          }
        ]
      },
      "then": {
        "effect": "[parameters('effect')]"
      }
    },

Note: the effect is set to "deny".

However, when I configured the private endpoint during the storage account creation, the policy prevents the account creation.

I have also tried the following condition instead of using "exists", the policy still denies the creation of the storage account.

{

"field": "Microsoft.Storage/storageAccounts/privateEndpointConnections",

"equals": ""

}

Any idea how should I modify my policy?

Thanks

Azure Policy
Azure Policy
An Azure service that is used to implement corporate governance and standards at scale for Azure resources.
1,014 questions
0 comments No comments
{count} votes

Accepted answer
  1. Ashok Gandhi Kotnana 10,115 Reputation points Microsoft External Staff Moderator
    2025-06-16T15:22:59.08+00:00

    @Guo, Jianning

    Please use this policy definition, this should work.

    {
      "properties": {
        "displayName": "Deny Storage Accounts without private access",
        "policyType": "Custom",
        "mode": "All",
        "description": "Deny creation of storage accounts if public network access is not disabled (i.e., only private endpoint access is allowed).",
        "metadata": {
          "version": "1.0.0",
          "category": "Storage"
        },
        "parameters": {},
        "policyRule": {
          "if": {
            "allOf": [
              {
                "field": "type",
                "equals": "Microsoft.Storage/storageAccounts"
              },
              {
                "field": "Microsoft.Storage/storageAccounts/publicNetworkAccess",
                "notequals": "Disabled"
              }
            ]
          },
          "then": {
            "effect": "deny"
          }
        }
      }
    }
     
    

    Artifact:

    User's image

    Hope this helps!

    let us know if any help, we will always help as you needed.!

    User's image

    Please do not forget to "Accept the answer” and upvote it wherever the information provided helps you, this can be beneficial to other community members.it would be greatly appreciated and helpful to others.

    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Guo, Jianning 40 Reputation points
    2025-06-16T15:32:24.33+00:00

    I do have disable publicnetworkaccess policy in place. I was trying to see if I could also make sure private endpoint is configured during storage account creation.


Your answer

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