Ejemplo n.º 1
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
        }
        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));
        }
Ejemplo n.º 4
0
        protected async Task <CdnOriginGroup> CreateCdnOriginGroup(CdnEndpoint endpoint, string originGroupName, string originName)
        {
            CdnOriginGroupData input = ResourceDataHelper.CreateOriginGroupData();

            input.Origins.Add(new WritableSubResource
            {
                Id = new ResourceIdentifier($"{endpoint.Id}/origins/{originName}")
            });
            var lro = await endpoint.GetCdnOriginGroups().CreateOrUpdateAsync(true, originGroupName, input);

            return(lro.Value);
        }
Ejemplo n.º 5
0
        public async Task ListOriginGroups()
        {
            #region Snippet:Managing_OriginGroups_ListAllOriginGroups
            // 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();
            // With GetAllAsync(), we can get a list of the origin group in the collection
            AsyncPageable <CdnOriginGroup> response = originGroupCollection.GetAllAsync();
            await foreach (CdnOriginGroup originGroup in response)
            {
                Console.WriteLine(originGroup.Data.Name);
            }
            #endregion Snippet:Managing_OriginGroups_ListAllOriginGroups
        }
Ejemplo n.º 6
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
        }
Ejemplo 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
        }
        public async Task List()
        {
            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-");

            _ = await CreateCdnOriginGroup(cdnEndpoint, cdnOriginGroupName, cdnEndpoint.Data.Origins[0].Name);

            int count = 0;

            await foreach (var tempOriginGroup in cdnEndpoint.GetCdnOriginGroups().GetAllAsync())
            {
                count++;
            }
            Assert.AreEqual(count, 1);
        }