I'm trying to add a new Traffic Manager endpoint to an existing profile in a powershell script as part of a deployment pipeline. In the Azure portal I'm able to simply add a second endpoint and a new priority is assigned. Since I'm using weighted policy the priority is meaningless for me, so I don't care what it is. I don't want to set it with a random number since that could still fail the job.
The documentation claims that new endpoints should be auto assigned a new value, but this only works if I remove all existing endpoints first then add them all back in. Since the get-AzureRMTrafficManagerEndPoint cmdlet requires the endpoint name (not optional) and I don't know all of the endpoint names I have no way to remove and re-add them.
Am I approaching this wrong? Is it a bug? Am I using the commands wrong?
The error text is "Set-AzureRmTrafficManagerProfile : BadRequest: The endpoint priorities are not set correctly. The priorities must be set on all or none of the endpoints."
This code works:
$TrafficManagerProfile = Get-AzureRmTrafficManagerProfile -Name "TMName" -ResourceGroupName "TMRGName"
$publicIPObj = Get-AzureRmPublicIpAddress -ResourceGroupName "App1RGName"
Add-AzureRmTrafficManagerEndpointConfig -EndpointName "App1" -EndpointStatus Enabled -TargetResourceId $publicIPObj.id -TrafficManagerProfile $TrafficManagerProfile -Type AzureEndpoints -Weight 10
$publicIPObj = Get-AzureRmPublicIpAddress -ResourceGroupName "App2RGName"
Add-AzureRmTrafficManagerEndpointConfig -EndpointName "App2" -EndpointStatus Enabled -TargetResourceId $publicIPObj.id -TrafficManagerProfile $TrafficManagerProfile -Type AzureEndpoints -Weight 10
Set-AzureRmTrafficManagerProfile -TrafficManagerProfile $TrafficManagerProfile
This code fails:
$TrafficManagerProfile = Get-AzureRmTrafficManagerProfile -Name "TMName" -ResourceGroupName "TMRGName"
$publicIPObj = Get-AzureRmPublicIpAddress -ResourceGroupName "App1RGName"
Add-AzureRmTrafficManagerEndpointConfig -EndpointName "App1" -EndpointStatus Enabled -TargetResourceId $publicIPObj.id -TrafficManagerProfile $TrafficManagerProfile -Type AzureEndpoints -Weight 10
Set-AzureRmTrafficManagerProfile -TrafficManagerProfile $TrafficManagerProfile
$TrafficManagerProfile = Get-AzureRmTrafficManagerProfile -Name "TMName" -ResourceGroupName "TMRGName"
$publicIPObj = Get-AzureRmPublicIpAddress -ResourceGroupName "App2RGName"
Add-AzureRmTrafficManagerEndpointConfig -EndpointName "App2" -EndpointStatus Enabled -TargetResourceId $publicIPObj.id -TrafficManagerProfile $TrafficManagerProfile -Type AzureEndpoints -Weight 10
Set-AzureRmTrafficManagerProfile -TrafficManagerProfile $TrafficManagerProfile