Skip to content

Commit eb8604a

Browse files
committed
added examples for subject filtering
1 parent 72ff1cb commit eb8604a

File tree

1 file changed

+33
-7
lines changed

1 file changed

+33
-7
lines changed

articles/event-grid/event-filtering.md

Lines changed: 33 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -96,17 +96,43 @@ The JSON syntax for filtering by event type is:
9696

9797
For simple filtering by subject, specify a starting or ending value for the subject. For example, you can specify the subject ends with `.txt` to only get events related to uploading a text file to storage account. Or, you can filter the subject begins with `/blobServices/default/containers/testcontainer` to get all events for that container but not other containers in the storage account.
9898

99-
When publishing events to custom topics, create subjects for your events that make it easy for subscribers to know whether they're interested in the event. Subscribers use the subject property to filter and route events. Consider adding the path for where the event happened, so subscribers can filter by segments of that path. The path enables subscribers to narrowly or broadly filter events. If you provide a three segment path like `/A/B/C` in the subject, subscribers can filter by the first segment `/A` to get a broad set of events. Those subscribers get events with subjects like `/A/B/C` or `/A/D/E`. Other subscribers can filter by `/A/B` to get a narrower set of events.
99+
When publishing events to custom topics, create subjects for your events that make it easy for subscribers to know whether they're interested in the event. Subscribers use the **subject** property to filter and route events. Consider adding the path for where the event happened, so subscribers can filter by segments of that path. The path enables subscribers to narrowly or broadly filter events. If you provide a three segment path like `/A/B/C` in the subject, subscribers can filter by the first segment `/A` to get a broad set of events. Those subscribers get events with subjects like `/A/B/C` or `/A/D/E`. Other subscribers can filter by `/A/B` to get a narrower set of events.
100100

101-
The JSON syntax for filtering by subject is:
101+
### Examples (Blob Storage events)
102+
Blob events can be filtered by the event type, container name, or name of the object that was created or deleted.
102103

103-
```json
104-
"filter": {
105-
"subjectBeginsWith": "/blobServices/default/containers/mycontainer/blobs/log",
106-
"subjectEndsWith": ".jpg"
107-
}
104+
The subject of Blob storage events uses the format:
108105

109106
```
107+
/blobServices/default/containers/<containername>/blobs/<blobname>
108+
```
109+
110+
To match all events for a storage account, you can leave the subject filters empty.
111+
112+
To match events from blobs created in a set of containers sharing a prefix, use a `subjectBeginsWith` filter like:
113+
114+
```
115+
/blobServices/default/containers/containerprefix
116+
```
117+
118+
To match events from blobs created in specific container, use a `subjectBeginsWith` filter like:
119+
120+
```
121+
/blobServices/default/containers/containername/
122+
```
123+
124+
To match events from blobs created in specific container sharing a blob name prefix, use a `subjectBeginsWith` filter like:
125+
126+
```
127+
/blobServices/default/containers/containername/blobs/blobprefix
128+
```
129+
To match events from blobs create in a specific subfolder of a container, use a `subjectBeginsWith` filter like:
130+
131+
```
132+
/blobServices/default/containers/{containername}/blobs/{subfolder}/
133+
```
134+
135+
To match events from blobs created in specific container sharing a blob suffix, use a `subjectEndsWith` filter like ".log" or ".jpg".
110136

111137
## Advanced filtering
112138

0 commit comments

Comments
 (0)