public async Task Update() { Subscription subscription = await Client.GetDefaultSubscriptionAsync(); ResourceGroup rg = await CreateResourceGroup(subscription, "testRg-"); string afdProfileName = Recording.GenerateAssetName("AFDProfile-"); Profile afdProfile = await CreateAfdProfile(rg, afdProfileName, SkuName.StandardAzureFrontDoor); string afdEndpointName1 = Recording.GenerateAssetName("AFDEndpoint-"); AfdEndpoint afdEndpointInstance1 = await CreateAfdEndpoint(afdProfile, afdEndpointName1); string afdSecurityPolicyName = Recording.GenerateAssetName("AFDSecurityPolicy-"); AfdSecurityPolicy afdSecurityPolicy = await CreateAfdSecurityPolicy(afdProfile, afdEndpointInstance1, afdSecurityPolicyName); string afdEndpointName2 = Recording.GenerateAssetName("AFDEndpoint-"); AfdEndpoint afdEndpointInstance2 = await CreateAfdEndpoint(afdProfile, afdEndpointName2); AfdSecurityPolicyUpdateOptions updateOptions = new AfdSecurityPolicyUpdateOptions { Parameters = new SecurityPolicyWebApplicationFirewallParameters { WafPolicy = new WritableSubResource { Id = new ResourceIdentifier("/subscriptions/f3d94233-a9aa-4241-ac82-2dfb63ce637a/resourceGroups/CdnTest/providers/Microsoft.Network/frontdoorWebApplicationFirewallPolicies/testAFDWaf") } } }; SecurityPolicyWebApplicationFirewallAssociation securityPolicyWebApplicationFirewallAssociation = new SecurityPolicyWebApplicationFirewallAssociation(); securityPolicyWebApplicationFirewallAssociation.Domains.Add(new WritableSubResource { Id = afdEndpointInstance1.Id }); securityPolicyWebApplicationFirewallAssociation.Domains.Add(new WritableSubResource { Id = afdEndpointInstance2.Id }); securityPolicyWebApplicationFirewallAssociation.PatternsToMatch.Add("/*"); ((SecurityPolicyWebApplicationFirewallParameters)updateOptions.Parameters).Associations.Add(securityPolicyWebApplicationFirewallAssociation); var lro = await afdSecurityPolicy.UpdateAsync(true, updateOptions); AfdSecurityPolicy updatedSecurityPolicy = lro.Value; ResourceDataHelper.AssertAfdSecurityPolicyUpdate(updatedSecurityPolicy, updateOptions); }
public async Task ValidateCustomDomain() { Subscription subscription = await Client.GetDefaultSubscriptionAsync(); ResourceGroup rg = await CreateResourceGroup(subscription, "testRg-"); string afdProfileName = Recording.GenerateAssetName("AFDProfile-"); Profile afdProfile = await CreateAfdProfile(rg, afdProfileName, CdnSkuName.StandardAzureFrontDoor); string afdEndpointName = Recording.GenerateAssetName("AFDEndpoint-"); AfdEndpoint afdEndpointInstance = await CreateAfdEndpoint(afdProfile, afdEndpointName); ValidateCustomDomainInput validateCustomDomainInput = new ValidateCustomDomainInput("customdomain4afd.azuretest.net"); ValidateCustomDomainOutput validateCustomDomainOutput = await afdEndpointInstance.ValidateCustomDomainAsync(validateCustomDomainInput); Assert.False(validateCustomDomainOutput.CustomDomainValidated); }
public async Task Get() { Subscription subscription = await Client.GetDefaultSubscriptionAsync(); ResourceGroup rg = await CreateResourceGroup(subscription, "testRg-"); string afdProfileName = Recording.GenerateAssetName("AFDProfile-"); Profile afdProfile = await CreateAfdProfile(rg, afdProfileName, SkuName.StandardAzureFrontDoor); string afdEndpointName = Recording.GenerateAssetName("AFDEndpoint-"); AfdEndpoint afdEndpointInstance = await CreateAfdEndpoint(afdProfile, afdEndpointName); AfdEndpoint getAfdEndpointInstance = await afdProfile.GetAfdEndpoints().GetAsync(afdEndpointName); ResourceDataHelper.AssertValidAfdEndpoint(afdEndpointInstance, getAfdEndpointInstance); Assert.ThrowsAsync <ArgumentNullException>(async() => _ = await afdProfile.GetAfdEndpoints().GetAsync(null)); }
public async Task Delete() { 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-"); AfdEndpoint afdEndpointInstance = await CreateAfdEndpoint(afdProfile, afdEndpointName); await afdEndpointInstance.DeleteAsync(WaitUntil.Completed); var ex = Assert.ThrowsAsync <RequestFailedException>(async() => await afdEndpointInstance.GetAsync()); Assert.AreEqual(404, ex.Status); }
public async Task Purge() { 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-"); AfdEndpoint afdEndpointInstance = await CreateAfdEndpoint(afdProfile, afdEndpointName); AfdPurgeOptions purgeParameters = new AfdPurgeOptions(new List <string> { "/*" }); Assert.DoesNotThrowAsync(async() => await afdEndpointInstance.PurgeContentAsync(WaitUntil.Completed, purgeParameters)); }
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.PremiumAzureFrontDoor); string afdEndpointName = Recording.GenerateAssetName("AFDEndpoint-"); AfdEndpoint afdEndpointInstance = await CreateAfdEndpoint(afdProfile, afdEndpointName); string afdSecurityPolicyName = Recording.GenerateAssetName("AFDSecurityPolicy-"); AfdSecurityPolicy afdSecurityPolicy = await CreateAfdSecurityPolicy(afdProfile, afdEndpointInstance, afdSecurityPolicyName); Assert.AreEqual(afdSecurityPolicyName, afdSecurityPolicy.Data.Name); Assert.ThrowsAsync <ArgumentNullException>(async() => _ = await afdProfile.GetAfdSecurityPolicies().CreateOrUpdateAsync(WaitUntil.Completed, null, afdSecurityPolicy.Data)); Assert.ThrowsAsync <ArgumentNullException>(async() => _ = await afdProfile.GetAfdSecurityPolicies().CreateOrUpdateAsync(WaitUntil.Completed, afdSecurityPolicyName, 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.PremiumAzureFrontDoor); string afdEndpointName = Recording.GenerateAssetName("AFDEndpoint-"); AfdEndpoint afdEndpointInstance = await CreateAfdEndpoint(afdProfile, afdEndpointName); string afdSecurityPolicyName = Recording.GenerateAssetName("AFDSecurityPolicy-"); AfdSecurityPolicy afdSecurityPolicy = await CreateAfdSecurityPolicy(afdProfile, afdEndpointInstance, afdSecurityPolicyName); AfdSecurityPolicy getAfdSecurityPolicy = await afdProfile.GetAfdSecurityPolicies().GetAsync(afdSecurityPolicyName); ResourceDataHelper.AssertValidAfdSecurityPolicy(afdSecurityPolicy, getAfdSecurityPolicy); Assert.ThrowsAsync <ArgumentNullException>(async() => _ = await afdProfile.GetAfdSecurityPolicies().GetAsync(null)); }
public async Task Delete() { Subscription subscription = await Client.GetDefaultSubscriptionAsync(); ResourceGroup rg = await CreateResourceGroup(subscription, "testRg-"); string afdProfileName = Recording.GenerateAssetName("AFDProfile-"); Profile afdProfile = await CreateAfdProfile(rg, afdProfileName, SkuName.PremiumAzureFrontDoor); string afdEndpointName = Recording.GenerateAssetName("AFDEndpoint-"); AfdEndpoint afdEndpointInstance = await CreateAfdEndpoint(afdProfile, afdEndpointName); string afdSecurityPolicyName = Recording.GenerateAssetName("AFDSecurityPolicy-"); AfdSecurityPolicy afdSecurityPolicy = await CreateAfdSecurityPolicy(afdProfile, afdEndpointInstance, afdSecurityPolicyName); await afdSecurityPolicy.DeleteAsync(); var ex = Assert.ThrowsAsync <RequestFailedException>(async() => await afdSecurityPolicy.GetAsync()); Assert.AreEqual(404, ex.Status); }
public async Task Usages() { 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-"); AfdEndpoint afdEndpointInstance = await CreateAfdEndpoint(afdProfile, afdEndpointName); int count = 0; await foreach (var tempUsage in afdEndpointInstance.GetResourceUsageAsync()) { count++; Assert.AreEqual(tempUsage.CurrentValue, 0); Assert.AreEqual(tempUsage.Unit, UsageUnit.Count); } Assert.AreEqual(count, 1); }
public async Task Update() { 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-"); AfdEndpoint afdEndpointInstance = await CreateAfdEndpoint(afdProfile, afdEndpointName); PatchableAfdEndpointData updateOptions = new PatchableAfdEndpointData { OriginResponseTimeoutSeconds = 30 }; updateOptions.Tags.Add("newTag", "newValue"); var lro = await afdEndpointInstance.UpdateAsync(WaitUntil.Completed, updateOptions); AfdEndpoint updatedAfdEndpointInstance = lro.Value; ResourceDataHelper.AssertAfdEndpointUpdate(updatedAfdEndpointInstance, updateOptions); }
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.PremiumAzureFrontDoor); string afdEndpointName = Recording.GenerateAssetName("AFDEndpoint-"); AfdEndpoint afdEndpointInstance = await CreateAfdEndpoint(afdProfile, afdEndpointName); string afdSecurityPolicyName = Recording.GenerateAssetName("AFDSecurityPolicy-"); _ = await CreateAfdSecurityPolicy(afdProfile, afdEndpointInstance, afdSecurityPolicyName); int count = 0; await foreach (var tempSecurityPolicy in afdProfile.GetAfdSecurityPolicies().GetAllAsync()) { count++; } Assert.AreEqual(count, 1); }
protected async Task <AfdSecurityPolicy> CreateAfdSecurityPolicy(Profile profile, AfdEndpoint endpoint, string securityPolicyName) { AfdSecurityPolicyData input = ResourceDataHelper.CreateAfdSecurityPolicyData(endpoint); SecurityPolicyWebApplicationFirewallAssociation securityPolicyWebApplicationFirewallAssociation = new SecurityPolicyWebApplicationFirewallAssociation(); securityPolicyWebApplicationFirewallAssociation.Domains.Add(new WritableSubResource { Id = endpoint.Id }); securityPolicyWebApplicationFirewallAssociation.PatternsToMatch.Add("/*"); ((SecurityPolicyWebApplicationFirewallParameters)input.Parameters).Associations.Add(securityPolicyWebApplicationFirewallAssociation); var lro = await profile.GetAfdSecurityPolicies().CreateOrUpdateAsync(true, securityPolicyName, input); return(lro.Value); }