Invoke
serverless invoke --function functionName
Options
- --function or -f: The name of the function that you want to invoke. Required
- --data or -d: Data you want to pass into the function.
- --path or -p: The path to a JSON file which contains the input data to be transferred to the invoked function. This path is relative to the root directory of the service.
Examples
- Simple function invocation
serverless invoke --function functionName
In this example the deployed function will be invoked and the result of the invocation will be displayed in the terminal.
- Function invocation with data
serverless invoke --function functionName --data '{"name": "Bob"}'
In this example, the function will be invoked with the provided data and the result will be displayed in the terminal.
- Function invocation with passed data
serverless invoke --function functionName --path lib/event.json
In this example, the JSON data in the lib/event.json file will be passed (relative to the root of the service) while invoking the specified or deployed function.
Example of event.json{ "key": "value" }
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