With the powershell scripts underneath you can easily close and open traffic towards your azure app services. Note: by adjusting the resource name variable you can add appsettings to your staging slot as well.
[expander_maker id="1” more="Script: open to the world” less="Collapse”] ### Open to the world ### Write-Host “Open all traffic to app service” $resourceGroupName = ‘TOBEFILLED’ $resourceName = ‘YOURAPPNAMEHERE’ + ‘/web’ $r = Get-AzureRmResource -ResourceGroupName $resourceGroupName -ResourceType Microsoft.Web/sites/config -ResourceName $resourceName -ApiVersion 2016-08-01
$p = $r.Properties $empty = @() $p.ipSecurityRestrictions = $empty
Set-AzureRmResource -ResourceGroupName $resourceGroupName -ResourceType Microsoft.Web/sites/config -ResourceName $resourceName -ApiVersion 2016-08-01 -PropertyObject $p [/expander_maker]
[expander_maker id="1” more="Script: set IP restrictions” less="Collapse”] ### Open to specified IP addresses ### Write-Host “Block all traffic to app service except specified ips” $resourceGroupName = ‘TOBEFILLED’ $resourceName = ‘YOURAPPNAMEHERE’ + ‘/web’ $r = Get-AzureRmResource -ResourceGroupName $resourceGroupName -ResourceType Microsoft.Web/sites/config -ResourceName $resourceName -ApiVersion 2016-08-01
$p = $r.Properties $p.ipSecurityRestrictions = @() $restriction = @{} $restriction.Add(“ipAddress”,“YOURIPADDRESSHERE”) $restriction.Add(“subnetMask”,“255.255.0.0”) $p.ipSecurityRestrictions+= $restriction
Set-AzureRmResource -ResourceGroupName $resourceGroupName -ResourceType Microsoft.Web/sites/config -ResourceName $resourceName -ApiVersion 2016-08-01 -PropertyObject $p [/expander_maker]