Пример #1
0
        public async Task DeleteCdnWebApplicationFirewallPolicies()
        {
            #region Snippet:Managing_CdnWebApplicationFirewallPolicies_DeleteAWebApplicationFirewallPolicy
            // First we need to get the cdn web application firewall policy collection from the specific resource group
            CdnWebApplicationFirewallPolicyCollection policyCollection = resourceGroup.GetCdnWebApplicationFirewallPolicies();
            // Now we can get the policy with GetAsync()
            CdnWebApplicationFirewallPolicy policy = await policyCollection.GetAsync("myPolicy");

            // With DeleteAsync(), we can delete the policy
            await policy.DeleteAsync(WaitUntil.Completed);

            #endregion Snippet:Managing_CdnWebApplicationFirewallPolicies_DeleteAWebApplicationFirewallPolicy
        }
        public async Task Delete()
        {
            Subscription subscription = await Client.GetDefaultSubscriptionAsync();

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

            string policyName = Recording.GenerateAssetName("Policy");
            CdnWebApplicationFirewallPolicy policy = await CreatePolicy(rg, policyName);

            await policy.DeleteAsync(true);

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

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