Created
July 12, 2018 18:05
-
-
Save stephenweinrich/f726298c0b6c654e00349db4329464aa to your computer and use it in GitHub Desktop.
app service IP restriction
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Signing into azure with principal account | |
$clientID = "<--client-id-->" | |
$key= "<--secret-key-->" | |
$SecurePassword = $key | ConvertTo-SecureString -AsPlainText -Force | |
$cred = new-object -typename System.Management.Automation.PSCredential ` -argumentlist $clientID, $SecurePassword | |
Add-AzureRmAccount -Credential $cred -Tenant "<--tenant-id-->" -ServicePrincipal | |
# Selecting Subscription | |
Select-AzureRmSubscription "<--subscription-id-->" | |
$ResourceGroupName = "<-resource-group-name->" | |
$WebAppName = "<-web-app-name->" | |
$Resource = Get-AzureRmResource -ResourceGroupName $ResourceGroupName -ResourceType Microsoft.Web/sites/config -ResourceName $WebAppName/web -ApiVersion 2016-08-01 | |
$Properties = $Resource.Properties | |
$Properties.ipSecurityRestrictions = @() | |
# IP Restriction 1 | |
$Restriction = @{} | |
$Restriction.Add("ipAddress","127.0.0.1") | |
$Restriction.Add("subnetMask","255.255.255.255") | |
$Properties.ipSecurityRestrictions += $Restriction | |
# IP Restriction 2 | |
$Restriction = @{} | |
$Restriction.Add("ipAddress","127.0.0.2") | |
$Restriction.Add("subnetMask","255.255.255.255") | |
$Properties.ipSecurityRestrictions += $Restriction | |
Set-AzureRmResource -ResourceGroupName $ResourceGroupName -ResourceType Microsoft.Web/sites/config -ResourceName $WebAppName/web -ApiVersion 2016-08-01 -PropertyObject $Properties -force |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment