Skip to main content

Isolate Web Application from public internet (App Service)

In this post, we will talk about web endpoint security. Let us start from a basic requirement and see what we need to fulfil it.
The web application hosted inside App Services shall not be public available from internet.

Context
The requirement is simple and clear, but can give us headaches if the team does not cover it from the beginning. Microsoft Azure is offering two options to fulfil it:

  • IP Restrictions
  • App Service integration with VNET
  • VNET with dedicated App Service Environment


IP Restrictions
App services is allowing us to specify a list of IPs that can access our web application. The feature is similar with the IP restriction functionality offered by IIS and can be configured inside web.config.
The difference between this two is the location where these checked is done. Using IP Restrictions the check is done a layer before the IIS. Additional this, the configuration can be done from Azure Portal or using ARM templates. There is no need to modify the configuration file of your application, meaning that all security setups can be done from only one place.
Do not forget that inside the IP Restriction list you can define only whitelist IPs. This means that once you add your first IP in the list, all requests that are coming from different IPs will not be allowed. You have the ability to define a whitelist and not a blacklist. Even if this might sounds strange, in this way you have the ability to know exactly who has access to your system.

This approach does not fulfil 100% our requirements. The web endpoint can still be accessible from internet, but with limited access. Meaning that any IP from internet can try to access our endpoint, but the IP Restriction layer will drop connections from IPs that are not in our whitelist.

VNET combined with ILB
This solution involves restricting public access to our web application by adding it inside a VNET. Once our App Service is inside the VNET we can disable the public load balancer and create an Internal Load Balancer for our App Services.
Without a public load, balancer traffic from public internet cannot reach our web application anymore. We do not have a public IP and a domain name.
Microsoft Azure allows us to connect to a VNET from our own subscription or from another subscription. This part can be done from Azure Portal also, not only from ARM or from PowerShell.
Once we have this connection establish, Azure is creating automatically a Point-to-Site VPN connection between our VNET and our App Service. This connection limits the access to our App Services VMs that are behind it. In this moment your web application can be accessed directly from your VNET.

STOP: In this moment even if you have a connection between your your App Service and VNET, your web application is still accessible from internet. You just have a direct connection to access the resources from VNET directly from App Services, without going outside your network.
This kind of solution does not fulfills your requirements because the web application is still accessible from the internet using DNS or Public IP.

Dedicated App Service Environment
This solution is offering us a dedicated App Service Environment inside our VNET where we have full control, including who can access it. From the beginning expect higher running price, in comparison with a normal App Service instance, but you can manage it completely.
When you create an App Service Environment, you can configure in a such a way to not have a public IP (internet facing endpoint) and only an ILB (Internal Load Balancer) that has a private IP (a VNET IP). This will allow incoming traffic only from your VNET or other networks that are connected using a VNET connection to it.
There are some things that you need to know and have before creating an App Service Environment like domain name, app certificates and DNS management endpoint. This are required from the beginning because all this things are managed internally, inside the VNET.
Using this approach you'll have an environment when you can run your own web application completely isolated from the internet. Access will be done only through the VNET.

Conclusion
Depending on your current needs and what you want to achieve you can use any of this approach. A fast solution can be based on IP Restrictions. For more complex scenarios, where on-premises systems are involved, an integration with VNET might be much better.

Comments

Popular posts from this blog

Windows Docker Containers can make WIN32 API calls, use COM and ASP.NET WebForms

After the last post , I received two interesting questions related to Docker and Windows. People were interested if we do Win32 API calls from a Docker container and if there is support for COM. WIN32 Support To test calls to WIN32 API, let’s try to populate SYSTEM_INFO class. [StructLayout(LayoutKind.Sequential)] public struct SYSTEM_INFO { public uint dwOemId; public uint dwPageSize; public uint lpMinimumApplicationAddress; public uint lpMaximumApplicationAddress; public uint dwActiveProcessorMask; public uint dwNumberOfProcessors; public uint dwProcessorType; public uint dwAllocationGranularity; public uint dwProcessorLevel; public uint dwProcessorRevision; } ... [DllImport("kernel32")] static extern void GetSystemInfo(ref SYSTEM_INFO pSI); ... SYSTEM_INFO pSI = new SYSTEM_INFO(...

How to audit an Azure Cosmos DB

In this post, we will talk about how we can audit an Azure Cosmos DB database. Before jumping into the problem let us define the business requirement: As an Administrator I want to be able to audit all changes that were done to specific collection inside my Azure Cosmos DB. The requirement is simple, but can be a little tricky to implement fully. First of all when you are using Azure Cosmos DB or any other storage solution there are 99% odds that you’ll have more than one system that writes data to it. This means that you have or not have control on the systems that are doing any create/update/delete operations. Solution 1: Diagnostic Logs Cosmos DB allows us activate diagnostics logs and stream the output a storage account for achieving to other systems like Event Hub or Log Analytics. This would allow us to have information related to who, when, what, response code and how the access operation to our Cosmos DB was done. Beside this there is a field that specifies what was th...

Cloud Myths: Cloud is Cheaper (Pill 1 of 5 / Cloud Pills)

Cloud Myths: Cloud is Cheaper (Pill 1 of 5 / Cloud Pills) The idea that moving to the cloud reduces the costs is a common misconception. The cloud infrastructure provides flexibility, scalability, and better CAPEX, but it does not guarantee lower costs without proper optimisation and management of the cloud services and infrastructure. Idle and unused resources, overprovisioning, oversize databases, and unnecessary data transfer can increase running costs. The regional pricing mode, multi-cloud complexity, and cost variety add extra complexity to the cost function. Cloud adoption without a cost governance strategy can result in unexpected expenses. Improper usage, combined with a pay-as-you-go model, can result in a nightmare for business stakeholders who cannot track and manage the monthly costs. Cloud-native services such as AI services, managed databases, and analytics platforms are powerful, provide out-of-the-shelve capabilities, and increase business agility and innovation. H...