fun local invoke supports the -d, --debug-port option. This command can be used to step in a local single-step debugging function. The debugging technologies involved in the fun local are all implemented based on the common debugging protocols of each language, and can be debugged using the remote debugging methods of the corresponding language. This topic describes the naming format and related information for debugging functions by using fun local invoke commands.

Notice The content described in this article will no longer be maintained later. If your Function service resources are managed by Funcraft, we recommend that you migrate the resources to Serverless Devs.

For more information about how to migrate Function Compute-related resources from Funcraft to Serverless Devs, see Migrate resources from Funcraft to Serverless Devs.

For more information about Serverless Devs, see Overview.

For more information about how to use Serverless Devs to debug functions, see Debug Functions and Remote debug Using s Local Related Commands.

We apologize for any inconvenience caused.

Command syntax

The debugging technologies involved in the fun local are all implemented based on the common debugging protocols of each language, and the remote debugging methods of the corresponding language can be used for debugging.

There are several ways to debug the command format of local event functions:
  • Debug by using the function name.
    fun local invoke -d <your port> <your function>
  • Debug by using Service Name /Function Name.
    fun local invoke -d <your port> <your service>/<your function>

References

Event source

Function service provides a variety of triggers, including OSS triggers, Log Service triggers, and Alibaba Cloud Content Delivery Network event triggers. Whether running or debugging a function locally, in order to be able to fully simulate the on-line environment, it is usually necessary to construct a trigger event. The trigger event can be a piece of readable JSON configuration or a piece of non-readable binary data.

Take JSON as an example. Assume that the content of the trigger event is as follows.
{
    "testKey": "testValue"
}
Pass the event content to function execution in the following ways.
  • Pipe: echo '{"testKey": "testValue"}' | fun local invoke nodejs8
  • File: Write the contents of JSON to the file, customize the file name, such as event.json, and then specify the file name by -e: fun local invoke -e event.json nodejs8
  • Redirection: The following methods are supported. For more information about redirection, see Reference.
    • fun local invoke nodejs8 < event.json
    • fun local invoke nodejs8 <<< '{“testKey”: “testValue”}'