In the Function Compute console, complete the following steps:
- On the code management page, click Event.
- Create the event based on your needs. You can set JSON string or raw string.
- Click OK.
This creates the event that is sent by the MNS topic trigger to the function. You can use this method to debug and test the function.
On the code management page, click Triggers.
Set the type of the trigger to MNS Topic Trigger and select the topic created in step one.
Note: We recommend that you select a topic that has the same region as the function.
- Select the system role AliyunMNSNotificationRole as the trigger role.
For each trigger, you need to specify a trigger role that is authorized to trigger the function. MNS needs to be assigned these permissions to trigger the function.
For more information about roles, see User permissions.
After you have configured the trigger, log on to the Message Service console, find the topic, and check its subscription list. If the function is subscribed to this topic, publish a message to this topic and use Log Service to check if the function has been executed.