You can call the ListInstances operation to query available instances of a function.
Usage notes
The ListInstances operation queries the real-time status of function instances. The returned instances are the available instances on the traffic path of the function.
Available instances are instances that are running requests or can be scheduled to process requests. The instances returned by ListInstances are consistent with the instances on the traffic path of InvokeFunction.
Test the operation
Request headers
This operation has no special request headers. For more information about common request headers, see Common parameters.
Request syntax
GET /services/{serviceName[.qualifier]}/functions/{function_name}/instances HTTP/1.1
Request parameters
|
Parameter |
Type |
Position |
Required |
Example |
Description |
| serviceName | String | Path | Yes | service_name | The name of the service. |
| functionName | String | Path | Yes | function_name | The name of the function. |
| qualifier | String | Path | No | test | The version or alias of the service. The default value is LATEST. The qualifier parameter has the same meaning as the qualifier parameter in InvokeFunction. For example, if you set Important To query instances in provisioned mode, set the qualifier parameter to an alias, not a version. Provisioned resources are directly attached to aliases, and instances in provisioned mode are managed under the corresponding aliases.
|
| instanceIds | Array of String | Query | No | ["1ef6b6ff-7f7b-485e-ab49-501ac681****", "04db0821-c6d2-4c10-970b-93e36f1a****"] | The instance IDs. |
| limit | Long | Query | No | 20 | The maximum number of resources to return. The value must be in the range of [0, 1000]. The number of returned resources can be less than but not greater than the specified limit. |
Response parameters
Parameter |
Type |
Example |
Description |
| Array | The list of returned instance information. |
||
| instanceId | String | ["1ef6b6ff-7f7b-485e-ab49-501ac681****", "04db0821-c6d2-4c10-970b-93e36f1a****"] | The instance ID. |
| versionId | Long | 1 | The service version of the instance. If the function instance is under the LATEST alias, the version number 0 is returned. |
Examples
Request example
GET /services/{serviceName[.qualifier]}/functions/{function_name}/instances?instanceIds=["[\"1ef6b6ff-7f7b-485e-ab49-501ac681****\", \"04db0821-c6d2-4c10-970b-93e36f1a****\"]"]&limit=20 HTTP/1.1
Host:fc-ram.aliyuncs.com
Content-Type:application/json
Response example
JSON format
HTTP/1.1 200 OK
Content-Type:application/json
[ {
"instanceId" : "[\"1ef6b6ff-7f7b-485e-ab49-501ac681****\", \"04db0821-c6d2-4c10-970b-93e36f1a****\"]",
"versionId" : 1
} ]
Error codes
For more information about error codes, see the Error Center.