Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to restrict IP addresses with an Azure App Service / Web App

Does the ipSecurity section in web.config works with Azure App Services?

What are the steps to get a simple IP address blocking (black list) set up with a web app hosted on Azure?

like image 827
Armin Avatar asked Aug 31 '17 21:08

Armin


1 Answers

App Service provides UX for this under Networking > Ip Restrictions

IP Restrictions

From here you can block a specic ip address or a range of address:

Block ip addresses

If you want to do it through web.config you will need to use XDT Transforms

<?xml version="1.0"?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
  <system.webServer>
    <security>
      <ipSecurity xdt:Transform="RemoveAttributes(allowUnlisted)">
        <add ipAddress="204.79.197.200" allowed="true" xdt:Transform="Insert"/>
      </ipSecurity>
    </security>
  </system.webServer>
</configuration>

You can read more about XDT transforms and app service here: https://github.com/projectkudu/kudu/wiki/Xdt-transform-samples

like image 129
Byron Tardif Avatar answered Oct 22 '22 02:10

Byron Tardif