Примечание
Для доступа к этой странице требуется авторизация. Вы можете попробовать войти или изменить каталоги.
Для доступа к этой странице требуется авторизация. Вы можете попробовать изменить каталоги.
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.
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.
Prerequisites
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": "1.0.0.0",
"metadata": {
"_generator": {
"name": "bicep",
"version": "0.25.53.49325",
"templateHash": "17662726020644193974"
}
},
"parameters": {
"uniqueDnsName": {
"type": "string",
"metadata": {
"description": "Relative DNS name for the traffic manager profile, must be globally unique."
}
}
},
"resources": [
{
"type": "Microsoft.Network/trafficmanagerprofiles",
"apiVersion": "2022-04-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"
}
}
]
}
}
],
"outputs": {
"name": {
"type": "string",
"value": "ExternalEndpointExample"
},
"resourceGroupName": {
"type": "string",
"value": "[resourceGroup().name]"
},
"resourceId": {
"type": "string",
"value": "[resourceId('Microsoft.Network/trafficmanagerprofiles', 'ExternalEndpointExample')]"
}
}
}
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
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.
Select Copy from the previous code block to copy the PowerShell script.
Right-click the shell console pane and then select Paste.
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 oflearn.microsoft.com
with the location in South Central US.The resource group name is the project name with rg appended.
Note
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 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
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
.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
orlearn.microsoft.com
depending on which region is closer to you.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
orlearn.microsoft.com
respectively.Disable-AzTrafficManagerEndpoint -Name {endpointName} -Type ExternalEndpoints -ProfileName ExternalEndpointExample -ResourceGroupName $resourceGroupName -Force
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.