DEV Community

Subash Sivaji
Subash Sivaji

Posted on

Azure event grid advanced filter limit

The azure event grid advanced filter limit is 25 filter values on a single event grid subscription, so this can be across one or more advanced filters within that single event grid subscription.

If you just have one advanced filter in an event grid subscription you can still have 25 filter values in that.

However, the azure portal will only allow us to create 5 filter values within an advanced filter (even if you just have one advanced filter!). But programmatically (CLI, PowerShell etc...) you can add more than 5 filter values. I use Azure CLI here to create an azure event grid subscription.

az eventgrid event-subscription create  --name "egsub-test" `
    --source-resource-id $source_resource_id `
    --endpoint-type "storagequeue" `
    --endpoint $endpoint `
    --advanced-filter data.api StringIn PutBlob PutBlockList FlushWithClose `
    --advanced-filter subject StringContains $test_objects `
    --subject-begins-with "$($generic_blob_prefix)/source/blobs/testpath/" `
    --subject-ends-with ".csv"

In the example I have 2 advanced filters "data.api" and "subject"

  • The "data.api" contains 3 filter values "PutBlob" "PutBlockList" "FlushWithClose"

So I can have 22 more filter values in this event grid subscription.

  • The $test_objects variable within "subject" contains 22 filter values (note: I have hidden the 22 filter values in a variable for brevity).

Once executed, this is how it looks in the portal. The event grid subscription was tested and it filters as expected.

Alt Text

If I increase $test_objects variable to 23, the CLI script will throw following error,

The total number of AdvancedFilter values allowed on a single event subscription is 25.

At the time of writing this post I found the document and portal UI slightly misleading and hence sharing this post.
https://docs.microsoft.com/en-us/azure/event-grid/event-filtering#advanced-filtering

Top comments (0)