All Products
Search
Document Center

Function Compute:UpdateFunction

更新时间:Aug 20, 2025

Updates 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. OpenAPI Explorer dynamically generates the sample code of the operation for different SDKs.

Request headers

This operation uses both common request headers and special request headers. The following table describes the special request headers. For more information about common request headers, see Common parameters.

ParameterTypeRequiredExampleDescription
If-MatchStringNoe19d5cd5af0378da05f63f891c7467af

The value that is used to ensure that the modified resource is consistent with the resource to be modified. You can obtain the value from the responses of the CreateFunction, GetFunction, and UpdateFunction operations.

X-Fc-Code-ChecksumStringNo543402527838814****

The CRC-64 value of the function code package.

Request syntax

PUT /services/{serviceName}/functions/{functionName} HTTP/1.1

Request parameters

ParameterTypePositionRequiredExampleDescription
serviceNameStringPathYesservice_name

The name of the service.

functionNameStringPathYesfunction_name

The name of the function.

ObjectBodyNo

The definition of the function.

codeCodeBodyNo

The code package in ZIP format.

customContainerConfigCustomContainerConfigBodyNo

The configurations of the custom container runtime. After you configure the custom container runtime, you can use a custom container image to execute functions.

layersArray of StringBodyNo02f81d283888f5ec63442a88fe82b260#Layer-name#1

The name of the layer resource.

descriptionStringBodyNotest_description

The description of the function.

environmentVariablesMapBodyNo

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 Overview.

handlerStringBodyNoindex.handler

The handler of the function. The format is determined by the programming language. For more information, see Function handlers.

memorySizeIntegerBodyNo512

The memory size for the function. Unit: MB. The memory size is a multiple of 64 MB. The memory size that is available for an instance varies with the instance type. For more information, see Instance specifications.

runtimeStringBodyNopython3

The runtime environment of the function. Valid values: nodejs14, nodejs12, nodejs10, nodejs8, nodejs6, nodejs4.4, python3, python2.7, java11, java8, go1, php7.2, dotnetcore2.1, custom, and custom-container. For more information about the runtime environments that are supported by Function Compute, see Supported function runtime environments.

timeoutStringBodyNo60

The timeout period for Function Compute to execute the function. Unit: seconds. Default value: 60. Valid values: 1 to 86400. When the period expires, the function execution is terminated.

initializationTimeoutIntegerBodyNo60

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

initializerStringBodyNoindex.handler

The handler of the initializer function. The format of the value varies with the programming language. For more information, see Initializer function.

caPortIntegerBodyNo9000

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

Function code packages can be provided in the following two methods. You must use only one of the methods in a single request.

  • Specify the names of the Object Storage Service (OSS) bucket (ossBucketName) where the code package is stored and object name (ossObjectName).
  • Set the value of the zipFile parameter to the Base64-encoded content of the ZIP file.

Response parameters

ParameterTypeExampleDescription
ETagStringe19d5cd5af0378da05f63f891c74****

The value that is used to ensure that the modified function is consistent with the function that is expected to be modified. The value is obtained from the responses of the CreateFunction, GetFunction, and UpdateFunction operations.

codeChecksumString2825179536350****

The CRC-64 value of the function code package.

codeSizeLong421

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

createdTimeString2020-04-01T08:14:58Z

The time when the function was created.

customContainerConfigCustomContainerConfig

The configurations of the custom container runtime. After you configure the custom container runtime, you can use a custom container image to execute functions.

layersArray of String02f81d283888f5ec63442a88fe82****#Layer-name#1

The name of the layer resource.

descriptionStringtest_description

The description of the function.

environmentVariablesMap

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 Overview.

functionIdStringe68905d5-f81c-4238-a5e4-***

The ID generated by the system for each function. The ID is globally unique.

functionNameStringfunction_name

The name of the function.

handlerStringindex.handler

The handler of the function. The format is determined by the programming language. For more information, see Function handlers.

lastModifiedTimeLong2016-08-15T17:00:00.000+0000

The time when the function was last updated.

memorySizeInteger512

The memory size for the function. Unit: MB. The memory size is a multiple of 64 MB. The memory size that is available for an instance varies with the instance type. For more information, see Instance specifications.

runtimeStringpython3

The runtime environment of the function. Valid values: nodejs14, nodejs12, nodejs10, nodejs8, nodejs6, nodejs4.4, python3, python2.7, java11, java8, go1, php7.2, dotnetcore2.1, custom, and custom-container. For more information about the runtime environments that are supported by Function Compute, see Supported function runtime environments.

timeoutInteger10

The timeout period for Function Compute to execute the function. Unit: seconds. Default value: 60. Valid values: 1 to 86400. When the period expires, the function execution is terminated.

initializationTimeoutInteger60

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

initializerStringindex.handler

The handler of the initializer function. The format of the value varies with the programming language. For more information, see Initializer function.

caPortInteger9000

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

Examples

Sample requests

PUT /services/service_name/functions/function_name HTTP/1.1
Host:fc-ram.aliyuncs.com
If-Match:e19d5cd5af0378da05f63f891c7467af
X-Fc-Code-Checksum:543402527838814****
Content-Type:application/json

{
  "code" : {
    "ossBucketName" : "demo-bucket",
    "ossObjectName" : "demo-key",
    "zipFile" : "cHJpbnQoImhlbGxvIHdvcmxkIikK"
  },
  "customContainerConfig" : {
    "args" : "[\"-arg1\", \"value1\"]",
    "command" : "[\"/code/myserver\"]",
    "image" : "registry-vpc.cn-hangzhou.aliyuncs.com/fc-demo/helloworld:v1beta1",
    "accelerationType" : "Default",
    "instanceID" : "cri-xxxxxxxx"
  },
  "layers" : [ "02f81d283888f5ec63442a88fe82b260#Layer-name#1" ],
  "description" : "test_description",
  "handler" : "index.handler",
  "memorySize" : 512,
  "runtime" : "python3",
  "timeout" : "60",
  "initializationTimeout" : 60,
  "initializer" : "index.handler",
  "caPort" : 9000
}

Sample success responses

JSON format

HTTP/1.1 200 OK
Content-Type:application/json

{
  "codeChecksum" : "2825179536350****",
  "codeSize" : 421,
  "createdTime" : "2020-04-01T08:14:58Z",
  "customContainerConfig" : {
    "args" : "[\"-arg1\", \"value1\"]",
    "command" : "[\"/code/myserver\"]",
    "image" : "registry-vpc.cn-hangzhou.aliyuncs.com/fc-demo/helloworld:v1beta1",
    "accelerationType" : "Default",
    "instanceID" : "cri-xxxxxxxx"
  },
  "layers" : [ "02f81d283888f5ec63442a88fe82****#Layer-name#1" ],
  "description" : "test_description",
  "functionId" : "e68905d5-f81c-4238-a5e4-***",
  "functionName" : "function_name",
  "handler" : "index.handler",
  "memorySize" : 512,
  "runtime" : "python3",
  "timeout" : 10,
  "initializationTimeout" : 60,
  "initializer" : "index.handler",
  "caPort" : 9000
}

Error codes

For a list of error codes, visit the API Error Center.