Skip to content

Latest commit

 

History

History
148 lines (92 loc) · 5.5 KB

quickstart-create-traffic-manager-profile-bicep.md

File metadata and controls

148 lines (92 loc) · 5.5 KB
title description services author ms.author ms.date ms.topic ms.service ms.custom
Quickstart: Create an Azure Traffic Manager profile - Bicep
This quickstart article describes how to create an Azure Traffic Manager profile by using Bicep.
traffic-manager
greg-lindsay
greglin
02/19/2023
quickstart
traffic-manager
template-quickstart, subject-armqs, mode-arm, devx-track-bicep

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.

[!INCLUDE About Bicep]

Prerequisites

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.

:::code language="bicep" source="~/quickstart-templates/quickstarts/microsoft.network/traffic-manager-external-endpoint/main.bicep":::

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>
    
    New-AzResourceGroup -Name exampleRG -Location eastus
    New-AzResourceGroupDeployment -ResourceGroupName exampleRG -TemplateFile ./main.bicep -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.

    [!NOTE] 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.

    Get-AzTrafficManagerProfile -Name ExternalEndpointExample -ResourceGroupName exampleRG | Select RelativeDnsName
    

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


  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.

    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.

    az network traffic-manager endpoint update --name {endpointName} --type externalEndpoints --profile-name ExternalEndpointExample --resource-group exampleRG --endpoint-status "Disabled"
    
    Disable-AzTrafficManagerEndpoint -Name {endpointName} -Type ExternalEndpoints -ProfileName ExternalEndpointExample -ResourceGroupName exampleRG -Force
    

  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
Remove-AzResourceGroup -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.

[!div class="nextstepaction"] Traffic Manager tutorials