Exemple #1
0
        protected async Task <CdnCustomDomain> CreateCdnCustomDomain(CdnEndpoint endpoint, string customDomainName, string hostName)
        {
            CustomDomainOptions input = ResourceDataHelper.CreateCdnCustomDomainData(hostName);
            var lro = await endpoint.GetCdnCustomDomains().CreateOrUpdateAsync(true, customDomainName, input);

            return(lro.Value);
        }
Exemple #2
0
        public async Task List()
        {
            //In this test, the CName mapping from custom domain "customdomaintest-2.azuretest.net" to endpoint "testEndpoint4dotnetsdk.azureedge.net" is created in advance.
            Subscription subscription = await Client.GetDefaultSubscriptionAsync();

            ResourceGroup rg = await subscription.GetResourceGroups().GetAsync("CdnTest");

            Profile cdnProfile = await rg.GetProfiles().GetAsync("testProfile");

            CdnEndpoint cdnEndpoint = await cdnProfile.GetCdnEndpoints().GetAsync("testEndpoint4dotnetsdk");

            string cdnCustomDomainName = Recording.GenerateAssetName("customDomain-");
            string hostName            = "customdomaintest-2.azuretest.net";

            _ = await CreateCdnCustomDomain(cdnEndpoint, cdnCustomDomainName, hostName);

            int count = 0;

            await foreach (var tempCustomDomain in cdnEndpoint.GetCdnCustomDomains().GetAllAsync())
            {
                if (tempCustomDomain.Data.HostName.Equals("customdomaintest-2.azuretest.net"))
                {
                    count++;
                }
            }
            Assert.AreEqual(count, 1);
        }
Exemple #3
0
        public async Task Get()
        {
            //In this test, the CName mapping from custom domain "customdomaintest-3.azuretest.net" to endpoint "testEndpoint4dotnetsdk.azureedge.net" is created in advance.
            Subscription subscription = await Client.GetDefaultSubscriptionAsync();

            ResourceGroup rg = await subscription.GetResourceGroups().GetAsync("CdnTest");

            Profile cdnProfile = await rg.GetProfiles().GetAsync("testProfile");

            CdnEndpoint cdnEndpoint = await cdnProfile.GetCdnEndpoints().GetAsync("testEndpoint4dotnetsdk");

            string          cdnCustomDomainName = Recording.GenerateAssetName("customDomain-");
            string          hostName            = "customdomaintest-3.azuretest.net";
            CdnCustomDomain cdnCustomDomain     = await CreateCdnCustomDomain(cdnEndpoint, cdnCustomDomainName, hostName);

            CdnCustomDomain getCdnCustomDomain = await cdnEndpoint.GetCdnCustomDomains().GetAsync(cdnCustomDomainName);

            ResourceDataHelper.AssertValidCustomDomain(cdnCustomDomain, getCdnCustomDomain);
            Assert.ThrowsAsync <ArgumentNullException>(async() => _ = await cdnEndpoint.GetCdnCustomDomains().GetAsync(null));
        }
        public async Task Delete()
        {
            //In this test, the CName mapping from custom domain "customdomaintest-4.azuretest.net" to endpoint "testEndpoint4dotnetsdk.azureedge.net" is created in advance.
            //The CName mapping needs to be deleted before deleting the custom domain.
            Subscription subscription = await Client.GetDefaultSubscriptionAsync();

            ResourceGroup rg = await subscription.GetResourceGroups().GetAsync("CdnTest");

            Profile cdnProfile = await rg.GetProfiles().GetAsync("testProfile");

            CdnEndpoint cdnEndpoint = await cdnProfile.GetCdnEndpoints().GetAsync("testEndpoint4dotnetsdk");

            string cdnCustomDomainName = "customDomain-811";
            var    lro = await cdnEndpoint.GetCdnCustomDomains().GetAsync(cdnCustomDomainName);

            CdnCustomDomain cdnCustomDomain = lro.Value;
            await cdnCustomDomain.DeleteAsync();

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

            Assert.AreEqual(404, ex.Status);
        }