I have some long-standing Azure PowerShell code to set Advanced Filters on an Azure Event Grid Domain Subscription, running from an Azure DevOps classic release pipeline.
Up until recently, the code was working, but there have been some changes to Microsoft’s 'azure pipelines/windows-latest'
agents to update to a more recent version of Azure PowerShell (12.1.0), following which the existing code stopped working. After a little re-factoring, the majority of the functionality was restored, but I could no longer set the values for the Advanced Filters (you can have up to 25 of them per filter): the Advanced Filter Key
and OperatorType
are being added, but not the Values
. All the samples I can find imply that this code will add the values, but it doesn’t.
This is a typical code sample, reflective of my current code:
# Define the advanced filters
$advancedFilters = @(
@{
OperatorType = "StringIn";
Key = "subject";
Values = @("example1", "example2")
},
@{
OperatorType = "NumberGreaterThan";
Key = "data.size";
Value = 100
}
)
# Create the Event Grid domain subscription with advanced filters
New-AzEventGridDomainEventSubscription `
-ResourceGroupName "yourResourceGroupName" `
-DomainName "yourDomainName" `
-EventSubscriptionName "yourSubscriptionName" `
-FilterIncludedEventType @("Microsoft.Storage.BlobCreated",
"Microsoft.Storage.BlobDeleted") `
-Destination @{
EndpointType = "WebHook";
Properties = @{
EndpointUrl = "https://your-webhook-endpoint"
}
} `
-FilterEnableAdvancedFilteringOnArray $true `
-FilterAdvancedFilter $advancedFilters
From the look of the documentation for the New-AzEventGridDomainEventSubscription command, the
-FilterAdvancedFilter <IAdvancedFilter[]>
parameter takes a collection of Advanced Filter definitions, but the IAdvancedFilter interface only defines two properties, Key
and OperatorType
– there’s no mention of Values
or Value
.
I’ve searched high and low on the Internet, but all the samples indicate the code above should work. The equivalent code in the Az CLI, albeit with completely different command syntax does work, but I’m not using that and it would be a big job to change the whole script to use it.
I’ve also tried a number of other commands that take the Advanced Filters array, such as Update-AzEventGridDomainEventSubscription
, but not surprisingly, they don’t work either.
Has anyone managed to overcome this problem? Am I missing some syntactic trick to get the values to be set?