With Azure PowerShell you can get certain functionality currently unavailable on Azure Portal, like:
ResourceId
instead of domain name, so you don't need to set Location manually for Azure EndpointsTo start you need to login and select RM subscription.
Operations with Traffic Managers via PowerShell are done in three steps:
$profile = Get-AzureRmTrafficManagerProfile -ResourceGroupName my-resource-group -Name my-traffic-manager
$profile
fields and $profile.Endpoints
to see each endpoint's configuration.Set-AzureRmTrafficManagerProfile -TrafficManagerProfile $profile
.All current endpoints are stored in $profile.Endpoints
list, so you can alter them directly by index$profile.Endpoints[0].Weight = 100
or by name
$profile.Endpoints | ?{ $_.Name -eq 'my-endpoint' } | %{ $_.Weight = 100 }
To clear all endpoints use
$profile.Endpoints.Clear()
To delete particular endpoint use
Remove-AzureRmTrafficManagerEndpointConfig -TrafficManagerProfile $profile -EndpointName 'my-endpoint'
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
As you can see, in the last case we've addressed our azure service via ResourceId rather than domain name.
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.