public TrafficManagerEndpoint GetTrafficManagerEndpoint(string resourceGroupName, string profileName, string endpointType, string endpointName) { EndpointGetResponse response = this.TrafficManagerManagementClient.Endpoints.Get(resourceGroupName, profileName, endpointType, endpointName); return(TrafficManagerClient.GetPowershellTrafficManagerEndpoint( resourceGroupName, profileName, endpointType, endpointName, response.Endpoint.Properties)); }
public void CrudEndpointsFullCycle() { using (UndoContext context = UndoContext.Current) { context.Start(); TrafficManagerManagementClient trafficManagerClient = TrafficManagerHelper.GetTrafficManagerClient(); string profileName = TestUtilities.GenerateName("hydratestwatmv2profile"); string endpointName = TestUtilities.GenerateName("hydratestwatmv2endpoint"); ResourceGroupExtended resourceGroup = TrafficManagerHelper.CreateResourceGroup(); Profile profile = TrafficManagerHelper.GenerateDefaultProfile(profileName); profile.Properties.Endpoints = null; // Create profile without endpoints trafficManagerClient.Profiles.CreateOrUpdate( resourceGroup.Name, profileName, new ProfileCreateOrUpdateParameters { Profile = profile }); // Create the endpoint EndpointCreateOrUpdateResponse createEndpoint = trafficManagerClient.Endpoints.CreateOrUpdate( resourceGroup.Name, profileName, "ExternalEndpoints", endpointName, new EndpointCreateOrUpdateParameters { Endpoint = TrafficManagerHelper.GenerateDefaultEndpoint(endpointName) }); Assert.Equal(HttpStatusCode.Created, createEndpoint.StatusCode); EndpointGetResponse getEndpoint = trafficManagerClient.Endpoints.Get( resourceGroup.Name, profileName, "ExternalEndpoints", endpointName); Assert.Equal(HttpStatusCode.OK, getEndpoint.StatusCode); Endpoint endpointToUpdate = getEndpoint.Endpoint; string oldTarget = endpointToUpdate.Properties.Target; string newTarget = "another." + oldTarget; endpointToUpdate.Properties.Target = newTarget; // Create the endpoint EndpointUpdateResponse updateEndpoint = trafficManagerClient.Endpoints.Update( resourceGroup.Name, profileName, "ExternalEndpoints", endpointName, new EndpointUpdateParameters { Endpoint = endpointToUpdate }); Assert.Equal(HttpStatusCode.Created, updateEndpoint.StatusCode); Assert.Equal(newTarget, updateEndpoint.Endpoint.Properties.Target); AzureOperationResponse deleteResponse = trafficManagerClient.Endpoints.Delete( resourceGroup.Name, profileName, "ExternalEndpoints", endpointName); Assert.Equal(HttpStatusCode.OK, deleteResponse.StatusCode); } }
public void CrudEndpointGeographicProfile() { using (UndoContext context = UndoContext.Current) { context.Start(); TrafficManagerManagementClient trafficManagerClient = TrafficManagerHelper.GetTrafficManagerClient(); string profileName = TestUtilities.GenerateName("hydratestwatmv2profile"); ResourceGroupExtended resourceGroup = TrafficManagerHelper.CreateResourceGroup(); Profile profile = TrafficManagerHelper.GenerateDefaultProfile(profileName); profile.Properties.TrafficRoutingMethod = "Geographic"; profile.Properties.Endpoints = null; // Create the profile ProfileCreateOrUpdateResponse createResponse = trafficManagerClient.Profiles.CreateOrUpdate( resourceGroup.Name, profileName, new ProfileCreateOrUpdateParameters { Profile = profile }); Assert.Equal(HttpStatusCode.Created, createResponse.StatusCode); Assert.Equal("Geographic", createResponse.Profile.Properties.TrafficRoutingMethod); Endpoint endpoint = new Endpoint { Id = null, Name = "My external endpoint", Type = "Microsoft.network/TrafficManagerProfiles/ExternalEndpoints", Properties = new EndpointProperties { TargetResourceId = null, Target = "foobar.contoso.com", EndpointStatus = "Enabled", GeoMapping = new[] { "GEO-AS", "GEO-AF" }, } }; // Create the endpoint EndpointCreateOrUpdateResponse createEndpointResponse = trafficManagerClient.Endpoints.CreateOrUpdate( resourceGroup.Name, profileName, "ExternalEndpoints", endpoint.Name, new EndpointCreateOrUpdateParameters { Endpoint = endpoint }); Assert.Equal(HttpStatusCode.Created, createEndpointResponse.StatusCode); Assert.Equal("GEO-AS", createEndpointResponse.Endpoint.Properties.GeoMapping[0]); Assert.Equal("GEO-AF", createEndpointResponse.Endpoint.Properties.GeoMapping[1]); // Get the endpoint EndpointGetResponse endpointGetResponse = trafficManagerClient.Endpoints.Get( resourceGroup.Name, profileName, "ExternalEndpoints", endpoint.Name); Assert.Equal("GEO-AS", endpointGetResponse.Endpoint.Properties.GeoMapping[0]); Assert.Equal("GEO-AF", endpointGetResponse.Endpoint.Properties.GeoMapping[1]); } }