How to enable/disable the publicNetworkAccess of App Service and what is the meaning of its default value 'null'

Ethan Hou 61 Reputation points Microsoft Employee
2022-01-05T12:43:28.29+00:00

Hi, I'm trying to create a policy to monitor some properties of Azure App service that enables publicNetworkAccess. After research I didn't find a way to setup this property. From the document https://learn.microsoft.com/en-us/azure/templates/microsoft.web/sites?tabs=bicep it is clearly that the property is exist and the default value is null, but it doesn't make sense to me, what is the meaning of 'null'? Because from my perspective the publicNetworkAccess is either enabled or disabled. Anyone can help? Thanks

Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
8,930 questions
{count} votes

Accepted answer
  1. Andriy Bilous 11,821 Reputation points MVP Volunteer Moderator
    2022-01-05T15:06:35.65+00:00

    Hello anonymous user

    You are right Azure App service has option publicNetworkAccess that has default option null in Resource Explorer.
    Resource Explorer treat null as if the property isn't present, no publicNetworkAccess option was set in Bicep or ARM template. In this case publicNetworkAccess is not active
    https://learn.microsoft.com/en-us/azure/azure-resource-manager/templates/template-expressions#null-values
    162467-image.png

    You can use existing policies that will prevent App Service Apps to have access from the Internet.

    • Configure App Services to disable public network access
    • App Services should disable public network access

    162556-image.png


2 additional answers

Sort by: Most helpful
  1. Kris 26 Reputation points
    2023-07-06T06:21:46.8433333+00:00

    When null, it is actually conditional. If there is no private endpoint, then it allows public access. If there is a private endpoint to the web app, then public access is denied. It may be beneficial for you to explicitly set this to Enabled or Disabled to ensure you get a consistent and expected action regardless of private endpoints.

    1 person found this answer helpful.
    0 comments No comments

  2. Ye Zhu 1 Reputation point Microsoft Employee
    2022-01-06T06:22:39.69+00:00

    Hi @Andriy Bilous the publicNetworkAccess in this doc https://learn.microsoft.com/en-us/azure/templates/microsoft.web/sites?tabs=bicep means "Property to allow or block all public traffic.". Could you please tell it allow or block all public traffic when this property is null?


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.