-
Notifications
You must be signed in to change notification settings - Fork 18
Description
Link to sample
No response
Library name and version
Python
Language of the Sample
- C#/.NET
- Java
- JavaScript/TypedScript
- Python
- Golang
- Other - Please specify in Issue details field
Sample Issue Type
- Sample not working
- Sample missing
- Do not understand sample
Issue details
The script provided on this page (https://learn.microsoft.com/en-us/rest/api/trafficmanager/endpoints/update?tabs=Python) for Python is not working. It was tested by a customer and not successful. The customer provided a sample of code that is working for them.
`from azure.identity import DefaultAzureCredential
from azure.mgmt.trafficmanagerimport TrafficManagerManagementClient
def update_tm_endpoint(target: str):
subscription_id = "subscription_id"
resource_group_name = "rg-name"
profile_name = "trafficmanager-profile-name"
endpoint_type = "azureEndpoints"
endpoint_name = "trafficmanagerendpointname"
target = "/subscriptions/subscription_id/resourceGroups/rg-name/providers/Microsoft.Web/sites/website-name"
weight = "1"
endpoint_status = "Enabled"
credentials = DefaultAzureCredential()
traffic_manager_client = TrafficManagerManagementClient(
credentials, subscription_id
)
endpoint = traffic_manager_client.endpoints.get(
resource_group_name, profile_name, endpoint_type, endpoint_name
)
endpoint.target_resource_id = target
endpoint.weight = weight
endpoint.endpoint_status = endpoint_status
res = traffic_manager_client.endpoints.create_or_update(
resource_group_name, profile_name, endpoint_type, endpoint_name, endpoint
)
return res, datetime.now()`
Expected behavior
No response
Actual behavior
No response
Reproduction Steps
No response
Environment
No response