public static Profile CreateOrUpdateProfileWithMultiValue( TrafficManagerManagementClient trafficManagerClient, string resourceGroupName, string profileName, long?maxReturn = 2) { Profile expectedProfile = CreateOrUpdateDefaultEmptyProfile(trafficManagerClient, resourceGroupName, profileName, "MultiValue", "Disabled", maxReturn); expectedProfile.Endpoints = new List <Endpoint>(); for (int ndx = 0; ndx < 5; ndx++) { Endpoint endpoint = TrafficManagerHelper.GenerateDefaultEndpoint( $"My external endpoint {ndx}", $"1.2.3.{ndx}"); EndpointPropertiesSubnetsItem range = new EndpointPropertiesSubnetsItem($"1.2.{ndx}.0", $"1.2.{ndx}.250"); EndpointPropertiesSubnetsItem subnet = new EndpointPropertiesSubnetsItem($"3.4.{ndx}.0", null, 24); endpoint.Subnets = new List <EndpointPropertiesSubnetsItem> { range, subnet }; trafficManagerClient.Endpoints.CreateOrUpdate( resourceGroupName, profileName, "ExternalEndpoints", endpoint.Name, endpoint); expectedProfile.Endpoints.Add(endpoint); } return(expectedProfile); }
public static Profile GenerateDefaultEmptyProfile( string profileName, string trafficRoutingMethod = "Performance", string trafficViewEnrollmentStatus = "Disabled", long?maxReturn = null) { return(TrafficManagerHelper.BuildProfile( id: null, name: profileName, type: "microsoft.network/trafficmanagerprofiles", location: "global", tags: null, profileStatus: "Enabled", trafficRoutingMethod: trafficRoutingMethod, trafficViewEnrollmentStatus: trafficViewEnrollmentStatus, maxReturn: maxReturn, dnsConfig: new DnsConfig { RelativeName = profileName, Ttl = 35 }, monitorConfig: new MonitorConfig { Protocol = "http", Port = 80, Path = "/testpath.aspx" }, endpoints: null)); }
public static Profile GenerateDefaultProfile(string profileName, string relativeName = null) { return(TrafficManagerHelper.BuildProfile( id: null, name: profileName, type: "microsoft.network/trafficmanagerprofiles", location: "global", tags: null, profileStatus: "Enabled", trafficRoutingMethod: "Performance", dnsConfig: new DnsConfig { RelativeName = relativeName ?? TestUtilities.GenerateName("foohydratestrelativeName"), Ttl = 35 }, monitorConfig: new MonitorConfig { Protocol = "http", Port = 80, Path = "/testpath.aspx" }, endpoints: new [] { GenerateDefaultEndpoint() })); }
public static Profile GenerateDefaultProfile(string profileName) { return(TrafficManagerHelper.BuildProfile( id: null, name: profileName, type: "microsoft.network/trafficmanagerprofiles", location: "global", tags: null, profileStatus: "Enabled", trafficRoutingMethod: "Performance", dnsConfig: new DnsConfig { RelativeName = profileName, Ttl = 35 }, monitorConfig: new MonitorConfig { Protocol = "http", Port = 80, Path = "/testpath.aspx" }, endpoints: new [] { new Endpoint { Id = null, Name = "My external endpoint", Type = "Microsoft.network/TrafficManagerProfiles/ExternalEndpoints", TargetResourceId = null, Target = "foobar.contoso.com", EndpointLocation = "North Europe", EndpointStatus = "Enabled" } })); }
public static Profile CreateOrUpdateProfileWithCustomHeadersAndStatusCodeRanges( TrafficManagerManagementClient trafficManagerClient, string resourceGroupName, string profileName) { Profile expectedProfile = GenerateDefaultEmptyProfile(profileName); expectedProfile.MonitorConfig.CustomHeaders = new List <MonitorConfigCustomHeadersItem> { new MonitorConfigCustomHeadersItem("host", "www.contoso.com"), new MonitorConfigCustomHeadersItem("custom-name", "custom-value") }; expectedProfile.MonitorConfig.ExpectedStatusCodeRanges = new List <MonitorConfigExpectedStatusCodeRangesItem> { new MonitorConfigExpectedStatusCodeRangesItem(200, 499) }; trafficManagerClient.Profiles.CreateOrUpdate( resourceGroupName, profileName, expectedProfile); expectedProfile.Endpoints = new List <Endpoint>(); for (int ndx = 0; ndx < 3; ndx++) { Endpoint endpoint = TrafficManagerHelper.GenerateDefaultEndpoint( $"My external endpoint {ndx}", $"foobar.Contoso{ndx}.com"); endpoint.CustomHeaders = new List <EndpointPropertiesCustomHeadersItem> { new EndpointPropertiesCustomHeadersItem("custom-name", "custom-value-overriden") }; trafficManagerClient.Endpoints.CreateOrUpdate( resourceGroupName, profileName, "ExternalEndpoints", endpoint.Name, endpoint); expectedProfile.Endpoints.Add(endpoint); } return(expectedProfile); }
public static Profile CreateOrUpdateDefaultProfileWithExternalEndpoint( TrafficManagerManagementClient trafficManagerClient, string resourceGroupName, string profileName, string trafficRoutingMethod = "Performance", string trafficViewEnrollmentStatus = "Disabled", string target = "foobar.contoso.com") { Profile profile = TrafficManagerHelper.CreateOrUpdateDefaultEmptyProfile( trafficManagerClient, resourceGroupName, profileName, trafficRoutingMethod, trafficViewEnrollmentStatus); // Create the endpoint and associate it with the resource group and profile. TrafficManagerHelper.CreateOrUpdateDefaultEndpoint( trafficManagerClient, resourceGroupName, profileName, target); return(trafficManagerClient.Profiles.Get(resourceGroupName, profileName)); }