public async Task Delete()
        {
            Subscription subscription = await Client.GetDefaultSubscriptionAsync();

            ResourceGroup rg = await CreateResourceGroup(subscription, "testRg-");

            string  afdProfileName = Recording.GenerateAssetName("AFDProfile-");
            Profile afdProfile     = await CreateAfdProfile(rg, afdProfileName, SkuName.StandardAzureFrontDoor);

            string      afdEndpointName     = Recording.GenerateAssetName("AFDEndpoint-");
            AfdEndpoint afdEndpointInstance = await CreateAfdEndpoint(afdProfile, afdEndpointName);

            string         afdOriginGroupName     = Recording.GenerateAssetName("AFDOriginGroup-");
            AfdOriginGroup afdOriginGroupInstance = await CreateAfdOriginGroup(afdProfile, afdOriginGroupName);

            string    afdOriginName     = Recording.GenerateAssetName("AFDOrigin-");
            AfdOrigin afdOriginInstance = await CreateAfdOrigin(afdOriginGroupInstance, afdOriginName);

            string     afdRuleSetName = Recording.GenerateAssetName("AFDRuleSet");
            AfdRuleSet afdRuleSet     = await CreateAfdRuleSet(afdProfile, afdRuleSetName);

            string   afdRouteName = Recording.GenerateAssetName("AFDRoute");
            AfdRoute afdRoute     = await CreateAfdRoute(afdEndpointInstance, afdRouteName, afdOriginGroupInstance, afdRuleSet);

            await afdRoute.DeleteAsync();

            var ex = Assert.ThrowsAsync <RequestFailedException>(async() => await afdRoute.GetAsync());

            Assert.AreEqual(404, ex.Status);
        }
 public static void AssertValidAfdOriginGroup(AfdOriginGroup model, AfdOriginGroup getResult)
 {
     Assert.AreEqual(model.Data.Name, getResult.Data.Name);
     Assert.AreEqual(model.Data.Id, getResult.Data.Id);
     Assert.AreEqual(model.Data.Type, getResult.Data.Type);
     if (model.Data.LoadBalancingSettings != null || getResult.Data.LoadBalancingSettings != null)
     {
         Assert.NotNull(model.Data.LoadBalancingSettings);
         Assert.NotNull(getResult.Data.LoadBalancingSettings);
         Assert.AreEqual(model.Data.LoadBalancingSettings.SampleSize, getResult.Data.LoadBalancingSettings.SampleSize);
         Assert.AreEqual(model.Data.LoadBalancingSettings.SuccessfulSamplesRequired, getResult.Data.LoadBalancingSettings.SuccessfulSamplesRequired);
         Assert.AreEqual(model.Data.LoadBalancingSettings.AdditionalLatencyInMilliseconds, getResult.Data.LoadBalancingSettings.AdditionalLatencyInMilliseconds);
     }
     if (model.Data.HealthProbeSettings != null || getResult.Data.HealthProbeSettings != null)
     {
         Assert.NotNull(model.Data.HealthProbeSettings);
         Assert.NotNull(getResult.Data.HealthProbeSettings);
         Assert.AreEqual(model.Data.HealthProbeSettings.ProbeIntervalInSeconds, getResult.Data.HealthProbeSettings.ProbeIntervalInSeconds);
         Assert.AreEqual(model.Data.HealthProbeSettings.ProbePath, getResult.Data.HealthProbeSettings.ProbePath);
         Assert.AreEqual(model.Data.HealthProbeSettings.ProbeProtocol, getResult.Data.HealthProbeSettings.ProbeProtocol);
         Assert.AreEqual(model.Data.HealthProbeSettings.ProbeRequestType, getResult.Data.HealthProbeSettings.ProbeRequestType);
     }
     Assert.AreEqual(model.Data.TrafficRestorationTimeToHealedOrNewEndpointsInMinutes, getResult.Data.TrafficRestorationTimeToHealedOrNewEndpointsInMinutes);
     Assert.AreEqual(model.Data.SessionAffinityState, getResult.Data.SessionAffinityState);
     Assert.AreEqual(model.Data.ProvisioningState, getResult.Data.ProvisioningState);
     Assert.AreEqual(model.Data.DeploymentStatus, getResult.Data.DeploymentStatus);
     //Todo: ResponseBasedAfdOriginErrorDetectionSettings
 }
        public async Task Update()
        {
            Subscription subscription = await Client.GetDefaultSubscriptionAsync();

            ResourceGroup rg = await CreateResourceGroup(subscription, "testRg-");

            string  afdProfileName = Recording.GenerateAssetName("AFDProfile-");
            Profile afdProfile     = await CreateAfdProfile(rg, afdProfileName, SkuName.StandardAzureFrontDoor);

            string      afdEndpointName     = Recording.GenerateAssetName("AFDEndpoint-");
            AfdEndpoint afdEndpointInstance = await CreateAfdEndpoint(afdProfile, afdEndpointName);

            string         afdOriginGroupName     = Recording.GenerateAssetName("AFDOriginGroup-");
            AfdOriginGroup afdOriginGroupInstance = await CreateAfdOriginGroup(afdProfile, afdOriginGroupName);

            string    afdOriginName     = Recording.GenerateAssetName("AFDOrigin-");
            AfdOrigin afdOriginInstance = await CreateAfdOrigin(afdOriginGroupInstance, afdOriginName);

            string     afdRuleSetName = Recording.GenerateAssetName("AFDRuleSet");
            AfdRuleSet afdRuleSet     = await CreateAfdRuleSet(afdProfile, afdRuleSetName);

            string   afdRouteName = Recording.GenerateAssetName("AFDRoute");
            AfdRoute afdRoute     = await CreateAfdRoute(afdEndpointInstance, afdRouteName, afdOriginGroupInstance, afdRuleSet);

            RouteUpdateOptions updateOptions = new RouteUpdateOptions
            {
                EnabledState = EnabledState.Disabled
            };
            var lro = await afdRoute.UpdateAsync(updateOptions);

            AfdRoute updatedAfdRoute = lro.Value;

            ResourceDataHelper.AssertAfdRouteUpdate(updatedAfdRoute, updateOptions);
        }
Ejemplo n.º 4
0
        public async Task List()
        {
            Subscription subscription = await Client.GetDefaultSubscriptionAsync();

            ResourceGroup rg = await CreateResourceGroup(subscription, "testRg-");

            string  afdProfileName = Recording.GenerateAssetName("AFDProfile-");
            Profile afdProfile     = await CreateAfdProfile(rg, afdProfileName, CdnSkuName.StandardAzureFrontDoor);

            string      afdEndpointName     = Recording.GenerateAssetName("AFDEndpoint-");
            AfdEndpoint afdEndpointInstance = await CreateAfdEndpoint(afdProfile, afdEndpointName);

            string         afdOriginGroupName     = Recording.GenerateAssetName("AFDOriginGroup-");
            AfdOriginGroup afdOriginGroupInstance = await CreateAfdOriginGroup(afdProfile, afdOriginGroupName);

            string afdOriginName = Recording.GenerateAssetName("AFDOrigin-");

            _ = await CreateAfdOrigin(afdOriginGroupInstance, afdOriginName);

            string     afdRuleSetName = Recording.GenerateAssetName("AFDRuleSet");
            AfdRuleSet afdRuleSet     = await CreateAfdRuleSet(afdProfile, afdRuleSetName);

            string afdRouteName = Recording.GenerateAssetName("AFDRoute");

            _ = await CreateAfdRoute(afdEndpointInstance, afdRouteName, afdOriginGroupInstance, afdRuleSet);

            int count = 0;

            await foreach (var tempRoute in afdEndpointInstance.GetAfdRoutes().GetAllAsync())
            {
                count++;
            }
            Assert.AreEqual(count, 1);
        }
        public async Task Update()
        {
            SubscriptionResource subscription = await Client.GetDefaultSubscriptionAsync();

            ResourceGroupResource rg = await CreateResourceGroup(subscription, "testRg-");

            string          afdProfileName     = Recording.GenerateAssetName("AFDProfile-");
            ProfileResource afdProfileResource = await CreateAfdProfile(rg, afdProfileName, CdnSkuName.StandardAzureFrontDoor);

            string         afdOriginGroupName     = Recording.GenerateAssetName("AFDOriginGroup-");
            AfdOriginGroup afdOriginGroupInstance = await CreateAfdOriginGroup(afdProfile, afdOriginGroupName);

            string    afdOriginName     = Recording.GenerateAssetName("AFDOrigin-");
            AfdOrigin afdOriginInstance = await CreateAfdOrigin(afdOriginGroupInstance, afdOriginName);

            PatchableAfdOriginData updateOptions = new PatchableAfdOriginData
            {
                Priority = 1,
                Weight   = 150
            };
            var lro = await afdOriginInstance.UpdateAsync(WaitUntil.Completed, updateOptions);

            AfdOrigin updatedAfdOriginInstance = lro.Value;

            ResourceDataHelper.AssertAfdOriginUpdate(updatedAfdOriginInstance, updateOptions);
        }
Ejemplo n.º 6
0
        protected async Task <AfdOrigin> CreateAfdOrigin(AfdOriginGroup originGroup, string originName)
        {
            AfdOriginData input = ResourceDataHelper.CreateAfdOriginData();
            var           lro   = await originGroup.GetAfdOrigins().CreateOrUpdateAsync(true, originName, input);

            return(lro.Value);
        }
Ejemplo n.º 7
0
        public async Task Get()
        {
            Subscription subscription = await Client.GetDefaultSubscriptionAsync();

            ResourceGroup rg = await CreateResourceGroup(subscription, "testRg-");

            string  afdProfileName = Recording.GenerateAssetName("AFDProfile-");
            Profile afdProfile     = await CreateAfdProfile(rg, afdProfileName, CdnSkuName.StandardAzureFrontDoor);

            string      afdEndpointName     = Recording.GenerateAssetName("AFDEndpoint-");
            AfdEndpoint afdEndpointInstance = await CreateAfdEndpoint(afdProfile, afdEndpointName);

            string         afdOriginGroupName     = Recording.GenerateAssetName("AFDOriginGroup-");
            AfdOriginGroup afdOriginGroupInstance = await CreateAfdOriginGroup(afdProfile, afdOriginGroupName);

            string    afdOriginName     = Recording.GenerateAssetName("AFDOrigin-");
            AfdOrigin afdOriginInstance = await CreateAfdOrigin(afdOriginGroupInstance, afdOriginName);

            string     afdRuleSetName = Recording.GenerateAssetName("AFDRuleSet");
            AfdRuleSet afdRuleSet     = await CreateAfdRuleSet(afdProfile, afdRuleSetName);

            string   afdRouteName = Recording.GenerateAssetName("AFDRoute");
            AfdRoute afdRoute     = await CreateAfdRoute(afdEndpointInstance, afdRouteName, afdOriginGroupInstance, afdRuleSet);

            AfdRoute getAfdRoute = await afdEndpointInstance.GetAfdRoutes().GetAsync(afdRouteName);

            ResourceDataHelper.AssertValidAfdRoute(afdRoute, getAfdRoute);
            Assert.ThrowsAsync <ArgumentNullException>(async() => _ = await afdEndpointInstance.GetAfdRoutes().GetAsync(null));
        }
Ejemplo n.º 8
0
        public async Task CreateOrUpdate()
        {
            Subscription subscription = await Client.GetDefaultSubscriptionAsync();

            ResourceGroup rg = await CreateResourceGroup(subscription, "testRg-");

            string  afdProfileName = Recording.GenerateAssetName("AFDProfile-");
            Profile afdProfile     = await CreateAfdProfile(rg, afdProfileName, CdnSkuName.StandardAzureFrontDoor);

            string      afdEndpointName     = Recording.GenerateAssetName("AFDEndpoint-");
            AfdEndpoint afdEndpointInstance = await CreateAfdEndpoint(afdProfile, afdEndpointName);

            string         afdOriginGroupName     = Recording.GenerateAssetName("AFDOriginGroup-");
            AfdOriginGroup afdOriginGroupInstance = await CreateAfdOriginGroup(afdProfile, afdOriginGroupName);

            string afdOriginName = Recording.GenerateAssetName("AFDOrigin-");

            _ = await CreateAfdOrigin(afdOriginGroupInstance, afdOriginName);

            string     afdRuleSetName = Recording.GenerateAssetName("AFDRuleSet");
            AfdRuleSet afdRuleSet     = await CreateAfdRuleSet(afdProfile, afdRuleSetName);

            string   afdRouteName = Recording.GenerateAssetName("AFDRoute");
            AfdRoute afdRoute     = await CreateAfdRoute(afdEndpointInstance, afdRouteName, afdOriginGroupInstance, afdRuleSet);

            Assert.AreEqual(afdRouteName, afdRoute.Data.Name);
            Assert.ThrowsAsync <ArgumentNullException>(async() => _ = await afdEndpointInstance.GetAfdRoutes().CreateOrUpdateAsync(WaitUntil.Completed, null, afdRoute.Data));
            Assert.ThrowsAsync <ArgumentNullException>(async() => _ = await afdEndpointInstance.GetAfdRoutes().CreateOrUpdateAsync(WaitUntil.Completed, afdRouteName, null));
        }
        public async Task Update()
        {
            Subscription subscription = await Client.GetDefaultSubscriptionAsync();

            ResourceGroup rg = await CreateResourceGroup(subscription, "testRg-");

            string  afdProfileName = Recording.GenerateAssetName("AFDProfile-");
            Profile afdProfile     = await CreateAfdProfile(rg, afdProfileName, SkuName.StandardAzureFrontDoor);

            string         afdOriginGroupName     = Recording.GenerateAssetName("AFDOriginGroup-");
            AfdOriginGroup afdOriginGroupInstance = await CreateAfdOriginGroup(afdProfile, afdOriginGroupName);

            AfdOriginGroupUpdateOptions updateOptions = new AfdOriginGroupUpdateOptions
            {
                LoadBalancingSettings = new LoadBalancingSettingsParameters
                {
                    SampleSize = 10,
                    SuccessfulSamplesRequired       = 5,
                    AdditionalLatencyInMilliseconds = 500
                }
            };
            var lro = await afdOriginGroupInstance.UpdateAsync(true, updateOptions);

            AfdOriginGroup updatedAfdOriginGroupInstance = lro.Value;

            ResourceDataHelper.AssertAfdOriginGroupUpdate(updatedAfdOriginGroupInstance, updateOptions);
        }
 public static AfdRouteData CreateAfdRouteData(AfdOriginGroup originGroup) => new AfdRouteData
 {
     OriginGroup = new WritableSubResource
     {
         Id = originGroup.Id
     },
     LinkToDefaultDomain = LinkToDefaultDomain.Enabled,
     EnabledState        = EnabledState.Enabled
 };
Ejemplo n.º 11
0
        public async Task CreateOrUpdate()
        {
            Subscription subscription = await Client.GetDefaultSubscriptionAsync();

            ResourceGroup rg = await CreateResourceGroup(subscription, "testRg-");

            string  afdProfileName = Recording.GenerateAssetName("AFDProfile-");
            Profile afdProfile     = await CreateAfdProfile(rg, afdProfileName, SkuName.StandardAzureFrontDoor);

            string         afdOriginGroupName     = Recording.GenerateAssetName("AFDOriginGroup-");
            AfdOriginGroup afdOriginGroupInstance = await CreateAfdOriginGroup(afdProfile, afdOriginGroupName);

            Assert.AreEqual(afdOriginGroupName, afdOriginGroupInstance.Data.Name);
            Assert.ThrowsAsync <ArgumentNullException>(async() => _ = await afdProfile.GetAfdOriginGroups().CreateOrUpdateAsync(null, afdOriginGroupInstance.Data));
            Assert.ThrowsAsync <ArgumentNullException>(async() => _ = await afdProfile.GetAfdOriginGroups().CreateOrUpdateAsync(afdOriginGroupName, null));
        }
        public async Task Get()
        {
            SubscriptionResource subscription = await Client.GetDefaultSubscriptionAsync();

            ResourceGroupResource rg = await CreateResourceGroup(subscription, "testRg-");

            string          afdProfileName     = Recording.GenerateAssetName("AFDProfile-");
            ProfileResource afdProfileResource = await CreateAfdProfile(rg, afdProfileName, CdnSkuName.StandardAzureFrontDoor);

            string         afdOriginGroupName     = Recording.GenerateAssetName("AFDOriginGroup-");
            AfdOriginGroup afdOriginGroupInstance = await CreateAfdOriginGroup(afdProfile, afdOriginGroupName);

            AfdOriginGroup getAfdOriginGroupInstance = await afdProfile.GetAfdOriginGroups().GetAsync(afdOriginGroupName);

            ResourceDataHelper.AssertValidAfdOriginGroup(afdOriginGroupInstance, getAfdOriginGroupInstance);
            Assert.ThrowsAsync <ArgumentNullException>(async() => _ = await afdProfile.GetAfdOriginGroups().GetAsync(null));
        }
Ejemplo n.º 13
0
        public async Task Delete()
        {
            Subscription subscription = await Client.GetDefaultSubscriptionAsync();

            ResourceGroup rg = await CreateResourceGroup(subscription, "testRg-");

            string  afdProfileName = Recording.GenerateAssetName("AFDProfile-");
            Profile afdProfile     = await CreateAfdProfile(rg, afdProfileName, CdnSkuName.StandardAzureFrontDoor);

            string         afdOriginGroupName     = Recording.GenerateAssetName("AFDOriginGroup-");
            AfdOriginGroup afdOriginGroupInstance = await CreateAfdOriginGroup(afdProfile, afdOriginGroupName);

            await afdOriginGroupInstance.DeleteAsync(WaitUntil.Completed);

            var ex = Assert.ThrowsAsync <RequestFailedException>(async() => await afdOriginGroupInstance.GetAsync());

            Assert.AreEqual(404, ex.Status);
        }
        public async Task GetResourceUsage()
        {
            Subscription subscription = await Client.GetDefaultSubscriptionAsync();

            ResourceGroup rg = await CreateResourceGroup(subscription, "testRg-");

            string  afdProfileName = Recording.GenerateAssetName("AFDProfile-");
            Profile afdProfile     = await CreateAfdProfile(rg, afdProfileName, SkuName.StandardAzureFrontDoor);

            string         afdOriginGroupName     = Recording.GenerateAssetName("AFDOriginGroup-");
            AfdOriginGroup afdOriginGroupInstance = await CreateAfdOriginGroup(afdProfile, afdOriginGroupName);

            int count = 0;

            await foreach (var tempUsage in afdOriginGroupInstance.GetResourceUsageAsync())
            {
                count++;
                Assert.AreEqual(tempUsage.Unit, UsageUnit.Count);
                Assert.AreEqual(tempUsage.CurrentValue, 0);
            }
            Assert.AreEqual(count, 1);
        }
 public static void AssertAfdOriginGroupUpdate(AfdOriginGroup updatedAfdOriginGroup, AfdOriginGroupUpdateOptions updateOptions)
 {
     Assert.AreEqual(updatedAfdOriginGroup.Data.LoadBalancingSettings.SampleSize, updateOptions.LoadBalancingSettings.SampleSize);
     Assert.AreEqual(updatedAfdOriginGroup.Data.LoadBalancingSettings.SuccessfulSamplesRequired, updateOptions.LoadBalancingSettings.SuccessfulSamplesRequired);
     Assert.AreEqual(updatedAfdOriginGroup.Data.LoadBalancingSettings.AdditionalLatencyInMilliseconds, updateOptions.LoadBalancingSettings.AdditionalLatencyInMilliseconds);
 }
Ejemplo n.º 16
0
        protected async Task <AfdRoute> CreateAfdRoute(AfdEndpoint endpoint, string routeName, AfdOriginGroup originGroup, AfdRuleSet ruleSet)
        {
            AfdRouteData input = ResourceDataHelper.CreateAfdRouteData(originGroup);

            input.RuleSets.Add(new WritableSubResource
            {
                Id = ruleSet.Id
            });
            input.PatternsToMatch.Add("/*");
            var lro = await endpoint.GetAfdRoutes().CreateOrUpdateAsync(true, routeName, input);

            return(lro.Value);
        }