Disable/enable the public network access on a webapp

Nibbler 656 Reputation points
2023-08-31T18:35:16.2166667+00:00

Hello Q&A,

Is it possible to disable/enable the public network access on a azure webapp with PowerShell?

PowerShell
PowerShell
A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
2,765 questions
Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
8,213 questions
0 comments No comments
{count} votes

Accepted answer
  1. TP 102K Reputation points
    2023-08-31T19:33:31.5933333+00:00

    Hi,

    Below sample code will disable public network access:

    $webapp = Get-AzResource -Name mywebapp -ResourceGroupName myresourcegroup -ResourceType Microsoft.Web/sites
    $webapp.Properties.publicNetworkAccess = "Disabled"
    $webapp|Set-AzResource -Force
    
    

    Below sample code will enable public network access:

    $webapp = Get-AzResource -Name mywebapp -ResourceGroupName myresourcegroup -ResourceType Microsoft.Web/sites
    $webapp.Properties.publicNetworkAccess = "Enabled"
    $webapp|Set-AzResource -Force
    

    Please click Accept Answer if the above was helpful.

    Thanks.

    -TP


0 additional answers

Sort by: Most helpful

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.