Skip to main content

Blue and Red Network Topology in Azure (Virtual Network without internet access)

When you create the infrastructure of a system, it is common to have two separate network. One that has access to public internet where front-end system are hosted (web pages, web services). Another network is without internet access, more protected from intruders. In this kind of secure network backend services are hosted, databases and other private services.

In this post we will do the following references:

  • Blue Network - The network that had direct access to internet
  • Red Network - The network that doesn't have access to internet and can be accessed only from internal systems

As we can see above, from Public Internet a requests goes to the front-end layer (Blue Network). Systems that runs in the Blue Network can make a direct call to the Red Network systems directly. But a request cannot goes from Public Internet directly to the Red Network. Red Network configuration (e.g. routers, firewalls) don't allow requests from Public Internet.

Can we have such a network topology on Azure?
You might say no, because the first expectation is that all services and system that run in Azure are public available from internet. Don't be surprise if the response is YES, you can have such a network topology in Azure.
We can have as many Red Networks as we want, isolated from public internet, with machines that talk only with other machines from the network. The number of network layers that we want to create is unlimited, we can have 2 as above, but we can have 3, 4 or even 100.

Is this possible? How you can configure it and make changes?
Even if it might sounds strange at the beginning, this is possible to do. Each Virtual Networks created in Azure has some basic characteristics that allows a network to be 100% isolated from the rest of the network, even if it is running over the same infrastructure.

Virtual Networks characteristics that enable us to have isolated networks

  1. Traffic Isolation - By default two virtual networks cannot communicate between each other. Packages are visible only in the same virtual network. It means that by default only VMs from the same networks can exchange data
  2. IP Forwarding and User Defined Routes (UDR) - Support for different virtual appliances (e.g IDS/IPS, firewalls) that route traffic between virtual networks and to the internet. 
  3. Network Security Groups (NGS) - Allows us to define ACLs rules that control the communication level at VMs, network interface and virtual subnets. In this way there is full control on who can communicate with what.
  4. Cross-premises connectivity - A virtual network can be configured in a such a way to be able to communicate with another virtual network or with an on-premises network using mechanism like Azure VPN, Express Router, S2S VPN and so on.
  5. Multi-tier topology - By allocated subnets and having separate address groups based on our system model we can define inside a virtual network different communication policies. 
Using this mechanism, a virtual network can be protected from public internet. All traffic that comes from other virtual network or from public internet needs to go through firewalls, VPNs devices, NGS and UDR rules that will allow only allowed traffic to reach the virtual network systems. 
The most important layer of virtual network is so called internet facing layer. This layer consist of:
  • Public IP addresses
  • Virtual IPs (VIPs)
  • Service endpoints
  • Subnet that has direct access to internet
  • Inbound traffic to virtual network
  • Outbound traffic that goes from virtual network to public internet
, where content is filtered by firewalls, UDR, NGS and other virtual appliances that can drop packages that are not allowed to go in/out of a virtual network or a subnet.

How can we create a Virtual Network without access from internet?
To have a more concrete example, we will go on the previous example where we had the Blue and Red Network, where Red Network didn't had direct access to internet. Red Networks allows traffic only from Red Network of from Blue Network.
To be able to isolate Red Network we  can use Network Security Rules, by defining the following rules:

  1. Allow traffic on port 53 (DNS traffic canonical port)
  2. Allow traffic on port 3389 (RDP). If we don't want remote access on VMs from Red Network from internet we should not add this rule.
  3. All traffic from internet our Firewall is allowed.
  4. All traffic from specific Blue Network VMs to specific Red Network VMs is allowed.
  5. All traffic from internet to Blue and Red Network is denied (rule 3 will apply before and will redirect traffic to firewall).
  6. All traffic from any Blue Network to Red Network is denied.
  7. All traffic from Red Network to Blue Network is allowed.
  8. All traffic from Red Network is denied.  
Remember that rules in NGS are checked based on their order. If rule 4 applies, then no check for rule 5-8 will be done for the same package and so on. If you want allow all traffic from Blue to Red Network to be allowed, then remove rule 6 and change rule 4 in "All traffic from Blue Network VMs to Red Network VMs is allowed"
More complex rules can be defined, where we can restrict ports ranges or even what VMs from specific networks can be accessed. 

Remarks: If we want RDP access on in Red Network. but without open RDP ports to the public internet we can configure a Point to Site VPN or a Site to Site VPN. In this way only from our local machined RDPs connection would be allowed or from our S2S network.

Additional to NGS rules, we need to define firewall rules at Blue Network level to redirect traffic from port 80, 443 to our portal and web services. We might want to redirect portal from a specific CNAME to our portal and portal another CNAME to our web services endpoint. For this we need a firewall as network virtual appliance. 

What are Virtual Appliance?
A virtual appliance is just another VM in your VNet that runs a software based appliance function, such as firewall, WAN optimization, or intrusion detection. You can create a route in Azure to route your VNet traffic through a virtual appliance to use its capabilities. For instance, NSGs can be used to provide security on your VNet. However, NSGs provide layer 4 Access Control List (ACL) to incoming and outgoing packets. If you want to use a layer 7 security model, you need to use a firewall appliance.

(Virtual) Network Appliance in Azure world is represented in general by VMs that allows us to to have virtual appliance like firewalls from 3rd parties vendors or as services like Azure VPN Gateway or Azure Application Gateway. 
Most of the Network Appliance that are provided by Microsoft runs on top of custom hardware, in contrast with the one offered by 3rd parties that are running on VMs. From 3rd parties vendors, the most common are firewalls, when people prefer that all traffic that is coming from internet to go through a firewall (with custom rules and filters) before hitting internal endpoints. 

As we seen above, Azure allows us to define virtual networks that are completely isolated from public internet. 
Even if the job is easy I highly recommend to have a infrastructure guy to review the topology, architecture and rules that needs to be defined. For example rule 6 - "All traffic from any Blue Network to Red Network is denied." was defined for the cases when somebody get access to Blue Network but not the machines that can communicate from/to Blue/Red Network. 


  1. If you want to use features such as Azure backup, monitoring, etc, the Red Network VM's will need to access the Azure Public DC's, whether that is by proxy or firewall rule (SSL TCP 443 primarily, but some HTTP TCP 80 too). There are over 600 networks defined for these public DC's, so using a UDR is not realistically possible.
    Just something to consider when architecting the infrastructure

    1. This is correct. 100% valid.
      When you start to use features of Azure like Azure Backup or other services clients need to take into account that they need to open/relay there rules because external access is required.


Post a Comment

Popular posts from this blog

ADO.NET provider with invariant name 'System.Data.SqlClient' could not be loaded

Today blog post will be started with the following error when running DB tests on the CI machine:
threw exception: System.InvalidOperationException: The Entity Framework provider type 'System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer' registered in the application config file for the ADO.NET provider with invariant name 'System.Data.SqlClient' could not be loaded. Make sure that the assembly-qualified name is used and that the assembly is available to the running application. See for more information. at System.Data.Entity.Infrastructure.DependencyResolution.ProviderServicesFactory.GetInstance(String providerTypeName, String providerInvariantName) This error happened only on the Continuous Integration machine. On the devs machines, everything has fine. The classic problem – on my machine it’s working. The CI has the following configuration:

TeamCity.NET 4.51EF 6.0.2VS2013
It seems that there …

GET call of REST API that contains '/'-slash character in the value of a parameter

Let’s assume that we have the following scenario: I have a public HTTP endpoint and I need to post some content using GET command. One of the parameters contains special characters like “\” and “/”. If the endpoint is an ApiController than you may have problems if you encode the parameter using the http encoder.
using (var httpClient = new HttpClient()) { httpClient.BaseAddress = baseUrl; Task<HttpResponseMessage> response = httpClient.GetAsync(string.Format("api/foo/{0}", "qwert/qwerqwer"))); response.Wait(); response.Result.EnsureSuccessStatusCode(); } One possible solution would be to encode the query parameter using UrlTokenEncode method of HttpServerUtility class and GetBytes method ofUTF8. In this way you would get the array of bytes of the parameter and encode them as a url token.
The following code show to you how you could write the encode and decode methods.

Entity Framework (EF) TransactionScope vs Database.BeginTransaction

In today blog post we will talk a little about a new feature that is available on EF6+ related to Transactions.
Until now, when we had to use transaction we used ‘TransactionScope’. It works great and I would say that is something that is now in our blood.
using (var scope = new TransactionScope(TransactionScopeOption.Required)) { using (SqlConnection conn = new SqlConnection("...")) { conn.Open(); SqlCommand sqlCommand = new SqlCommand(); sqlCommand.Connection = conn; sqlCommand.CommandText = ... sqlCommand.ExecuteNonQuery(); ... } scope.Complete(); } Starting with EF6.0 we have a new way to work with transactions. The new approach is based on Database.BeginTransaction(), Database.Rollback(), Database.Commit(). Yes, no more TransactionScope.
In the followi…