Skip to main content

Virtual Networks (Day 9 of 31)

List of all posts from this series:

Short Description 
A Virtual Network is a ‘private’ network that you can define over Azure infrastructure. In each Virtual Network users has the ability to add Azure services and VM that he wants and need.
Only VMs and Azure services from the same Virtual Network can see each other’s. By default, external resources cannot access resources from Virtual Network. Of course users have the ability to configure a Virtual Network to be accessed from outside world (if needed).
We can imagine a Virtual Network as a private network that we create home or at work. We can add to it any resources, allocate specific IPs and subnet masks, open different ports for external access and so on. Is a network inside a network if we could say this. Many time I refer to it as a Private Network, because you can add resources to it and limit access of external resources to them (it).

Main Features 
Isolate resources to public access
Using Virtual Networks you can create your own private cornet in Azure, where only you have access to it. All your resources are isolated from the rest of Azure
3 type of models
In general, there are 3 types of configuration used with Virtual Networks:

  • Cloud-Only – A Virtual Network with resources only from Azure. Used to manage, secure and isolated cloud resources.
  • Cross-Premises Virtual Network– For hybrid solutions, where Virtual Network is used to create a space in Azure that can be accessed and is integrated with an on-premises network. Both networks form a single networks, that allow cross access.
  • No-Virtual Network – No Virtual Network used for cloud resources. 

Cross-Premises Connection
In use cases when you need to connect your on-premises solution to Azure resources, than Virtual Network is a have to and you need to think about it from the first moment.
Resource Name Resolution
Once you integrate your network with a Virtual Network you can access your resources directly by their DNS name (for example Virtual Machine name).
Automatically integration scripts
When you create a Virtual Network, Azure can generate your custom scripts that needs to be run by IT on your on-premises network. Using this scripts the two networks can become one network without additional configuration.
Custom IP range and Subnet Mask
When creating a Virtual Network you have the ability to set a custom IP range and subnet mask. You can create your own configuration based on your own needs and network requirements.
Persistent Private IP Address 
In the Virtual Network resources will have a static IP that don’t change in time. For example a VM will have the same IP and will not change. On top of this you can assign a specific IP to your resources by hand from your Virtual Network IP range. In this way when a resource is deallocated or stopped.
Azure Resources Supported
In this moment only Virtual Machines and PaaS resources can be added to a Virtual Network. Resources like Service Bus cannot be added to a Virtual Network (yet).
Tools that can be used
For setup and configuration we have two tools that can be used:

  • Netcfg – a file that is generated by Azure platform and can be used to make different configuration
  • Management Portal

Subnet Masks Limitation
You can define how many subnets, as long as they don’t overlap. The same rules are applicable for any network (from on-premises or cloud).
IP Type and Ranges
Virtual Network allow us to use any kind of IP, from public IP Address to any kind of IP ranges.
Type of Network
Virtual Network is a Layer 3 network that is responsible for package forwarding and routing.
Supported Protocols 
There are 3 types of protocols that are supported in this moment:

  • TCP
  • UDP
  • ICMP

VPN connection are supported (RRAS – Remote Access servers and Windows Server 2012 Routing).
Linux Support
All Linux distribution that are supported on Azure can be used in a Virtual Network.

Cannot move resources to a Virtual Network once were created
Once a resource like a Virtual Machine was created and deployed you cannot move it to a Virtual Network. This is happening because network information are acquire during deployment. Of course you can redeploy your machine, but a short downtime will appear.
VPN is limited only to Windows OS
You can use VPN only for Windows OS (W7,W8, Windows Server 2008 R2 64b, Windows Server 2012)
Cannot be used with all Azure Services
In this moment only Virtual Machines and PaaS resources can be added to a Virtual Network. Other type of services cannot be added to a Virtual Network.
Cross Region
A virtual region can be defined only in one region. If you want to create a cross region network you need to create multiple Virtual Networks and connect them.
Network Size
The smallest subnet network that is supported is /29 and the largest is a /8.
VLANs cannot be added
Because Virtual Network is a Layer 3 network, there is no support for VLANs (that operate at Layer 2).
This network diagnostic tools cannot be used in a Virtual Network.
In this moment there is no support of IPv6.
In this moment there is no support for packages broadcast.
In this moment there is no support for multicast.
IP-in-IP encapsulated packets 
In this moment this is not supported.
Generic Routing Encapsulation (GRE)
In this moment this is not supported.
In this moment SQL DBs cannot be used in combination with Virtual Networks.

Applicable Use Cases 
Below you can find 4 use cases when I would use Virtual Network:
Isolate an application that contains multiple resources (like VM)
In this case you would like all your resources to be part from the same network and to be isolated from external world.
Scale your on-premises resources
When you need more computing power resources (VMs) and you want to scale your on-premises resources in a secure and simple way, Virtual Network can create the secure environments to do something like this.
Hybrid Solutions
When your solution is hosted on-premises and also on cloud, Virtual Network can be used with success to unify the system and resources.
Connect to Azure VM in a secure way
If you want to access VM in a secure and reliable way from your own networks that Virtual Network is a have to.

Code Sample 

Pros and Cons 

  • Easy to configure
  • Isolate resources from internet
  • Secure


  • Only VM and PaaS resources can be used
  • IPv6 is not yet supported

When you calculate how much Virtual Networks would cost, you should take into consideration the fallowing components:

  • Outbound data transfer (Inter V-NET)
  • VPN Gateway time duration

Virtual Network can be used with success when you need to extend your on-premises network, giving us the possibility to create hybrid scenarios very easily without any kind of effort. We can secure extend our data centers and create secure and isolated corners on cloud where we can manage our own resources.


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 …

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…

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.