You need to enable JavaScript to run this app.
Volcano Engine Function as a Service

Volcano Engine Function as a Service

Copy page
Download PDF
Asynchronous task
Submitting tasks
Copy page
Download PDF
Submitting tasks
This topic describes how to submit an asynchronous task. After a task is submitted, veFaaS returns the status code 202 (Accepted) and the unique identifier RequestID for the task. You can use the RequestID to query the execution status of the task or terminate the task.​
WebServer mode​
For asynchronous tasks in WebServer mode, you can submit them using one of the following three methods.​
Scheduled submission​
After the service is released, you can configure a timer trigger for the task to enable scheduled execution.​
Via an APIG domain name​
After the service is released, you can configure an APIG trigger for the service to submit tasks by calling the APIG domain name.​
  1. Submit tasks by calling the domain name of the gateway. The following curl command provides an example:​
​
curl --location 'https://api_gateway_address/' \​
--header 'Content-Type: application/json' \​
--data '{​
"test": "hello veFaaS!"​
}'​
​
In-console testing ​
After the service is released, you can initiate function testing in the console to simulate task submission via a timer or via the gateway domain name. For details, see Testing functions.​
Non-WebServer mode​
For asynchronous tasks in non-WebServer mode, you can submit them using one of the following three methods.​
Scheduled submission​
After the service is released, you can configure a timer trigger for the task to enable scheduled execution.​
Via an APIG domain name​
After the service is released, you can configure an APIG trigger for the service to submit tasks by calling the APIG domain name. Depending on whether the start command is modified, there are two scenarios:​
  • If you do not customize the start command, tasks run with the start command configured in the function by default.​
  1. Submit tasks by calling the APIG domain name. Submit tasks directly by calling the gateway domain name without including a payload in the request.​
  • The following curl command provides an example:​
  • ​
    curl -k --location 'https://api_gateway_address/'​
    ​
  • If a custom start command is provided, tasks run with the custom start command.​
  1. Submit tasks by calling the APIG domain name.​
  1. In the POST request, include header 'X-Faas-Custom-Task: true' to declare that tasks require a custom startup command.​
  1. Specify the startup command using the Command field in the JSON-formatted payload.​
  • The following curl command provides an example:​
tip​
The start command cannot exceed 256 characters in length.​
  • ​
    # Example 1: Custom parameters​
    curl --location 'https://api_gateway_address/' \​
    --header 'X-Faas-Custom-Task: true' \​
    --header 'Content-Type: application/json' \​
    --data '{​
    "Command": "./run.sh --foo=bar"​
    }'​
    ​
    # Example 2: Custom startup command (Ensure the corresponding startup script exists in your code package or image)​
    curl --location 'https://api_gateway_address/' \​
    --header 'X-Faas-Custom-Task: true' \​
    --header 'Content-Type: application/json' \​
    --data '{​
    "Command": "./custom-script.sh"​
    }'​
    ​
In-console testing​
After the service is released, you can initiate function testing in the console to simulate task submission via a timer or via the gateway domain name. When simulating task submission via the APIG domain name, you can specify a custom start command.​
  1. On the function details page, click Test.​
  1. On the function test page, configure the relevant parameters.​
  • ​
    Parameter​
    Description​
    Trigger type​
    Select Timer trigger or APIG trigger.​
    Startup command​
    If you select APIG trigger, you can specify a custom startup command. If you do not provide a startup command, the default startup command in the function configuration will be used.​
    ​
  1. Click Test.​
  • After the task is submitted, the console returns the RequestID. Click View details to go to the asynchronous task list and view the execution status of the current task.​
​
Last updated: 2026.08.19 14:06:06