private static void VerifyOriginCreated(string originName, AFDOrigin originCreateParameters, AFDOrigin origin) { Assert.NotNull(origin); Assert.Equal(originName, origin.Name); Assert.Equal(originCreateParameters.HostName, origin.HostName); Assert.Equal(originCreateParameters.OriginHostHeader, origin.OriginHostHeader); Assert.Equal(originCreateParameters.HttpPort, origin.HttpPort); Assert.Equal(originCreateParameters.HttpsPort, origin.HttpsPort); Assert.Equal(originCreateParameters.Priority, origin.Priority); Assert.Equal(originCreateParameters.Weight, origin.Weight); }
private void CreateAfdOrigin() { try { AFDOrigin afdOrigin = new AFDOrigin { HostName = this.HostName, SharedPrivateLinkResource = this.CreateSharedPrivateLinkResource() }; if (this.MyInvocation.BoundParameters.ContainsKey("HttpPort")) { afdOrigin.HttpPort = this.HttpPort; } if (this.MyInvocation.BoundParameters.ContainsKey("HttpsPort")) { afdOrigin.HttpsPort = this.HttpsPort; } if (this.MyInvocation.BoundParameters.ContainsKey("OriginHostHeader")) { afdOrigin.OriginHostHeader = this.OriginHostHeader; } if (this.MyInvocation.BoundParameters.ContainsKey("Priority")) { afdOrigin.Priority = this.Priority; } if (this.MyInvocation.BoundParameters.ContainsKey("Weight")) { afdOrigin.Weight = this.Weight; } PSAfdOrigin psAfdOrigin = this.CdnManagementClient.AFDOrigins.Create(this.ResourceGroupName, this.ProfileName, this.OriginGroupName, this.OriginName, afdOrigin).ToPSAfdOrigin(); psAfdOrigin.OriginGroupName = this.OriginGroupName; WriteObject(psAfdOrigin); } catch (AfdErrorResponseException errorResponse) { throw new PSArgumentException(errorResponse.Response.Content); } }
public void AFDRouteGetListTest() { var handler1 = new RecordedDelegatingHandler { StatusCodeToReturn = HttpStatusCode.OK }; var handler2 = new RecordedDelegatingHandler { StatusCodeToReturn = HttpStatusCode.OK }; using (MockContext context = MockContext.Start(this.GetType())) { // Create clients var cdnMgmtClient = CdnTestUtilities.GetCdnManagementClient(context, handler1); var resourcesClient = CdnTestUtilities.GetResourceManagementClient(context, handler2); // Create resource group var resourceGroupName = CdnTestUtilities.CreateResourceGroup(resourcesClient); try { // Create a standard Azure frontdoor profile string profileName = TestUtilities.GenerateName("profile"); Profile createParameters = new Profile { Location = "WestUs", Sku = new Sku { Name = SkuName.StandardAzureFrontDoor }, Tags = new Dictionary <string, string> { { "key1", "value1" }, { "key2", "value2" } } }; var profile = cdnMgmtClient.Profiles.Create(resourceGroupName, profileName, createParameters); // Create a standard Azure frontdoor endpoint string endpointName = TestUtilities.GenerateName("endpointName"); var endpointCreateParameters = new AFDEndpoint("WestUs") { EnabledState = "Enabled", OriginResponseTimeoutSeconds = 60, Tags = new Dictionary <string, string> { { "key1", "value1" }, { "key2", "value2" } } }; var endpoint = cdnMgmtClient.AFDEndpoints.Create(resourceGroupName, profileName, endpointName, endpointCreateParameters); // Create a standard Azure frontdoor originGroup string originGroupName = TestUtilities.GenerateName("originGroupName"); var originGroupCreateParameters = new AFDOriginGroup(name: originGroupName) { LoadBalancingSettings = new LoadBalancingSettingsParameters { SampleSize = 5, SuccessfulSamplesRequired = 4, AdditionalLatencyInMilliseconds = 200, }, HealthProbeSettings = new HealthProbeParameters { ProbeIntervalInSeconds = 1, ProbePath = "/", ProbeProtocol = ProbeProtocol.Https, ProbeRequestType = HealthProbeRequestType.GET }, }; var originGroup = cdnMgmtClient.AFDOriginGroups.Create(resourceGroupName, profileName, originGroupName, originGroupCreateParameters); // Create a standard Azure frontdoor origin string originName = TestUtilities.GenerateName("originName"); var hostName = "en.wikipedia.org"; var originCreateParameters = new AFDOrigin(hostName: hostName) { OriginHostHeader = hostName, HttpPort = 80, HttpsPort = 443, Priority = 1, Weight = 1000, }; var origin = cdnMgmtClient.AFDOrigins.Create(resourceGroupName, profileName, originGroupName, originName, originCreateParameters); // Create a standard Azure frontdoor ruleSet string ruleSetName = TestUtilities.GenerateName("ruleSetName"); var ruleSet = cdnMgmtClient.RuleSets.Create(resourceGroupName, profileName, ruleSetName); // Create a standard Azure frontdoor rule string ruleName = TestUtilities.GenerateName("ruleName"); var ruleGroupCreateParameters = new Rule { Conditions = new List <DeliveryRuleCondition>() { new DeliveryRuleRequestUriCondition() { Parameters = new RequestUriMatchConditionParameters() { OperatorProperty = "Any" } } }, Actions = new List <DeliveryRuleAction> { new DeliveryRuleCacheExpirationAction() { Parameters = new CacheExpirationActionParameters() { CacheBehavior = "Override", CacheDuration = "00:00:20" } } } }; var rule = cdnMgmtClient.Rules.Create(resourceGroupName, profileName, ruleSetName, ruleName, ruleGroupCreateParameters); // Create a standard Azure frontdoor route string routeName = TestUtilities.GenerateName("routeName"); var routeCreateParameters = new Route { OriginGroup = new ResourceReference(originGroup.Id), RuleSets = new List <ResourceReference>() { new ResourceReference(ruleSet.Id), }, PatternsToMatch = new List <string>() { "/*" }, LinkToDefaultDomain = "Enabled", EnabledState = "Enabled", }; var route = cdnMgmtClient.Routes.Create(resourceGroupName, profileName, endpointName, routeName, routeCreateParameters); Assert.NotNull(route); Assert.Equal(routeName, route.Name); var getRoute = cdnMgmtClient.Routes.Get(resourceGroupName, profileName, endpointName, routeName); Assert.NotNull(getRoute); Assert.Equal(routeName, getRoute.Name); var routList = cdnMgmtClient.Routes.ListByEndpoint(resourceGroupName, profileName, endpointName); Assert.NotNull(routList); Assert.Single(routList); cdnMgmtClient.Routes.Delete(resourceGroupName, profileName, endpointName, routeName); routList = cdnMgmtClient.Routes.ListByEndpoint(resourceGroupName, profileName, endpointName); Assert.NotNull(routList); Assert.Empty(routList); } finally { // Delete resource group _ = CdnTestUtilities.DeleteResourceGroupAsync(resourcesClient, resourceGroupName); } } }
public void AFDOriginUpdateTest() { var handler1 = new RecordedDelegatingHandler { StatusCodeToReturn = HttpStatusCode.OK }; var handler2 = new RecordedDelegatingHandler { StatusCodeToReturn = HttpStatusCode.OK }; using (MockContext context = MockContext.Start(this.GetType())) { // Create clients var cdnMgmtClient = CdnTestUtilities.GetCdnManagementClient(context, handler1); var resourcesClient = CdnTestUtilities.GetResourceManagementClient(context, handler2); // Create resource group var resourceGroupName = CdnTestUtilities.CreateResourceGroup(resourcesClient); try { // Create a standard Azure frontdoor profile string profileName = TestUtilities.GenerateName("profile"); Profile createParameters = new Profile { Location = "WestUs", Sku = new Sku { Name = SkuName.StandardAzureFrontDoor }, Tags = new Dictionary <string, string> { { "key1", "value1" }, { "key2", "value2" } } }; var profile = cdnMgmtClient.Profiles.Create(resourceGroupName, profileName, createParameters); string originGroupName = TestUtilities.GenerateName("originGroupName"); var originGroupCreateParameters = new AFDOriginGroup(name: originGroupName) { LoadBalancingSettings = new LoadBalancingSettingsParameters { SampleSize = 5, SuccessfulSamplesRequired = 4, AdditionalLatencyInMilliseconds = 200, }, HealthProbeSettings = new HealthProbeParameters { ProbeIntervalInSeconds = 1, ProbePath = "/", ProbeProtocol = ProbeProtocol.Https, ProbeRequestType = HealthProbeRequestType.GET }, }; var originGroup = cdnMgmtClient.AFDOriginGroups.Create(resourceGroupName, profileName, originGroupName, originGroupCreateParameters); Assert.NotNull(originGroup); Assert.Equal(originGroupName, originGroup.Name); string originName = TestUtilities.GenerateName("originName"); var hostName = "en.wikipedia.org"; var originCreateParameters = new AFDOrigin(hostName: hostName) { OriginHostHeader = hostName, HttpPort = 80, HttpsPort = 443, Priority = 1, Weight = 1000, }; var origin = cdnMgmtClient.AFDOrigins.Create(resourceGroupName, profileName, originGroupName, originName, originCreateParameters); VerifyOriginCreated(originName, originCreateParameters, origin); var originUpdateProperties = new AFDOriginUpdateParameters { HostName = "update." + hostName, OriginHostHeader = "update." + hostName, HttpPort = 81, HttpsPort = 443, Priority = 2, Weight = 100, }; var updatedOrigin = cdnMgmtClient.AFDOrigins.Update(resourceGroupName, profileName, originGroupName, originName, originUpdateProperties); VerifyOriginUpdated(originUpdateProperties, updatedOrigin); } finally { // Delete resource group _ = CdnTestUtilities.DeleteResourceGroupAsync(resourcesClient, resourceGroupName); } } }
private static void VerifyOriginUpdated(AFDOriginUpdateParameters originUpdateProperties, AFDOrigin origin) { Assert.NotNull(origin); Assert.Equal(originUpdateProperties.HostName, origin.HostName); Assert.Equal(originUpdateProperties.OriginHostHeader, origin.OriginHostHeader); Assert.Equal(originUpdateProperties.HttpPort, origin.HttpPort); Assert.Equal(originUpdateProperties.HttpsPort, origin.HttpsPort); Assert.Equal(originUpdateProperties.Priority, origin.Priority); Assert.Equal(originUpdateProperties.Weight, origin.Weight); }
/// <summary> /// Creates a new origin within the specified origin group. /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='resourceGroupName'> /// Name of the Resource group within the Azure subscription. /// </param> /// <param name='profileName'> /// Name of the CDN profile which is unique within the resource group. /// </param> /// <param name='originGroupName'> /// Name of the origin group which is unique within the profile. /// </param> /// <param name='originName'> /// Name of the origin that is unique within the profile. /// </param> /// <param name='origin'> /// Origin properties /// </param> /// <param name='cancellationToken'> /// The cancellation token. /// </param> public static async Task <AFDOrigin> BeginCreateAsync(this IAFDOriginsOperations operations, string resourceGroupName, string profileName, string originGroupName, string originName, AFDOrigin origin, CancellationToken cancellationToken = default(CancellationToken)) { using (var _result = await operations.BeginCreateWithHttpMessagesAsync(resourceGroupName, profileName, originGroupName, originName, origin, null, cancellationToken).ConfigureAwait(false)) { return(_result.Body); } }
/// <summary> /// Creates a new origin within the specified origin group. /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='resourceGroupName'> /// Name of the Resource group within the Azure subscription. /// </param> /// <param name='profileName'> /// Name of the CDN profile which is unique within the resource group. /// </param> /// <param name='originGroupName'> /// Name of the origin group which is unique within the profile. /// </param> /// <param name='originName'> /// Name of the origin that is unique within the profile. /// </param> /// <param name='origin'> /// Origin properties /// </param> public static AFDOrigin BeginCreate(this IAFDOriginsOperations operations, string resourceGroupName, string profileName, string originGroupName, string originName, AFDOrigin origin) { return(operations.BeginCreateAsync(resourceGroupName, profileName, originGroupName, originName, origin).GetAwaiter().GetResult()); }