All Products
Search
Document Center

Function Compute (2.0):GetFunction

Last Updated:Apr 18, 2024

Queries the information about a function.

Debugging

OpenAPI Explorer automatically calculates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer.

Authorization information

There is currently no authorization information disclosed in the API.

Request syntax

GET /2021-04-06/services/{serviceName}/functions/{functionName}

Request parameters

ParameterTypeRequiredDescriptionExample
serviceNamestringYes

The name of the service.

service_name
qualifierstringNo

The version or alias of the service.

demoQualifier
functionNamestringYes

The name of the function.

function_name
X-Fc-Account-IdstringNo

The ID of your Alibaba Cloud account.

188077086902****
X-Fc-DatestringNo

The time on which the function is invoked. The format of the value is: EEE,d MMM yyyy HH:mm:ss GMT.

Wed, 11 May 2022 09:00:00 GMT
X-Fc-Trace-IdstringNo

The custom request ID.

asdf****

Response parameters

ParameterTypeDescriptionExample
headersobject
ETagstring

The ETag value of the function. This value is used to ensure that the modified function is consistent with the function to be modified.

function_name
object

The definition of the function.

codeChecksumstring

The CRC-64 value of the function code package.

2825179536350****
codeSizelong

The size of the function code package. Unit: byte.

421
createdTimestring

The time when the function was created.

2020-04-01T08:15:27Z
descriptionstring

The description of the function.

test_description
environmentVariablesobject

The environment variables that are configured for the function. You can obtain the values of the environment variables from the function. For more information, see Environment variables.

string

The environment variables that you configured for the function.

{"key":"value"}
functionIdstring

The ID that is generated by the system for the function. Each function ID is unique in Function Compute.

aa715851-1c20-4b89-a8fb-***
functionNamestring

The name of the function.

function_name
handlerstring

The handler of the function. For more information, see Function handler.

index.handler
lastModifiedTimestring

The time when the function was last modified.

2020-04-01T08:15:27Z
memorySizeinteger

The memory size for the function. Unit: MB. The value must be a multiple of 64. The memory size varies based on the function instance type. For more information, see Instance types.

256
runtimestring

The runtime of the function. Valid values: nodejs20, nodejs18, nodejs16, nodejs14, nodejs12, nodejs10, nodejs8, nodejs6, nodejs4.4, python3.10, python3.9, python3, python2.7, java11, java8, go1, php7.2, dotnetcore2.1, custom.debian10, custom, and custom-container.

python3
timeoutinteger

The timeout period for the execution of the function. Unit: seconds. Default value: 60. Valid values: 1 to 600. When this period expires, the execution of the function is terminated.

60
initializationTimeoutinteger

The timeout period for the execution of the Initializer hook. Unit: seconds. Default value: 3. Valid values: 1 to 300. When this period ends, the execution of the Initializer hook is terminated.

60
initializerstring

The handler of the Initializer hook. The format of the value is determined by the programming language that you use. For more information, see Initializer hook.

index.handler
caPortinteger

The port on which the HTTP server listens for the custom runtime or custom container runtime.

9000
customContainerConfigCustomContainerConfigInfo

The configurations of the custom container runtime. After you configure the custom container runtime, Function Compute can execute the function in a container created from a custom image.

layersarray

The list of layers (ARN V1).

Note If multiple layers exist, the layers are merged based on the array subscripts in descending order. The content of a layer with a smaller subscript overwrites that of a larger subscript.
Note This parameter is to be deprecated. Use layersArnV2.
string

The name of the layer resource (ARN V1 version).

02f81d283888f5ec63442a88fe82b260#Layer-name#1
instanceConcurrencyinteger

The number of requests that can be concurrently processed by a single instance.

10
instanceSoftConcurrencyinteger

The soft concurrency of the instance. You can use this parameter to implement graceful scale-up of instances. If the number of concurrent requests on an instance is greater than the value of soft concurrency, an instance scale-up is triggered. For example, if your instance requires a long time to start, you can specify a suitable soft concurrency to start the instance in advance.

The value must be less than or equal to that of the instanceConcurrency parameter.

5
instanceTypestring

The instance type of the function. Valid values:

  • e1: elastic instance
  • c1: performance instance
  • fc.gpu.tesla.1: GPU-accelerated instance (Tesla T4)
  • fc.gpu.ampere.1: GPU-accelerated instance (Ampere A10)
  • g1: same as fc.gpu.tesla.1
e1
instanceLifecycleConfigInstanceLifecycleConfig

The lifecycle configurations of the instance.

customDNSCustomDNS

The custom DNS configurations of the function.

customRuntimeConfigCustomRuntimeConfig

The configurations of the custom runtime.

customHealthCheckConfigCustomHealthCheckConfig

The custom health check configuration of the function. This parameter is applicable only to custom runtimes and custom containers.

layersArnV2array

The list of layers (ARN V2).

Note If multiple layers exist, the layers are merged based on the array subscripts in descending order. The content of a layer with a smaller subscript overwrites that of a larger subscript.
string

The name of the layer resource (ARN V2 version).

acs:fc:{region}:{accountID}:layers/{layerName}/versions/{layerVersion}
cpufloat

The number of vCPUs of the function. The value must be a multiple of 0.05.

1.5
diskSizeinteger

The disk size of the function. Unit: MB. Valid values: 512 and 10240.

512
gpuMemorySizeinteger

The GPU memory capacity for the function. Unit: MB. The value is a multiple of 1,024.

2048

Examples

Sample success responses

JSONformat

{
  "codeChecksum": "2825179536350****",
  "codeSize": 421,
  "createdTime": "2020-04-01T08:15:27Z",
  "description": "test_description",
  "environmentVariables": {
    "key": "{\"key\":\"value\"}"
  },
  "functionId": "aa715851-1c20-4b89-a8fb-***",
  "functionName": "function_name",
  "handler": "index.handler",
  "lastModifiedTime": "2020-04-01T08:15:27Z",
  "memorySize": 256,
  "runtime": "python3",
  "timeout": 60,
  "initializationTimeout": 60,
  "initializer": "index.handler",
  "caPort": 9000,
  "customContainerConfig": {
    "args": "[\"-arg1\", \"value1\"]",
    "command": "[\"/code/myserver\"]",
    "image": "registry-vpc.cn-hangzhou.aliyuncs.com/fc-demo/helloworld:v1beta1",
    "accelerationType": "Default",
    "accelerationInfo": {
      "status": "Preparing"
    },
    "instanceID": "cri-xxxxxxxxxx",
    "webServerMode": true
  },
  "layers": [
    "02f81d283888f5ec63442a88fe82b260#Layer-name#1"
  ],
  "instanceConcurrency": 10,
  "instanceSoftConcurrency": 5,
  "instanceType": "e1",
  "instanceLifecycleConfig": {
    "preFreeze": {
      "handler": "index.preStop",
      "timeout": 10
    },
    "preStop": {
      "handler": "index.preStop",
      "timeout": 10
    }
  },
  "customDNS": {
    "nameServers": [
      "8.8.x.x"
    ],
    "searches": [
      "ns1.svc.cluster-domain.example"
    ],
    "dnsOptions": [
      {
        "name": "ndots",
        "value": "2"
      }
    ]
  },
  "customRuntimeConfig": {
    "command": [
      "/code/myBootstrap"
    ],
    "args": [
      "args1"
    ]
  },
  "customHealthCheckConfig": {
    "httpGetUrl": "/ready",
    "initialDelaySeconds": 1,
    "periodSeconds": 1,
    "timeoutSeconds": 2,
    "failureThreshold": 1,
    "successThreshold": 2
  },
  "layersArnV2": [
    "acs:fc:{region}:{accountID}:layers/{layerName}/versions/{layerVersion}"
  ],
  "cpu": 1.5,
  "diskSize": 512,
  "gpuMemorySize": 2048
}

Error codes

For a list of error codes, visit the Service error codes.

Change history

Change timeSummary of changesOperation
2023-07-27The response structure of the API has changedsee changesets
Change itemChange content
Output ParametersThe response structure of the API has changed.
2021-06-30The request parameters of the API has changedsee changesets
Change itemChange content
Input ParametersThe request parameters of the API has changed.
    Added Input Parameters: X-Fc-Account-Id
    Added Input Parameters: X-Fc-Code-Checksum
    Added Input Parameters: X-Fc-Log-Type
    Added Input Parameters: X-Fc-Invocation-Type
    Added Input Parameters: X-Fc-Date
    Added Input Parameters: X-Fc-Trace-Id
2021-06-30The request parameters of the API has changed. The response structure of the API has changedsee changesets
Change itemChange content
Input ParametersThe request parameters of the API has changed.
    Added Input Parameters: X-Fc-Account-Id
Output ParametersThe response structure of the API has changed.
2021-06-30The request parameters of the API has changed. The response structure of the API has changedsee changesets
Change itemChange content
Input ParametersThe request parameters of the API has changed.
    delete Input Parameters: X-Fc-Account-Id
Output ParametersThe response structure of the API has changed.