Exemplo n.º 1
0
        public async Task Update()
        {
            Subscription subscription = await Client.GetDefaultSubscriptionAsync();

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

            string  cdnProfileName = Recording.GenerateAssetName("profile-");
            Profile cdnProfile     = await CreateCdnProfile(rg, cdnProfileName, SkuName.StandardMicrosoft);

            string      cdnEndpointName = Recording.GenerateAssetName("endpoint-");
            CdnEndpoint cdnEndpoint     = await CreateCdnEndpoint(cdnProfile, cdnEndpointName);

            string         cdnOriginGroupName = Recording.GenerateAssetName("origingroup-");
            CdnOriginGroup cdnOriginGroup     = await CreateCdnOriginGroup(cdnEndpoint, cdnOriginGroupName, cdnEndpoint.Data.Origins[0].Name);

            OriginGroupUpdateOptions updateOptions = new OriginGroupUpdateOptions()
            {
                HealthProbeSettings = new HealthProbeParameters
                {
                    ProbePath              = "/healthz",
                    ProbeRequestType       = HealthProbeRequestType.Head,
                    ProbeProtocol          = ProbeProtocol.Https,
                    ProbeIntervalInSeconds = 60
                }
            };
            var lro = await cdnOriginGroup.UpdateAsync(updateOptions);

            CdnOriginGroup updatedCdnOriginGroup = lro.Value;

            ResourceDataHelper.AssertOriginGroupUpdate(updatedCdnOriginGroup, updateOptions);
        }
 public static void AssertOriginGroupUpdate(CdnOriginGroup updatedOriginGroup, OriginGroupUpdateOptions updateOptions)
 {
     Assert.AreEqual(updatedOriginGroup.Data.HealthProbeSettings.ProbePath, updateOptions.HealthProbeSettings.ProbePath);
     Assert.AreEqual(updatedOriginGroup.Data.HealthProbeSettings.ProbeRequestType, updateOptions.HealthProbeSettings.ProbeRequestType);
     Assert.AreEqual(updatedOriginGroup.Data.HealthProbeSettings.ProbeProtocol, updateOptions.HealthProbeSettings.ProbeProtocol);
     Assert.AreEqual(updatedOriginGroup.Data.HealthProbeSettings.ProbeIntervalInSeconds, updateOptions.HealthProbeSettings.ProbeIntervalInSeconds);
 }
Exemplo n.º 3
0
        public async Task UpdateOriginGroups()
        {
            #region Snippet:Managing_OriginGroups_UpdateAnOriginGroup
            // First we need to get the cdn origin group collection from the specific endpoint
            Profile profile = await resourceGroup.GetProfiles().GetAsync("myProfile");

            CdnEndpoint endpoint = await profile.GetCdnEndpoints().GetAsync("myEndpoint");

            CdnOriginGroupCollection originGroupCollection = endpoint.GetCdnOriginGroups();
            // Now we can get the origin group with GetAsync()
            CdnOriginGroup originGroup = await originGroupCollection.GetAsync("myOriginGroup");

            // With UpdateAsync(), we can update the origin group
            OriginGroupUpdateOptions input = new OriginGroupUpdateOptions()
            {
                HealthProbeSettings = new HealthProbeParameters
                {
                    ProbePath              = "/healthz",
                    ProbeRequestType       = HealthProbeRequestType.Head,
                    ProbeProtocol          = ProbeProtocol.Https,
                    ProbeIntervalInSeconds = 60
                }
            };
            CdnOriginGroupUpdateOperation lro = await originGroup.UpdateAsync(input);

            originGroup = lro.Value;
            #endregion Snippet:Managing_OriginGroups_UpdateAnOriginGroup
        }
Exemplo n.º 4
0
        public async Task DeleteOriginGroups()
        {
            #region Snippet:Managing_OriginGroups_DeleteAnOriginGroup
            // First we need to get the cdn origin group collection from the specific endpoint
            Profile profile = await resourceGroup.GetProfiles().GetAsync("myProfile");

            CdnEndpoint endpoint = await profile.GetCdnEndpoints().GetAsync("myEndpoint");

            CdnOriginGroupCollection originGroupCollection = endpoint.GetCdnOriginGroups();
            // Now we can get the origin group with GetAsync()
            CdnOriginGroup originGroup = await originGroupCollection.GetAsync("myOriginGroup");

            // With DeleteAsync(), we can delete the origin group
            await originGroup.DeleteAsync();

            #endregion Snippet:Managing_OriginGroups_DeleteAnOriginGroup
        }
        public async Task CreateOrUpdate()
        {
            Subscription subscription = await Client.GetDefaultSubscriptionAsync();

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

            string  cdnProfileName = Recording.GenerateAssetName("profile-");
            Profile cdnProfile     = await CreateCdnProfile(rg, cdnProfileName, CdnSkuName.StandardMicrosoft);

            string      cdnEndpointName = Recording.GenerateAssetName("endpoint-");
            CdnEndpoint cdnEndpoint     = await CreateCdnEndpoint(cdnProfile, cdnEndpointName);

            string         cdnOriginGroupName = Recording.GenerateAssetName("origingroup-");
            CdnOriginGroup cdnOriginGroup     = await CreateCdnOriginGroup(cdnEndpoint, cdnOriginGroupName, cdnEndpoint.Data.Origins[0].Name);

            Assert.AreEqual(cdnOriginGroupName, cdnOriginGroup.Data.Name);
            Assert.ThrowsAsync <ArgumentNullException>(async() => _ = await cdnEndpoint.GetCdnOriginGroups().CreateOrUpdateAsync(WaitUntil.Completed, null, cdnOriginGroup.Data));
            Assert.ThrowsAsync <ArgumentNullException>(async() => _ = await cdnEndpoint.GetCdnOriginGroups().CreateOrUpdateAsync(WaitUntil.Completed, cdnOriginGroupName, null));
        }
        public async Task Get()
        {
            Subscription subscription = await Client.GetDefaultSubscriptionAsync();

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

            string  cdnProfileName = Recording.GenerateAssetName("profile-");
            Profile cdnProfile     = await CreateCdnProfile(rg, cdnProfileName, CdnSkuName.StandardMicrosoft);

            string      cdnEndpointName = Recording.GenerateAssetName("endpoint-");
            CdnEndpoint cdnEndpoint     = await CreateCdnEndpoint(cdnProfile, cdnEndpointName);

            string         cdnOriginGroupName = Recording.GenerateAssetName("origingroup-");
            CdnOriginGroup cdnOriginGroup     = await CreateCdnOriginGroup(cdnEndpoint, cdnOriginGroupName, cdnEndpoint.Data.Origins[0].Name);

            CdnOriginGroup getCdnOriginGroup = await cdnEndpoint.GetCdnOriginGroups().GetAsync(cdnOriginGroupName);

            ResourceDataHelper.AssertValidOriginGroup(cdnOriginGroup, getCdnOriginGroup);
            Assert.ThrowsAsync <ArgumentNullException>(async() => _ = await cdnEndpoint.GetCdnOriginGroups().GetAsync(null));
        }
Exemplo n.º 7
0
        public async Task CreateOriginGroups()
        {
            #region Snippet:Managing_OriginGroups_CreateAnOriginGroup
            // Create a new cdn profile
            string profileName = "myProfile";
            var    input1      = new ProfileData(AzureLocation.WestUS, new Models.Sku {
                Name = SkuName.StandardMicrosoft
            });
            ProfileCreateOperation lro1 = await resourceGroup.GetProfiles().CreateOrUpdateAsync(profileName, input1);

            Profile profile = lro1.Value;
            // Get the cdn endpoint collection from the specific profile and create an endpoint
            string endpointName = "myEndpoint";
            var    input2       = new CdnEndpointData(AzureLocation.WestUS)
            {
                IsHttpAllowed    = true,
                IsHttpsAllowed   = true,
                OptimizationType = OptimizationType.GeneralWebDelivery
            };
            DeepCreatedOrigin deepCreatedOrigin = new DeepCreatedOrigin("myOrigin")
            {
                HostName = "testsa4dotnetsdk.blob.core.windows.net",
                Priority = 3,
                Weight   = 100
            };
            input2.Origins.Add(deepCreatedOrigin);
            CdnEndpointCreateOperation lro2 = await profile.GetCdnEndpoints().CreateOrUpdateAsync(endpointName, input2);

            CdnEndpoint endpoint = lro2.Value;
            // Get the cdn origin group collection from the specific endpoint and create an origin group
            string originGroupName = "myOriginGroup";
            var    input3          = new CdnOriginGroupData();
            input3.Origins.Add(new WritableSubResource
            {
                Id = new ResourceIdentifier($"{endpoint.Id}/origins/myOrigin")
            });
            CdnOriginGroupCreateOperation lro3 = await endpoint.GetCdnOriginGroups().CreateOrUpdateAsync(originGroupName, input3);

            CdnOriginGroup originGroup = lro3.Value;
            #endregion Snippet:Managing_OriginGroups_CreateAnOriginGroup
        }
Exemplo n.º 8
0
        public async Task Delete()
        {
            Subscription subscription = await Client.GetDefaultSubscriptionAsync();

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

            string  cdnProfileName = Recording.GenerateAssetName("profile-");
            Profile cdnProfile     = await CreateCdnProfile(rg, cdnProfileName, SkuName.StandardMicrosoft);

            string      cdnEndpointName = Recording.GenerateAssetName("endpoint-");
            CdnEndpoint cdnEndpoint     = await CreateCdnEndpoint(cdnProfile, cdnEndpointName);

            string         cdnOriginGroupName = Recording.GenerateAssetName("origingroup-");
            CdnOriginGroup cdnOriginGroup     = await CreateCdnOriginGroup(cdnEndpoint, cdnOriginGroupName, cdnEndpoint.Data.Origins[0].Name);

            await cdnOriginGroup.DeleteAsync();

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

            Assert.AreEqual(404, ex.Status);
        }
 public static void AssertValidOriginGroup(CdnOriginGroup model, CdnOriginGroup 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.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.Origins.Count, getResult.Data.Origins.Count);
     for (int i = 0; i < model.Data.Origins.Count; ++i)
     {
         Assert.AreEqual(model.Data.Origins[i].Id, getResult.Data.Origins[i].Id);
     }
     Assert.AreEqual(model.Data.TrafficRestorationTimeToHealedOrNewEndpointsInMinutes, getResult.Data.TrafficRestorationTimeToHealedOrNewEndpointsInMinutes);
     Assert.AreEqual(model.Data.ResourceState, getResult.Data.ResourceState);
     Assert.AreEqual(model.Data.ProvisioningState, getResult.Data.ProvisioningState);
     //Todo: ResponseBasedOriginErrorDetectionSettings
 }