public TrafficManagerProfile CreateTrafficManagerProfile(string resourceGroupName, string profileName, string profileStatus, string trafficRoutingMethod, string relativeDnsName, uint ttl, string monitorProtocol, uint monitorPort, string monitorPath, Hashtable[] tag) { ProfileCreateOrUpdateResponse response = this.TrafficManagerManagementClient.Profiles.CreateOrUpdate( resourceGroupName, profileName, new ProfileCreateOrUpdateParameters { Profile = new Profile { Name = profileName, Location = TrafficManagerClient.ProfileResourceLocation, Properties = new ProfileProperties { ProfileStatus = profileStatus, TrafficRoutingMethod = trafficRoutingMethod, DnsConfig = new DnsConfig { RelativeName = relativeDnsName, Ttl = ttl }, MonitorConfig = new MonitorConfig { Protocol = monitorProtocol, Port = monitorPort, Path = monitorPath } }, Tags = TagsConversionHelper.CreateTagDictionary(tag, validate: true), } }); return(TrafficManagerClient.GetPowershellTrafficManagerProfile(resourceGroupName, profileName, response.Profile)); }
public void CrudProfileFullCycle() { using (UndoContext context = UndoContext.Current) { context.Start(); TrafficManagerManagementClient trafficManagerClient = TrafficManagerHelper.GetTrafficManagerClient(); string profileName = TestUtilities.GenerateName("hydratestwatmv2profile"); ResourceGroupExtended resourceGroup = TrafficManagerHelper.CreateResourceGroup(); // Create the profile ProfileCreateOrUpdateResponse createResponse = trafficManagerClient.Profiles.CreateOrUpdate( resourceGroup.Name, profileName, new ProfileCreateOrUpdateParameters { Profile = TrafficManagerHelper.GenerateDefaultProfile(profileName) }); Assert.Equal(HttpStatusCode.Created, createResponse.StatusCode); // Get the profile ProfileGetResponse getResponse = trafficManagerClient.Profiles.Get( resourceGroup.Name, profileName); Assert.Equal(HttpStatusCode.OK, getResponse.StatusCode); // Delete the profile AzureOperationResponse deleteResponse = trafficManagerClient.Profiles.Delete(resourceGroup.Name, profileName); Assert.Equal(HttpStatusCode.OK, deleteResponse.StatusCode); } }
public TrafficManagerProfile CreateTrafficManagerProfile(string resourceGroupName, string profileName, string trafficRoutingMethod, string relativeDnsName, uint ttl, string monitorProtocol, uint monitorPort, string monitorPath) { ProfileCreateOrUpdateResponse response = this.TrafficManagerManagementClient.Profiles.CreateOrUpdate( resourceGroupName, profileName, new ProfileCreateOrUpdateParameters { Profile = new Profile { Name = profileName, Location = TrafficManagerClient.ProfileResourceLocation, Properties = new ProfileProperties { TrafficRoutingMethod = trafficRoutingMethod, DnsConfig = new DnsConfig { RelativeName = relativeDnsName, Ttl = ttl }, MonitorConfig = new MonitorConfig { Protocol = monitorProtocol, Port = monitorPort, Path = monitorPath } } } }); return(TrafficManagerClient.GetPowershellTrafficManagerProfile(resourceGroupName, profileName, response.Profile.Properties)); }
public void CrudProfileWithoutEndpoints_ThenUpdate() { 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.Endpoints = null; // Create the profile ProfileCreateOrUpdateResponse createResponse = trafficManagerClient.Profiles.CreateOrUpdate( resourceGroup.Name, profileName, new ProfileCreateOrUpdateParameters { Profile = profile }); Assert.Equal(HttpStatusCode.Created, createResponse.StatusCode); profile.Properties.Endpoints = new[] { new Endpoint { Id = null, Name = "My external endpoint", Type = "Microsoft.network/TrafficManagerProfiles/ExternalEndpoints", Properties = new EndpointProperties { TargetResourceId = null, Target = "foobar.contoso.com", EndpointLocation = "North Europe", EndpointStatus = "Enabled" } } }; // Update the profile ProfileCreateOrUpdateResponse updateResponse = trafficManagerClient.Profiles.CreateOrUpdate( resourceGroup.Name, profileName, new ProfileCreateOrUpdateParameters { Profile = profile }); Assert.Equal(HttpStatusCode.OK, updateResponse.StatusCode); } }
public TrafficManagerProfile SetTrafficManagerProfile(TrafficManagerProfile profile) { var parameters = new ProfileCreateOrUpdateParameters { Profile = profile.ToSDKProfile() }; ProfileCreateOrUpdateResponse response = this.TrafficManagerManagementClient.Profiles.CreateOrUpdate( profile.ResourceGroupName, profile.Name, parameters ); return(TrafficManagerClient.GetPowershellTrafficManagerProfile(profile.ResourceGroupName, profile.Name, response.Profile)); }
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]); } }