Restricting access to your Azure Web Application

As you may know almost everything that is deployed to Azure is publicly available. As with Azure SQL Database you do not have a firewall available for Azure Web Applications. That means other options need to be used to restrict access to Azure Web Application.

Restrict access by IP

A possible option is to restrict access to your application by IP addresses. The IP addresses can be added as a allowed IP address within the web.config of your application. All other IP addresses will get a 403 Forbidden response from Azure.

<system.webServer>
    <security>
      <ipSecurity allowUnlisted="false">
        <clear />
        <add ipAddress="99.99.99.99" allowed="true" />
      </ipSecurity>
    </security>
</system.webServer>

Restrict access for specific Users

Another option is to restrict access by enabling Authentication on the web application. This can be done for several Authentication Providers like: Azure Active Directory, Google, Facebook, Twitter and Microsoft. The below steps will help you with the configuration of Azure Active Directory as a authentication provider.

  1. In the Azure Portal navigate to the blade of the web application.

Authentication / Authorization

  1. Click on “Authentication/Authorization” and select “On”.
  2. Activating this option will give you several options for Authentication Providers. For know we will select Azure Active Directory.

Azure Active Directory

  1. Because there isn’t a pre-configured application select the “Express” option. This option will register the Enterprise application within Azure Active Directory for us, or let you select a existing.

Configure Authentication

  1. Clicking “Save” on this blade will register the application within Azure Active Directory. From there users can be granted access to the application.
  2. To grant users access to the application open the Azure Active Directory blade within the Azure Portal and select Enterprise Applications.

Enterprise Applications

  1. In the Enterprise Applications blade select “All Applications” to see a list of all applications that are registered within Azure Active Directory.

Enterprise Application List

  1. From this list select the application. This will open the blade of the specific application.
  2. In the blade select “Users and Groups”.

Users for Azure Active Directory Application

  1. In the “Users and Groups” blade all users are shown that are granted access to the application. From here you can a add users to give them access.

Restrict Crawling

When you are developing or testing a site that has anonymous content you probably want the content not to be crawled by spiders or bots because many traffic can come from bots and spiders. Stopping the crawling can be done by placing a file called “robots.txt” at the root of your web application with the following content.

#robots.txt
User-agent: *  
Disallow: / 

Related Posts

Listing Azure Services within a CSV file In some situations you will look into a current Azure Environment and the setup/governance of it and need to migrate or move resources around. The ...
Azure Event Grid with Custom Events As of yesterday (16-8-2017) the public preview of Azure Event Grid is live. Azure Event Grid is a fully managed event routing service. Azure Event Gri...
Removing the Classis Hybrid Connections from Azure (Azure BizTalk Service) As you know the classic hybrid connections that are build upon Azure BizTalk Services are deprecated. These connection will have to be replaced by the...
Configure access to a private network for a Azure App Services On-Premise connections for Azure App Services can be created by using Hybrid Connections. Hybrid connections do not need any development or re-configu...
Extensions and Tips for deploying with Azure Resource Templates Working with Azure Services in different subscriptions means that the Azure Services need to run in different subscriptions. This often occurs when we...
Part 2 – Azure API Application to query the Azure SQL Database This post is the second in a series of three posts and will help you with the creation of identity pass-through authentication from a client applicati...

2 comments

  • What exactly happens when someone try to access the page, does he/she get a popup to enter credentials?

    • Hi Chris,

      Depends on which action you choose:
      – Firewall: Do not know exactly but opening the page from a restricted IP will not open the page.
      – User: All users will be asked to login. Depending on who logins the user will be redirected or get of 403 – access denied

Leave a Reply

Your email address will not be published. Required fields are marked *