After you create a time trigger, you can start to define a function. This topic describes how to define a function in the Function Compute console and trigger the function at a specified time.


Create a trigger

Define a function by using Python

  1. Log on to the Function Compute console.
  2. In the top navigation bar, select a region.
  3. In the left-side navigation pane, click Service/Function.
  4. Locate the target function in the target service and click the function name.
  5. Click Code tag, and write code in the code editor.
    In the following example, Python is used to define the function.
    import json
    import logging
    logger = logging.getLogger()
    def handler(event, context):'event: %s', event)
        evt = json.loads(event)
        triggerName = evt["triggerName"]
        triggerTime = evt["triggerTime"]
        message = evt["payload"]
        creds = context.credentials'access_key_id: %s', creds.access_key_id)"message = %s", message)                        

Event format

A time trigger triggers a function by parsing the following event format:

Parameter Description
triggerTime The triggering time of the function.
triggerName The name of the time trigger.
payload The input parameters defined in the settings of the trigger.

What to do next

Debug a function