Quickstart: Create a Traffic Manager profile using Bicep

This quickstart describes how to use Bicep to create a Traffic Manager profile with external endpoints using the performance routing method.

Bicep is a domain-specific language (DSL) that uses declarative syntax to deploy Azure resources. It provides concise syntax, reliable type safety, and support for code reuse. Bicep offers the best authoring experience for your infrastructure-as-code solutions in Azure.


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

Review the Bicep file

The Bicep file used in this quickstart is from Azure Quickstart Templates.

@description('Relative DNS name for the traffic manager profile, must be globally unique.')
param uniqueDnsName string

resource ExternalEndpointExample 'Microsoft.Network/trafficmanagerprofiles@2018-08-01' = {
  name: 'ExternalEndpointExample'
  location: 'global'
  properties: {
    profileStatus: 'Enabled'
    trafficRoutingMethod: 'Performance'
    dnsConfig: {
      relativeName: 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 Bicep file:

Deploy the Bicep file

  1. Save the Bicep file as main.bicep to your local computer.

  2. Deploy the Bicep file using either Azure CLI or Azure PowerShell.

    az group create --name exampleRG --location eastus
    az deployment group create --resource-group exampleRG --template-file main.bicep --parameters uniqueDnsName=<dns-name>

    The Bicep file 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.


    uniqueDNSname needs to be a globally unique name in order for the Bicep file to deploy successfully.

    When the deployment finishes, you'll see a message indicating the deployment succeeded.

Validate the deployment

Use Azure CLI or Azure PowerShell to validate the deployment.

  1. Determine the DNS name of the Traffic Manager profile.

    az network traffic-manager profile show --name ExternalEndpointExample --resource-group exampleRG 

    From the output, copy the fqdn value. It'll be in the following format: <relativeDnsName>.trafficmanager.net. This value is also the DNS name of your Traffic Manager profile.

  2. Run the following command by replacing the {relativeDnsName} variable with <relativeDnsName>.trafficmanager.net.

    nslookup -type=cname {relativeDnsName}

    You should get a canonical name 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.

    az network traffic-manager endpoint update --name {endpointName} --type externalEndpoints --profile-name ExternalEndpointExample --resource-group exampleRG --endpoint-status "Disabled"
  4. Run the command from Step 2 again in Azure CLI or Azure PowerShell. This time, you should get the other canonical name/NameHost for the other endpoint.

Clean up resources

When you no longer need the Traffic Manager profile, use the Azure portal, Azure CLI, or Azure PowerShell to delete the resource group. This removes the Traffic Manager profile and all the related resources.

az group delete --name exampleRG

Next steps

In this quickstart, you created a Traffic Manager profile using Bicep.

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