Managing Traffic Managers



  • With Azure PowerShell you can get certain functionality currently unavailable on Azure Portal, like:
    • Reconfigure all Traffic Manager's endpoints at once
    • Address other services via Azure ResourceId instead of domain name, so you don't need to set Location manually for Azure Endpoints

Prerequisites

  • To start you need to login and select RM subscription.

Get TrafficManager profile

  • Operations with Traffic Managers via PowerShell are done in three steps:
    • Get TM profile:
$profile = Get-AzureRmTrafficManagerProfile -ResourceGroupName my-resource-group -Name my-traffic-manager
click below button to copy the code. By azure tutorial team
  • Explore and modify TM profile
    • Check $profile fields and $profile.Endpoints to see each endpoint's configuration.
  • Save changes via Set-AzureRmTrafficManagerProfile -TrafficManagerProfile $profile.

Change endpoints

  • All current endpoints are stored in $profile.Endpoints list, so you can alter them directly by index
$profile.Endpoints[0].Weight = 100
click below button to copy the code. By azure tutorial team
  • or by name
$profile.Endpoints | ?{ $_.Name -eq 'my-endpoint' } | %{ $_.Weight = 100 }
click below button to copy the code. By azure tutorial team
  • To clear all endpoints use
$profile.Endpoints.Clear()
click below button to copy the code. By azure tutorial team
  • To delete particular endpoint use
Remove-AzureRmTrafficManagerEndpointConfig -TrafficManagerProfile $profile -EndpointName 'my-endpoint'
click below button to copy the code. By azure tutorial team
  • To add new endpoint use
Add-AzureRmTrafficManagerEndpointConfig -TrafficManagerProfile $profile -EndpointName "my-endpoint" -Type AzureEndpoints -TargetResourceId "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/my-resource-group/providers/Microsoft.ClassicCompute/domainNames/my-azure-service" -EndpointStatus Enabled -Weight 100
click below button to copy the code. By azure tutorial team
  • As you can see, in the last case we've addressed our azure service via ResourceId rather than domain name.

Keep in mind

  • Your changes to TM and it's endpoints are not applied until you'll invoke Set-AzureRmTrafficManagerProfile -TrafficManagerProfile $profile. That allows you to fully reconfigure TM in one operation.

Traffic Manager is an implementation of DNS and IP address given to clients has some time to live (aka TTL, you can see it's duration in seconds in the $profile.Ttl field). So, after you've reconfigured TM some clients will continue to use old endpoints they cached until that TTL expire.


Related Searches to Managing Traffic Managers