Quantcast
Channel: Azure Networking (DNS, Traffic Manager, VPN, VNET) forum
Viewing all articles
Browse latest Browse all 6513

[Forum FAQ] How to attach an Affinity Group to an Azure Virtual Network

$
0
0

As we all known, affinity groups can help us to group the services in our Azure subscription and work together to achieve optimal performance. However, we may find that we can only choose the location for a virtual network when creating a virtual network in Azure Management portal and the affinity group is not available any more now.

Next, you can follow the steps below to attach an affinity group into a virtual network via Windows Azure PowerShell:

1. Create an affinity group

In the past, we can create a new affinity group when creating a virtual network. Now we can only create an affinity group via Windows Azure PowerShell or through the Affinity Group page in Azure Management portal.

In this demo, we use Windows Azure PowerShell to do that.

Figure 1. Create an affinity group via Windows Azure PowerShell

2. Retrieve the network configuration file to a local file

We can use the Get-AzureVentConfig cmdlets to obtain the network configuration file to a local file. If you haven’t specified any virtual networks, please try to create one.

 

Figure 2. Retrieve the network configuration file to a local file

3. Edit the network configuration file.

Next, we divide the scenario into two parts:

1) No Virtual machines in the existing virtual network

If you haven’t add any virtual machines into that existing virtual network, it would be easy to attach an affinity group to that existing virtual network. You just need to modify the <VirtualNetworkSite name="xxx" Location="xxx"> to <VirtualNetworkSite name="xxx" AffinityGroup="xxx"> in the .netcfg file.

2) Virtual machines existed in the virtual network

If you have deployed virtual machines into that existing virtual network, you cannot modify the virtual network anymore and must create a new virtual network with an affinity group. You need to open the .netcfg file and copy the part from <VirtualNetworkSite name="xxx" Location="xxx"> to </Subnet> </Subnets> </VirtualNetworkSite> and save it to a file as a template.

In addition, if you have specified a DNS server for an existing virtual network, it would be a little different. You need to copy the part from <VirtualNetworkSite name="xxx" Location="xxx"> to </DnsServersRef> </VirtualNetworkSite> instead.

The below is the example of an existing virtual network (without DNS server) in the demo:

      <VirtualNetworkSite name="test" Location="East Asia">

        <AddressSpace>

          <AddressPrefix>10.0.1.0/24</AddressPrefix>

        </AddressSpace>

        <Subnets>

          <Subnet name="Subnet-1">

            <AddressPrefix>10.0.1.0/27</AddressPrefix>

          </Subnet>

          <Subnet name="Subnet-2">

            <AddressPrefix>10.0.1.32/27</AddressPrefix>

          </Subnet>

        </Subnets>

      </VirtualNetworkSite>

Next, we need to modify <VirtualNetworkSite name="test" Location="East Asia"> to <VirtualNetworkSite name="lab123" AffinityGroup="lab">.

If your existing virtual network has defined a DNS server and you don’t want to specify one for the new virtual network, you can delete the part from <DnsServersRef> to </DnsServersRef> from the template. In addition, if you need to change the IP addresses range for your virtual network, you can also modify as you need.

After that, you can copy the modified commands and paste it after <VirtualNetworkSites> in .netcfg file, and then save it.

4. Use Set-AzureVNetConfig commands to reconfigure the virtual networks

Figure 3. Reconfigure the virtual networks via Windows AZURE PowerShell

 

After that, we can see the new virtual network has been created in the Azure management portal and it has been attached with the Affinity Group lab.

 

Figure 4. The new created virtual network in Windows Azure management portal

Besides, you can also check the Configure panel of the virtual network to view the subnet space you have specified in the .netcfg file.

Figure 5. The new created virtual network address spaces in Windows Azure management portal

More information:

 

Create an Affinity Group in the Management Portal

http://msdn.microsoft.com/en-us/library/azure/jj156209.aspx

Configure a Virtual Network Using a Network Configuration File

http://msdn.microsoft.com/en-us/library/azure/jj156097.aspx



Please click to vote if the post helps you. This can be beneficial to other community members reading the thread.


Viewing all articles
Browse latest Browse all 6513

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>