Tag Archive for Affinity Groups

Azure 101 Part (1): Understanding Affinity Groups

Azure comes with new keywords that many IT Pro and Developer may not be familiar with. Understanding the key concepts is important in designing and deploying Azure application, especially if We care about High Availability and Disaster Recovery. This post will observe the meaning and relationship between three important concepts: Affinity Groups, Availability Set, and Cloud Service.


Affinity Groups

The idea of Affinity Groups is quite simple: any applications, services, and infrastructure should be in the same data center for best performance. Of course this also depends on the connection between locations, but keeping all of them in the same region will give faster accessibility than separate them to multiple region. An Affinity Groups is the way Azure ties various resources as close as possible, by keeping them in the same region. As the time of this writing, Azure data centers are located at the 9 areas as follow:

  • North Central US
  • South Central US
  • East US
  • West US
  • South America
  • North Europe
  • West Europe
  • East Asia
  • South East Asia


Creating Affinity Groups

An Affinity Groups can be created either in Management Portal or PowerShell. The setup is located under Settings menu of the portal. Once it is created, it can be assigned to other Azure resources to keep them stay close in the same region.


There are 3 fields to fill in when creating Affinity Groups:

  • Name: the name for affinity group.
  • Description: the description for affinity group.
  • Region: the region where this affinity group will be located

create AG

Creating Affinity Groups with PowerShell is straight forward by using the following command:

New-AzureAffinityGroup -Name "SEA IaaS"-Location "Southeast Asia"-Description "IaaS group in SEA" -Label "SEA IaaS Group"

The name must be unique within an Azure Subscription. This does not limit us to create multiple Affinity Groups with the same region, as long as their names are different. Once created, the region location in it cannot be modified.


How Affinity Group relate to another Azure resources?

The relationship between Affinity Groups with other resources can be in many ways, depending on the sequence and approach in provisioning of those resources. Below are two examples:

  • Storage Account; Provisioning storage account requires either Location or Affinity Groups as mandatory parameter. The storage account is where all data related stuff located. These can be BLOB, database file, table, and VHD files belong to Virtual Machine.
  • Cloud Service; Similar with storage account, Cloud Service provisioning also requires some parameters related to location, which can be supplied with Affinity Groups or region name. I will explain this more detail in another post.

So to sum it up, the following diagram depicts logical relationship between Affinity Groups, storage account, cloud service, and another Azure services that may sit on top of that.