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