All Products
Document Center

1. Create functions

Last Updated: Dec 11, 2018

Make sure you have activated Message Service before you go through the following steps.

  1. Log on to the MNS console, click Topics, select a region, and click Create Topic to create a topic.

  2. Log on to the Function Compute console or use fcli to submit your function. The following example creates a function in the Function Compute console.

Python sample code

You can use the following code as a template to create functions associated with MNS topic triggers.

  1. import json
  2. import logging
  3. def handler(event, context):
  4. logger = logging.getLogger()
  5."rds trigger event = {}".format(event))
  6. # do your things, for example, record event to tablestore
  7. return "OK"

Parameter description

event is the input parameter of the function and represents the messages that are published to the MNS topic.

Next step

Step 2: Test the function