Ejemplo n.º 1
0
        protected async Task <AfdEndpointResource> CreateAfdEndpoint(ProfileResource profile, string endpointName)
        {
            AfdEndpointData input = ResourceDataHelper.CreateAfdEndpointData();
            var             lro   = await profile.GetAfdEndpoints().CreateOrUpdateAsync(WaitUntil.Completed, endpointName, 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 afdEndpointName = Recording.GenerateAssetName("AFDEndpoint-");
            AfdEndpointResource afdEndpointInstance = await CreateAfdEndpoint(afdProfileResource, afdEndpointName);

            Assert.AreEqual(afdEndpointName, afdEndpointInstance.Data.Name);
            Assert.ThrowsAsync <ArgumentNullException>(async() => _ = await afdProfileResource.GetAfdEndpoints().CreateOrUpdateAsync(WaitUntil.Completed, null, afdEndpointInstance.Data));
            Assert.ThrowsAsync <ArgumentNullException>(async() => _ = await afdProfileResource.GetAfdEndpoints().CreateOrUpdateAsync(WaitUntil.Completed, afdEndpointName, 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 afdEndpointName = Recording.GenerateAssetName("AFDEndpoint-");
            AfdEndpointResource afdEndpointInstance = await CreateAfdEndpoint(afdProfileResource, afdEndpointName);

            AfdEndpointResource getAfdEndpointInstance = await afdProfileResource.GetAfdEndpoints().GetAsync(afdEndpointName);

            ResourceDataHelper.AssertValidAfdEndpoint(afdEndpointInstance, getAfdEndpointInstance);
            Assert.ThrowsAsync <ArgumentNullException>(async() => _ = await afdProfileResource.GetAfdEndpoints().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 afdEndpointName = Recording.GenerateAssetName("AFDEndpoint-");

            _ = await CreateAfdEndpoint(afdProfileResource, afdEndpointName);

            int count = 0;

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