Quickstart: Create a Traffic Manager profile using an ARM template

This quickstart describes how to use an Azure Resource Manager template (ARM Template) to create a Traffic Manager profile with external endpoints using the performance routing method.

A resource manager template is a JavaScript Object Notation (JSON) file that defines the infrastructure and configuration for your project. The template uses declarative syntax. In declarative syntax, you describe your intended deployment without writing the sequence of programming commands to create the deployment.

If your environment meets the prerequisites and you're familiar with using ARM templates, select the Deploy to Azure button. The template will open in the Azure portal.

Deploy to Azure


If you don't have an Azure subscription, create a free account before you begin.

Review the template

The template used in this quickstart is from Azure Quickstart Templates.

  "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
  "contentVersion": "",
  "metadata": {
    "_generator": {
      "name": "bicep",
      "version": "",
      "templateHash": "14278858930741668940"
  "parameters": {
    "uniqueDnsName": {
      "type": "string",
      "metadata": {
        "description": "Relative DNS name for the traffic manager profile, must be globally unique."
  "resources": [
      "type": "Microsoft.Network/trafficmanagerprofiles",
      "apiVersion": "2018-08-01",
      "name": "ExternalEndpointExample",
      "location": "global",
      "properties": {
        "profileStatus": "Enabled",
        "trafficRoutingMethod": "Performance",
        "dnsConfig": {
          "relativeName": "[parameters('uniqueDnsName')]",
          "ttl": 30
        "monitorConfig": {
          "protocol": "HTTPS",
          "port": 443,
          "path": "/",
          "expectedStatusCodeRanges": [
              "min": 200,
              "max": 202
              "min": 301,
              "max": 302
        "endpoints": [
            "type": "Microsoft.Network/TrafficManagerProfiles/ExternalEndpoints",
            "name": "endpoint1",
            "properties": {
              "target": "www.microsoft.com",
              "endpointStatus": "Enabled",
              "endpointLocation": "northeurope"
            "type": "Microsoft.Network/TrafficManagerProfiles/ExternalEndpoints",
            "name": "endpoint2",
            "properties": {
              "target": "docs.microsoft.com",
              "endpointStatus": "Enabled",
              "endpointLocation": "southcentralus"

One Azure resource is defined in the template:

To find more templates that are related to Azure Traffic Manager, see Azure Quickstart Templates.

Deploy the template

  1. Select Try it from the following code block to open Azure Cloud Shell, and then follow the instructions to sign in to Azure.

    $projectName = Read-Host -Prompt "Enter a project name that is used for generating resource names"
    $location = Read-Host -Prompt "Enter the location (i.e. centralus)"
    $templateUri = "https://raw.githubusercontent.com/Azure/azure-quickstart-templates/master/quickstarts/microsoft.network/traffic-manager-external-endpoint/azuredeploy.json"
    $resourceGroupName = "${projectName}rg"
    New-AzResourceGroup -Name $resourceGroupName -Location "$location"
    New-AzResourceGroupDeployment -ResourceGroupName $resourceGroupName -TemplateUri $templateUri
    Read-Host -Prompt "Press [ENTER] to continue ..."

    Wait until you see the prompt from the console.

  2. Select Copy from the previous code block to copy the PowerShell script.

  3. Right-click the shell console pane and then select Paste.

  4. Enter the values.

    The template deployment creates a profile with two external endpoints. Endpoint1 uses a target endpoint of www.microsoft.com with the location in North Europe. Endpoint2 uses a target endpoint of learn.microsoft.com with the location in South Central US.

    The resource group name is the project name with rg appended.


    uniqueDNSname needs to be a globally unique name in order for the template to deploy successfully. If deployment fails, start over with Step 1.

    It takes a few minutes to deploy the template. When completed, the output is similar to:

    Azure Traffic Manager Resource Manager template PowerShell deployment output

Azure PowerShell is used to deploy the template. In addition to Azure PowerShell, you can also use the Azure portal, Azure CLI, and REST API. To learn other deployment methods, see Deploy templates.

Validate the deployment

  1. Determine the DNS name of the Traffic Manager profile using Get-AzTrafficManagerProfile.

    Get-AzTrafficManagerProfile -Name ExternalEndpointExample -ResourceGroupName $resourceGroupName | Select RelativeDnsName

    Copy the RelativeDnsName value. The DNS name of your Traffic Manager profile is <relativednsname>.trafficmanager.net.

  2. From a local PowerShell run the following command by replacing the {relativeDNSname} variable with <relativednsname>.trafficmanager.net.

    Resolve-DnsName -Name {relativeDNSname} | Select-Object NameHost | Select -First 1

    You should get a NameHost of either www.microsoft.com or learn.microsoft.com depending on which region is closer to you.

  3. To check if you can resolve to the other endpoint, disable the endpoint for the target you got in the last step. Replace the {endpointName} with either endpoint1 or endpoint2 to disable the target for www.microsoft.com or learn.microsoft.com respectively.

    Disable-AzTrafficManagerEndpoint -Name {endpointName} -Type ExternalEndpoints -ProfileName ExternalEndpointExample -ResourceGroupName $resourceGroupName -Force
  4. Run the command from Step 2 again in a local PowerShell. This time you should get the other NameHost for the other endpoint.

Clean up resources

When you no longer need the Traffic Manager profile, delete the resource group. This removes the Traffic Manager profile and all the related resources.

To delete the resource group, call the Remove-AzResourceGroup cmdlet:

Remove-AzResourceGroup -Name <your resource group name>

Next steps

In this quickstart, you created a Traffic Manager profile.

To learn more about routing traffic, continue to the Traffic Manager tutorials.