다음을 통해 공유


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?”

Yes.

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="https://www.w3.org/2001/XMLSchema" xmlns:xsi="https://www.w3.org/2001/XMLSchema-instance" xmlns="https://schemas.microsoft.com/ServiceHosting/2011/07/NetworkConfiguration">
<VirtualNetworkConfiguration>
<Dns>
<DnsServers>
<DnsServer name="YourDNS" IPAddress="10.1.0.4" />
</DnsServers>
</Dns>
<LocalNetworkSites>
<LocalNetworkSite name="YourCorpHQ">
<AddressSpace>
<AddressPrefix>10.0.0.0/24</AddressPrefix>
</AddressSpace>
<VPNGatewayAddress>XXX.XXX.XXX.XXX</VPNGatewayAddress>
</LocalNetworkSite>
</LocalNetworkSites>
<VirtualNetworkSites>
<VirtualNetworkSite name="YourVirtualNetwork" AffinityGroup="KevRemWestUS">
<AddressSpace>
<AddressPrefix>10.4.0.0/16</AddressPrefix>
</AddressSpace>
<Subnets>
<Subnet name="FrontEndSubnet">
<AddressPrefix>10.4.2.0/24</AddressPrefix>
</Subnet>
<Subnet name="BackEndSubnet">
<AddressPrefix>10.4.3.0/24</AddressPrefix>
</Subnet>
<Subnet name="ADDNSSubnet">
<AddressPrefix>10.4.4.0/24</AddressPrefix>
</Subnet>
<Subnet name="GatewaySubnet">
<AddressPrefix>10.4.1.0/24</AddressPrefix>
</Subnet>
</Subnets>
<DnsServersRef>
<DnsServerRef name="YourDNS" />
</DnsServersRef>
<Gateway>
<ConnectionsToLocalNetwork>
<LocalNetworkSiteRef name="YourCorpHQ" />
</ConnectionsToLocalNetwork>
</Gateway>
</VirtualNetworkSite>
</VirtualNetworkSites>
</VirtualNetworkConfiguration>
</NetworkConfiguration>


To get the full article, please read it here: https://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

  • Anonymous
    January 01, 2003
    Helpful topic