All Products
Search
Document Center

Function Compute:GetFunction

Last Updated:Sep 19, 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

The following table shows the authorization information corresponding to the API. The authorization information can be used in the Action policy element to grant a RAM user or RAM role the permissions to call this API operation. Description:

  • Operation: the value that you can use in the Action element to specify the operation on a resource.
  • Access level: the access level of each operation. The levels are read, write, and list.
  • Resource type: the type of the resource on which you can authorize the RAM user or the RAM role to perform the operation. Take note of the following items:
    • The required resource types are displayed in bold characters.
    • If the permissions cannot be granted at the resource level, All Resources is used in the Resource type column of the operation.
  • Condition Key: the condition key that is defined by the cloud service.
  • Associated operation: other operations that the RAM user or the RAM role must have permissions to perform to complete the operation. To complete the operation, the RAM user or the RAM role must have the permissions to perform the associated operations.
OperationAccess levelResource typeCondition keyAssociated operation
fc:GetFunctionget
  • All Resources
    *
    none
none

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 function information.

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 instances
  • c1: performance instances
  • fc.gpu.tesla.1: GPU-accelerated instances with Tesla series cards
  • fc.gpu.ampere.1: GPU-accelerated instances with Ampere series cards
  • fc.gpu.ada.1:GPU-accelerated instances with Ada series cards
  • 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 changedView Change Details
2021-06-30The request parameters of the API has changedView Change Details
2021-06-30The request parameters of the API has changed. The response structure of the API has changedView Change Details
2021-06-30The request parameters of the API has changed. The response structure of the API has changedView Change Details