Many countries have data protection laws and regulations. Many applications save the data of users from a geographical region to the data centers in same region or country.
In this post, let’s have a look at how how to redirect the requests based on geographical location.
Prerequisites
You would need an active Azure subscription. If you don’t have an Azure subscription, create a free account now. And then sign in to Azure Portal.
Create Web Apps
Create two instances of Azure web apps. Both of them should be in separate Azure regions. Let’s say first Azure web app is created in region East US
while the other one is created in Central India
region. The two URLs for those apps would be:
demo-app-east-us.azurewebsites.net
demo-app-central-india.azurewebsites.net
In real world, both web apps should host the same application. For this demo, we will not deploy any application. When an Azure web app instance is created, the default page is shown. We will use that page for verifying that Azure traffic manager settings are working.
We will configure the endpoints to route all traffic from India to the Azure web app deployed in Central India
. And we will add another rule to redirect all traffic originated from USA to the Azure web app deployed in East US
region.
Create Traffic Manager Profile
Let’s create a new traffic manager profile demo-tm
which has Geographic
routing method, as shown in below snapshot. Refer this post to know the detailed steps on how to create the traffic manager profile.
Add Endpoints
Next step is to add endpoints and associate each endpoint with geographical locations. Every endpoint can be associated with multiple locations. For adding every location, there are 3 dropdowns.
- Regional Grouping, First dropdown is to get the geographical area (like Afraca, North America, Asia, etc)
- Country/Region, Second dropdown is to select the country from the geographical area
- State/Province, Third dropdown is to select province / state from the geographical area
So, navigate to the traffic manager profile and select Endpoints from the left side navigation and then click on Add. On the new panel, provide information as shown in below snapshot to add the endpoint for East US
region. Then click on Add. This setup would add a rule to redirect all traffic from USA to this endpoint.
Next, try to add another endpoint and provide inputs as shown in below snapshot. This endpoint is for application deployed in Central India
region. This would add a rule to redirect all traffic from India to this new endpoint.
Verification
Now, how are you going to verify this setup ?
You can create 3 virtual machines:
- A virtual machine in any Azure region in USA, and try to access the traffic manager DNS name. It would open the application deployed at
East US
region. - A virtual machine in any Azure region in India, and try to access the traffic manager DNS name. It would open the application deployed at
Central India
region. - You can create another third VM in any region which maps to country other than India or USA. From this virtual machine if you try to access the traffic manager DNS name, the application would not be accessible. This is because in case geographic based routing in traffic manager, the traffic manager returns NO DATA in case the region from where request was originated is not mapped to any endpoint.
I hope you found this information helpful. Let me know your thoughts.