Add an external endpoint to an existing profile using an Azure Template

This article describes how to use an Azure Resource Manager template (ARM Template) to add an external endpoint to an existing Traffic Manager profile.

An Azure Resource Manager template is a JavaScript Object Notation (JSON) file that defines the infrastructure and configuration for your project. The template uses 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.

Button to deploy the Resource Manager template to Azure.

Prerequisites

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": "1.0.0.0",
  "parameters": {
    "existingTMProfileName": {
      "type": "string",
      "metadata": {
        "description": "Name of the traffic manager profile to add a endpoint to"
      }
    },
    "endpointName": {
      "type": "string",
      "metadata": {
        "description": "Name of the endpoint to add to traffic manager profile"
      }
    }
  },
  "variables": {
    "endpointStatus": "Enabled",
    "endpointMonitorStatus": "Degraded",
    "endpointLocation": "westus",
    "target": "www.msn.com",
    "weight": "3",
    "priority": "3"
  },
  "resources": [
    {
            "apiVersion": "2018-04-01",
            "type": "Microsoft.Network/TrafficManagerProfiles/ExternalEndpoints",
            "name": "[concat(parameters('existingTMProfileName'), '/', parameters('endpointName'))]",
            "properties": {
              "endpointStatus": "[variables('endpointStatus')]",
              "endpointLocation": "[variables('endpointLocation')]",
              "endpointMonitorStatus": "[variables('endpointMonitorStatus')]",
              "target": "[variables('target')]",
              "weight": "[variables('weight')]",
              "priority":"[variables('priority')]"
            }
    }
  ]
}

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.

    $templateUri = "https://raw.githubusercontent.com/Azure/azure-quickstart-templates/master/quickstarts/microsoft.network/traffic-manager-add-external-endpoint/azuredeploy.json"
    
    $resourceGroupName = Read-Host -Prompt "Enter name of resource group of existing traffic manager profile"
    
    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 adds another endpoint based on your inputs to an existing profile.

    The resource group name is the existing resource group that contains the existing profile.

    Note

    existingTMProfileName must match your existing profile 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. Use Get-AzTrafficManagerProfile to verify that another endpoint was added to the profile.

    Get-AzTrafficManagerProfile -ResourceGroupName myResourceGroup -Name ExternalEndpointExample | Select Endpoints
    

    The output is similar to:

    Output of validation command

Clean up resources

When you no longer need the Traffic Manager profile, delete the resource group. This command 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 added an endpoint to an existing Traffic Manager profile.

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