예제 #1
0
        protected async Task <AfdOriginGroupResource> CreateAfdOriginGroup(ProfileResource profile, string originGroupName)
        {
            AfdOriginGroupData input = ResourceDataHelper.CreateAfdOriginGroupData();
            var lro = await profile.GetAfdOriginGroups().CreateOrUpdateAsync(WaitUntil.Completed, originGroupName, input);

            return(lro.Value);
        }
        public async Task CreateOrUpdate()
        {
            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-");
            AfdOriginGroupResource afdOriginGroupInstance = await CreateAfdOriginGroup(afdProfileResource, afdOriginGroupName);

            Assert.AreEqual(afdOriginGroupName, afdOriginGroupInstance.Data.Name);
            Assert.ThrowsAsync <ArgumentNullException>(async() => _ = await afdProfileResource.GetAfdOriginGroups().CreateOrUpdateAsync(WaitUntil.Completed, null, afdOriginGroupInstance.Data));
            Assert.ThrowsAsync <ArgumentNullException>(async() => _ = await afdProfileResource.GetAfdOriginGroups().CreateOrUpdateAsync(WaitUntil.Completed, 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-");
            AfdOriginGroupResource afdOriginGroupInstance = await CreateAfdOriginGroup(afdProfileResource, afdOriginGroupName);

            AfdOriginGroupResource getAfdOriginGroupInstance = await afdProfileResource.GetAfdOriginGroups().GetAsync(afdOriginGroupName);

            ResourceDataHelper.AssertValidAfdOriginGroup(afdOriginGroupInstance, getAfdOriginGroupInstance);
            Assert.ThrowsAsync <ArgumentNullException>(async() => _ = await afdProfileResource.GetAfdOriginGroups().GetAsync(null));
        }
        public async Task List()
        {
            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-");

            _ = await CreateAfdOriginGroup(afdProfileResource, afdOriginGroupName);

            int count = 0;

            await foreach (var tempAfdOriginGroup in afdProfileResource.GetAfdOriginGroups().GetAllAsync())
            {
                count++;
            }
            Assert.AreEqual(count, 1);
        }