I am trying to update an Azure Traffic Manager endpoint with the Azure CLI, I run the following code:
az network traffic-manager endpoint update \
--name ${ENDPOINT_NAME} \
--profile-name ${PROFILE_NAME} \
--resource-group ${RESOURCE_GROUP} \
--type azureEndpoints \
--endpoint-status enabled \
--set targetResourceId=${INGRESS_IP_ID}
The values for those different flags were obtained by previous calls to az network traffic-manager endpoint list
But trying to set the endpoint targetResourceId
to a different resource fails with this error:
Operation failed with status: 'Bad Request'. Details: The 'resourceTargetId' property of endpoint 'we' is invalid or missing. The property must be specified only for the following endpoint types: AzureEndpoints, NestedEndpoints. You must have read access to the resource to which it refers.
I can say with absolute certainty that the endpoint I am trying to update is an AzureEndpoint, and the resource I am trying to set it to exists in the same location as the endpoint itself. I have looked through the documentation and tried to google for this error, but haven't found anything useful so far.
I can produce this issue. Probably, you pass the --target-resource-id incorrectly. It should be a full resource Id instead of the resource name.
If you target a public IP as the endpoint, you can use the command to get the resource Id.
az network public-ip show --name <publicIPName> --resource-group <resourceGroupName> --query "id"