31 Days of Servers in the Cloud: Create a Windows Azure Network using PowerShell (Part 19 of 31) by Kevin Remde

At 6:00 AM on Saturday, January 19, 2013, Kevin Remde posted Part 19 of 31 in the 31 Days of Servers in the Cloud Blog Series.  Below is a small excerpt from his blog.

Back in Part 10 of our “31 Days of Servers in the Cloud” series, my good friend Bob Hunt wrote up an excellent step-by-step for creating a virtual network in Windows Azure.

His article and guide was so good, in fact, that I am going to attempt to do the very same task – to create and configure a network in Windows Azure; but instead of using the Windows Azure portal, we’re going to do it entirely using PowerShell and some special Windows Azure Management Cmdlets.

“Are you out of your mind?”

Perhaps. The goal, as it was in Bob’s article, is that in the end we have a network configured and ready to securely connect to (and extend our) existing on-premises network. From Bob’s introduction:

Before we get started, it’s important to set the stage of what we’re trying to accomplish. The Windows Azure Virtual Network you are about to create establishes a Site to Site (S2S) VPN between your company’s network and the Windows Azure Cloud Service using the steps outlined below, and requires that you have an already installed VPN device on your premise. The list of currently supported VPN devices is located here. Windows Azure currently supports up to 5 S2S VPN tunnels, allowing you to have multiple Virtual Networks hosted in Windows Azure, such as a Test Network and a Production Network.

Contoso's Deployment

Set up PowerShell

To make this happen, of course, we’re going to have to have done a couple of things in advance:

  1. Get a Windows Azure account (start with the free 90-day trial),
  2. Get the Windows Azure PowerShell tools, and
  3. Follow some simple instructions to set up the secured connection for Windows Azure management.

Once you have this done, open up your Windows Azure PowerShell window, and open up notepad.

“Huh? Notepad?”


The .netcfg File

For configuring networking in Windows Azure using PowerShell, there are only two Set-AzureVNet commands:

There are Get-AzureVNet… commands that retrieve information (and objects), but for actually creating and configuring the networking, you’re going to be using an XML formatted document that has (by default) a .netcfg extension, and then using Set-AzureVNetConfig to upload that file. And then we use New-AzureVNetGateway and Set-AzureVNetGateway to configure and connect the gateway.

Again, in Bob’s article, we created a network. So as a starting point for creating the network using PowerShell, I’m going to use Get-AzureVNetConfig to retrieve his configuration into a .netcfg file.

Get-AzureVNetConfig -ExportToFile C:\Users\kevrem\Desktop\MyAzureNetworks.netcfg

And the resulting file looks something like this:


<?xml version="1.0" encoding="utf-8"?>
<NetworkConfiguration xmlns:xsd="
http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.microsoft.com/ServiceHosting/2011/07/NetworkConfiguration">
<DnsServer name="YourDNS" IPAddress="" />
<LocalNetworkSite name="YourCorpHQ">
<VirtualNetworkSite name="YourVirtualNetwork" AffinityGroup="KevRemWestUS">
<Subnet name="FrontEndSubnet">
<Subnet name="BackEndSubnet">
<Subnet name="ADDNSSubnet">
<Subnet name="GatewaySubnet">
<DnsServerRef name="YourDNS" />
<LocalNetworkSiteRef name="YourCorpHQ" />

To get the full article, please read it here: http://blogs.technet.com/b/kevinremde/archive/2013/01/19/create-a-windows-azure-network-using-powershell-31-days-of-servers-in-the-cloud-part-19-of-31.aspx.

Harold Wong

Comments (1)

Skip to main content