Using EG Event Notifications to Automate Image Processing in OBS
Scenarios
To improve efficiency, you may want actions such as uploading or deleting objects in your OBS bucket to automatically trigger follow-up workflows.
This practice illustrates an end-to-end solution with an example. In this example, when an image is uploaded to the source bucket, EG automatically notifies FunctionGraph of the upload event. The function then adds a watermark to the image and uploads the processed image to the target bucket.
Solution Architecture
The process is as follows:
- An image is uploaded to the source bucket. This creates an OBS event as the event source.
- EG routes the event from the source to the target through the channel to trigger the function to run.
- FunctionGraph runs the function to process the image and uploads the processed image to the target bucket.
Advantages
- You can efficiently monitor object operations in OBS buckets in real time.
- When there are multiple processes, EG event notifications can automatically trigger downstream programs. This reduces the costs of manual monitoring and execution.
Constraints
- The original image size cannot exceed 25 MB.
- EG event notifications have a certain delay, so they are not recommended for delay-sensitive service scenarios.
- A single bucket can have up to 10 EG event notification rules by default.
- New EG event notification rules take effect within 5 minutes.
- EG event notification rules for the same bucket cannot overlap. An event can only match one rule. If the rule you are creating conflicts with an existing one, the rule creation will fail.
For the same event, if an EG event notification rule has both the prefix and suffix left empty, no additional rule can be created. An empty prefix and suffix mean the rule applies to all objects.
For example, suppose there is already an EG event notification rule A for PUT events, with the prefix set to abcd and the suffix set to .txt. If you need to create another rule B for the same PUT events, configure its prefix and suffix by referring to Table 1 to make sure that your creation is successful.
Table 1 Prefix and suffix settings and creation results of rule B Rule A Prefix/Suffix
Rule B Prefix/Suffix
Rule B Creation Result
Reason
Prefix: abcd
Suffix: .txt
Prefix: abcd
Suffix: .txt
Failed
The prefixes and suffixes of both rules are completely the same.
Prefix: abcd
Suffix: left blank
Failed
Both prefixes are the same, and the suffix of rule B contains that of rule A.
Prefix: ab
Suffix: xt
Failed
Both the prefix and suffix of rule B contain those of rule A.
Prefix: abef
Suffix: .txt
Succeeded
Both rules have the same suffixes, but different prefixes.
Prefix: abcd
Suffix: .mp4
Succeeded
Both rules have the same prefixes, but different suffixes.
Resource Planning
| Resource | Resource Name | Description | Quantity | Billing |
|---|---|---|---|---|
| OBS bucket | piccomp | The source bucket for storing the uploaded image You need to create a source bucket on OBS Console. | 1 | You are billed for storing the image. For details, see Storage Space. |
| piccomp-output | The target bucket for storing the processed image You need to create a target bucket on OBS Console. | 1 | ||
| Image | example.jpg | The original image you want to add a watermark to You need to prepare the image first. | 1 | - |
| Function | FG_Test | The function for adding a watermark to the image You need to create a function on the FunctionGraph console. | 1 | You are billed for the number of requests, the execution duration, and the number of executions. For details, see FunctionGraph Billing. |
| EG event subscription | subscription-obs | An event subscription connects an event source, a channel, and an event target. The event source (an OBS event) uses the channel to trigger the event target (the function) to run. You need to create an EG event subscription on the event notification page of OBS Console. | 1 | You are billed for the number of requests. For details, see EventGrid Billing. |
Prerequisites
Your account or IAM user has the Tenant Administrator permission. For details, see Assigning Permissions to an IAM User.
Operation Process
Procedure
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot









