Beispiel #1
0
        protected async Task <CdnOriginResource> CreateCdnOrigin(CdnEndpointResource endpoint, string originName)
        {
            CdnOriginData input = ResourceDataHelper.CreateOriginData();
            var           lro   = await endpoint.GetCdnOrigins().CreateOrUpdateAsync(WaitUntil.Completed, originName, input);

            return(lro.Value);
        }
        public async Task CreateOrUpdate()
        {
            SubscriptionResource subscription = await Client.GetDefaultSubscriptionAsync();

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

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

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

            string            cdnOriginName = Recording.GenerateAssetName("origin-");
            CdnOriginResource cdnOrigin     = await CreateCdnOrigin(cdnEndpoint, cdnOriginName);

            Assert.AreEqual(cdnOriginName, cdnOrigin.Data.Name);
            Assert.ThrowsAsync <ArgumentNullException>(async() => _ = await cdnEndpoint.GetCdnOrigins().CreateOrUpdateAsync(WaitUntil.Completed, null, cdnOrigin.Data));
            Assert.ThrowsAsync <ArgumentNullException>(async() => _ = await cdnEndpoint.GetCdnOrigins().CreateOrUpdateAsync(WaitUntil.Completed, cdnOriginName, null));
        }
        public async Task Get()
        {
            SubscriptionResource subscription = await Client.GetDefaultSubscriptionAsync();

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

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

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

            string            cdnOriginName = Recording.GenerateAssetName("origin-");
            CdnOriginResource cdnOrigin     = await CreateCdnOrigin(cdnEndpoint, cdnOriginName);

            CdnOriginResource getCdnOrigin = await cdnEndpoint.GetCdnOrigins().GetAsync(cdnOriginName);

            ResourceDataHelper.AssertValidOrigin(cdnOrigin, getCdnOrigin);
            Assert.ThrowsAsync <ArgumentNullException>(async() => _ = await cdnEndpoint.GetCdnOrigins().GetAsync(null));
        }
        public async Task List()
        {
            SubscriptionResource subscription = await Client.GetDefaultSubscriptionAsync();

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

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

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

            string cdnOriginName = Recording.GenerateAssetName("origin-");

            _ = await CreateCdnOrigin(cdnEndpoint, cdnOriginName);

            int count = 0;

            await foreach (var tempOrigin in cdnEndpoint.GetCdnOrigins().GetAllAsync())
            {
                count++;
            }
            Assert.AreEqual(count, 2);
        }