Skip to content

Commit 38fdb18

Browse files
authored
Merge pull request #47801 from ccompy/ip-restrictions-redo
Ip restrictions redo
2 parents 9cf2dc5 + 5b8cee4 commit 38fdb18

File tree

7 files changed

+50
-12
lines changed

7 files changed

+50
-12
lines changed
Lines changed: 50 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: "Azure App Service IP Restrictions | Microsoft Docs"
33
description: "How to use IP restrictions with Azure App Service"
4-
author: btardif
4+
author: ccompy
55
manager: stefsch
66
editor: ''
77
services: app-service\web
@@ -13,28 +13,66 @@ ms.workload: web
1313
ms.tgt_pltfrm: na
1414
ms.devlang: multiple
1515
ms.topic: article
16-
ms.date: 10/23/2017
17-
ms.author: byvinyal
16+
ms.date: 7/30/2018
17+
ms.author: ccompy
1818

1919
---
2020
# Azure App Service Static IP Restrictions #
2121

22-
IP Restrictions allow you to define a list of IP addresses that are allowed to access your app. The allow list can include individual IP addresses or a range of IP addresses defined by a subnet mask.
22+
IP Restrictions allow you to define a priority ordered allow/deny list of IP addresses that are allowed to access your app. The allow list can include IPv4 and IPv6 addresses. When there are one or more entries, there is then an implicit deny all that exists at the end of the list.
2323

24-
When a request to the app is generated from a client, the IP address is evaluated against the allow list. If the IP address is not in the list, the app replies with an [HTTP 403](https://en.wikipedia.org/wiki/HTTP_403) status code.
24+
The IP Restrictions capability works with all App Service hosted work loads, which include; web apps, api apps, linux apps, linux container apps, and Functions.
2525

26-
IP Restrictions are defined in the web.config that your app consumes at runtime (more exactly, restrictions are inserted in a set of allowed IP addresses in applicationHost.config file, so if you also add a set of allowed IP addresses in web.config file, they will take precedence). Under certain circumstances, some module might be executed before IP restrictions logic in the HTTP pipeline. When this happens, the request fails with a different HTTP error code.
26+
When a request is made to your app, the FROM IP address is evaluated against the IP Restrictions list. If the address is not allowed access based on the rules in the list, the service replies with an [HTTP 403](https://en.wikipedia.org/wiki/HTTP_403) status code.
2727

28-
IP Restrictions are evaluated on the same App Service plan instances assigned to your app.
28+
The IP Restrictions capability is implemented in the App Service front-end roles, which are upstream of the worker hosts where your code runs. IP Restrictions are therefor effectively network ACLs.
29+
30+
![IP restrictions flow](media/app-service-ip-restrictions/ip-restrictions-flow.png)
31+
32+
For a time, the IP Restrictions capability in the portal was a layer on top of the ipSecurity capability in IIS. The current IP Restrictions capability is different. You can still configure ipSecurity within your application web.config but the front-end based IP Restrictions rules will be applied before any traffic reaches IIS.
33+
34+
## Adding and editing IP Restriction rules in the portal ##
2935

3036
To add an IP restriction rule to your app, use the menu to open **Network**>**IP Restrictions** and click on **Configure IP Restrictions**
3137

32-
![IP restrictions](media/app-service-ip-restrictions/ip-restrictions.png)
38+
![App Service networking options](media/app-service-ip-restrictions/ip-restrictions.png)
39+
40+
From the IP Restrictions UI, you can review the list of IP restriction rules defined for your app.
41+
42+
![list IP restrictions](media/app-service-ip-restrictions/ip-restrictions-browse.png)
43+
44+
If your rules were configured as in this image, then your app would only accept traffic from 131.107.159.0/24 and would be denied from any other IP address.
45+
46+
You can click on **[+] Add** to add a new IP restriction rule. Once you add a rule, it will become effective immediately. Rules are enforced in priority order starting from the lowest number and going up. There is an implicit deny all that is in effect once you add even a single rule.
47+
48+
![add an IP restriction rule](media/app-service-ip-restrictions/ip-restrictions-add.png)
49+
50+
IP Address notation must be specified in CIDR notation for both IPv4 and IPv6 addresses. To specify an exact address, you can use something like 1.2.3.4/32 where the first four octets represent your IP address and /32 is the mask. The IPv4 CIDR notation for all addresses is 0.0.0.0/0. To learn more about CIDR notation, you can read [Classless Inter-Domain Routing](https://en.wikipedia.org/wiki/Classless_Inter-Domain_Routing).
51+
52+
You can click on any row to edit an existing IP restriction rule. Edits are effective immediately including changes in priority ordering.
53+
54+
![edit an IP restriction rule](media/app-service-ip-restrictions/ip-restrictions-edit.png)
55+
56+
To delete a rule, click the **...** on your rule and then click **remove**.
57+
58+
![delete IP restriction rule](media/app-service-ip-restrictions/ip-restrictions-delete.png)
59+
60+
## Programmatic manipulation of IP restriction rules ##
61+
62+
There currently is no CLI or PowerShell for the new IP Restrictions capability but the values can be set manually with a PUT operation on the app configuration in Resource Manager. As an example, you can use resources.azure.com and edit the ipSecurityRestrictions block to add the required JSON.
3363

34-
From here, you can review the list of IP restriction rules defined for your app.
64+
The location for this information in Resource Manager is:
3565

36-
![list IP restrictions](media/app-service-ip-restrictions/browse-ip-restrictions.png)
66+
management.azure.com/subscriptions/**subscription ID**/resourceGroups/**resource groups**/providers/Microsoft.Web/sites/**web app name**/config/web?api-version=2018-02-01
3767

38-
You can click on **[+] Add** to add a new IP restriction rule.
68+
The JSON syntax for the earlier example is:
3969

40-
![add IP restrictions](media/app-service-ip-restrictions/add-ip-restrictions.png)
70+
"ipSecurityRestrictions": [
71+
{
72+
"ipAddress": "131.107.159.0/24",
73+
"action": "Allow",
74+
"tag": "Default",
75+
"priority": 100,
76+
"name": "allowed access"
77+
}
78+
],
15.8 KB
Loading
40.2 KB
Loading
44.3 KB
Loading
11.7 KB
Loading
25.2 KB
Loading
-41.7 KB
Loading

0 commit comments

Comments
 (0)