public async Task RouteFilterApiTest() { SubscriptionResource subscription = await ArmClient.GetDefaultSubscriptionAsync(); var filterCollection = await GetCollection(); // Create route filter string filterName = Recording.GenerateAssetName("filter"); string ruleName = Recording.GenerateAssetName("rule"); RouteFilterResource filter = await CreateDefaultRouteFilter(filterCollection, filterName); Assert.AreEqual("Succeeded", filter.Data.ProvisioningState.ToString()); Assert.AreEqual(filterName, filter.Data.Name); Assert.IsEmpty(filter.Data.Rules); var filters = await filterCollection.GetAllAsync().ToEnumerableAsync(); Has.One.Equals(filters); Assert.AreEqual(filterName, filters[0].Data.Name); Assert.IsEmpty(filters[0].Data.Rules); var allFilters = await subscription.GetRouteFiltersAsync().ToEnumerableAsync(); // there could be other filters in the current subscription Assert.True(allFilters.Any(f => filterName == f.Data.Name && f.Data.Rules.Count == 0)); // Crete route filter rule RouteFilterRuleResource filterRule = await CreateDefaultRouteFilterRule(filter, ruleName); Assert.AreEqual("Succeeded", filterRule.Data.ProvisioningState.ToString()); Assert.AreEqual(ruleName, filterRule.Data.Name); Response <RouteFilterResource> getFilterResponse = await filterCollection.GetAsync(filterName); Assert.AreEqual(filterName, getFilterResponse.Value.Data.Name); filter = await filterCollection.GetAsync(filterName); Assert.AreEqual(filterName, filter.Data.Name); Has.One.Equals(filter.Data.Rules); Assert.AreEqual(ruleName, filter.Data.Rules[0].Name); filterRule = await filter.GetRouteFilterRules().GetAsync(ruleName); Assert.AreEqual(ruleName, filterRule.Data.Name); // Update route filter filterRule.Data.Access = Access.Deny; var operation = InstrumentOperation(await filter.GetRouteFilterRules().CreateOrUpdateAsync(WaitUntil.Completed, ruleName, filterRule.Data)); await operation.WaitForCompletionAsync(); Assert.AreEqual(ruleName, filterRule.Data.Name); Assert.AreEqual(Access.Deny, filterRule.Data.Access); // Add filter rule, this will fail due to the limitation of maximum 1 rule per filter Assert.ThrowsAsync <RequestFailedException>(async() => await CreateDefaultRouteFilterRule(filter, Recording.GenerateAssetName("rule2"))); filter = await filterCollection.GetAsync(filterName); Has.One.Equals(filter.Data.Rules); Assert.AreEqual(ruleName, filter.Data.Rules[0].Name); // Delete fileter rule await filterRule.DeleteAsync(WaitUntil.Completed); var rules = await filter.GetRouteFilterRules().GetAllAsync().ToEnumerableAsync(); Assert.IsEmpty(rules); // Delete filter await filter.DeleteAsync(WaitUntil.Completed); allFilters = await subscription.GetRouteFiltersAsync().ToEnumerableAsync(); Assert.False(allFilters.Any(f => filter.Id == f.Id)); }