All Products
Search
Document Center

Function Compute:UpdateFunction

Last Updated:Jan 14, 2026

Updates the configuration of a function.

Try it now

Try this API in OpenAPI Explorer, no manual signing needed. Successful calls auto-generate SDK code matching your parameters. Download it with built-in credential security for local usage.

Test

RAM authorization

The table below describes the authorization required to call this API. You can define it in a Resource Access Management (RAM) policy. The table's columns are detailed below:

  • Action: The actions can be used in the Action element of RAM permission policy statements to grant permissions to perform the operation.

  • API: The API that you can call to perform the action.

  • Access level: The predefined level of access granted for each API. Valid values: create, list, get, update, and delete.

  • Resource type: The type of the resource that supports authorization to perform the action. It indicates if the action supports resource-level permission. The specified resource must be compatible with the action. Otherwise, the policy will be ineffective.

    • For APIs with resource-level permissions, required resource types are marked with an asterisk (*). Specify the corresponding Alibaba Cloud Resource Name (ARN) in the Resource element of the policy.

    • For APIs without resource-level permissions, it is shown as All Resources. Use an asterisk (*) in the Resource element of the policy.

  • Condition key: The condition keys defined by the service. The key allows for granular control, applying to either actions alone or actions associated with specific resources. In addition to service-specific condition keys, Alibaba Cloud provides a set of common condition keys applicable across all RAM-supported services.

  • Dependent action: The dependent actions required to run the action. To complete the action, the RAM user or the RAM role must have the permissions to perform all dependent actions.

Action

Access level

Resource type

Condition key

Dependent action

fc:UpdateFunction

update

*Function

acs:fc:{#regionId}:{#accountId}:services/{#ServiceName}/functions/{#FunctionName}

None None

Request syntax

PUT /2021-04-06/services/{serviceName}/functions/{functionName} HTTP/1.1

Path Parameters

Parameter

Type

Required

Description

Example

serviceName

string

Yes

The name of the service.

demoService

functionName

string

Yes

The name of the function.

demoFunction

Request parameters

Parameter

Type

Required

Description

Example

If-Match

string

No

Used to ensure that the resource to be modified is the same as the expected resource. The value is obtained from the response of the CreateFunction, GetFunction, or UpdateFunction operation.

e19d5cd5af0378da05f63f891c7467af

functionUpdateFields

object

No

The function update struct.

code Code

No

The Code struct. You can use one of the following two methods to provide the function code package. You must use one and only one of these methods in a request:

  • Specify ossBucketName and ossObjectName that store the code package.

  • Specify zipFile as the Base64-encoded content of the ZIP package.

customContainerConfig CustomContainerConfig

No

The configuration of the Custom Container runtime. After you configure this parameter, the function can be executed using a custom container image.

layers

array

No

A list of layers.

Note

Multiple layers are merged in descending order of the array index. The content of a layer with a smaller index overwrites the file with the same name in a layer with a larger index.

string

No

The name of the layer resource.

layername

description

string

No

The description of the function.

test desc

environmentVariables

object

No

The environment variables that you want to configure for the function. You can obtain the values of the environment variables in the function. For more information, see Environment variables.

string

No

The environment variable configuration.

{"key":"value"}

handler

string

No

The entry point for the function execution. The format varies based on the programming language. For more information, see Handler.

index.handler

memorySize

integer

No

The memory size of the function in MB. The value must be a multiple of 64 MB. The memory size varies by instance type. For more information, see Instance types.

512

runtime

string

No

The runtime environment 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, dotnetcore3.1, dotnetcore2.1, custom.debian10, custom, and custom-container. For more information, see Supported function runtimes.

python3.9

timeout

integer

No

The timeout period for the function to run, in seconds. Minimum value: 1. Default value: 3. The function execution is terminated if it exceeds this time limit.

60

initializationTimeout

integer

No

The timeout period for the initializer function to run, in seconds. Minimum value: 1. Default value: 3. The initializer function is terminated if its execution exceeds this time limit.

60

initializer

string

No

The entry point for the initializer function. The format varies based on the programming language. For more information, see Handler.

index.handler

caPort

integer

No

The listening port of the HTTP server for a custom runtime or a custom container runtime.

9000

InstanceConcurrency

integer

No

The maximum concurrency of the instance.

10

instanceSoftConcurrency

integer

No

The soft concurrency of the instance. This is used for graceful scale-out. When the number of concurrent requests on an instance exceeds the soft concurrency, the instance scales out. For example, if your instance starts slowly, you can set an appropriate soft concurrency to start instances in advance.

The value must be less than or equal to instanceConcurrency.

5

instanceType

string

No

The instance type of the function. Valid values:

  • e1: elastic instance.

  • c1: performance instance.

  • fc.gpu.tesla.1: GPU-accelerated instance of the Tesla series.

  • fc.gpu.ampere.1: GPU-accelerated instance of the Ampere series.

  • fc.gpu.ada.1: GPU-accelerated instance of the Ada series.

  • g1: same as fc.gpu.tesla.1.

e1

instanceLifecycleConfig

InstanceLifecycleConfig

No

The instance lifecycle configuration.

customDNS CustomDNS

No

The custom DNS configuration of the function.

customRuntimeConfig CustomRuntimeConfig

No

The detailed configuration of a Custom Runtime function.

customHealthCheckConfig CustomHealthCheckConfig

No

The custom health check configuration of the function. This applies only to Custom Runtime and Custom Container.

cpu

number

No

The CPU specification of the function in vCPUs. The value must be a multiple of 0.05 vCPU.

1.5

diskSize

integer

No

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

512

gpuMemorySize

integer

No

The GPU memory size of the function in MB. The value must be a multiple of 1024 MB.

2048

X-Fc-Account-Id

string

No

The ID of your Alibaba Cloud account.

188077086902****

X-Fc-Code-Checksum

string

No

The CRC-64 value of the function code package.

1506052139770049xxxx

X-Fc-Date

string

No

The start date of the function call. The format is EEE,d MMM yyyy HH:mm:ss GMT.

Wed, 11 May 2022 09:00:00 GMT

X-Fc-Trace-Id

string

No

The ID used to call the function. It corresponds to the `requestId` parameter in the response.

test-trace-id

Response elements

Element

Type

Description

Example

object

The response parameters for updating the function.

codeChecksum

string

The CRC-64 value of the function code package.

5434025278388143772

codeSize

integer

The size of the function code package returned by the system, in bytes.

1024

createdTime

string

The time when the function was created.

2016-08-15T15:00:00.000+0000

customContainerConfig CustomContainerConfig

The configuration of the Custom Container runtime. After you configure this parameter, the function can be executed using a custom container image.

layers

array

A list of layers.

Note

Multiple layers are merged in descending order of the array index. The content of a layer with a smaller index overwrites the file with the same name in a layer with a larger index.

string

The name of the layer resource.

md5#layername#version

description

string

The description of the function.

This is a demo hello world function

environmentVariables

object

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

string

The environment variable configuration.

{"key":"value"}

functionId

string

The unique ID that the system generates for each function.

2d28e0e9-9ba5-4eed-8b1a-d3d9cd24****

functionName

string

The name of the function.

demo-function

handler

string

The entry point of the function.

index.handler

lastModifiedTime

string

The time when the function was last modified.

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

memorySize

integer

The memory size of the function in MB.

512

runtime

string

The runtime environment 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, dotnetcore3.1, dotnetcore2.1, custom.debian10, custom, and custom-container. For more information, see Supported function runtimes.

python3.9

timeout

integer

The timeout period for the function to run, in seconds.

10

initializationTimeout

integer

The timeout period for the initializer function to run, in seconds. Minimum value: 1. Default value: 3. The initializer function is terminated if its execution exceeds this time limit.

60

initializer

string

The entry point for the initializer function. The format varies based on the programming language.

index.handler

caPort

integer

The listening port of the HTTP server for a Custom Runtime or Custom Container runtime.

9000

instanceType

string

The instance type of the function. Valid values:

  • e1: elastic instance.

  • c1: performance instance.

  • fc.gpu.tesla.1: GPU-accelerated instance of the Tesla series.

  • fc.gpu.ampere.1: GPU-accelerated instance of the Ampere series.

  • fc.gpu.ada.1: GPU-accelerated instance of the Ada series.

  • g1: same as fc.gpu.tesla.1.

e1

instanceSoftConcurrency

integer

The soft concurrency of the instance. This is used for graceful scale-out. When the number of concurrent requests on an instance exceeds the soft concurrency, the instance scales out. For example, if your instance starts slowly, you can set an appropriate soft concurrency to start instances in advance.

The value must be less than or equal to instanceConcurrency.

5

instanceLifecycleConfig

InstanceLifecycleConfig

The instance lifecycle configuration.

customDNS CustomDNS

The custom DNS configuration of the function.

customRuntimeConfig CustomRuntimeConfig

The detailed configuration of a Custom Runtime function.

customHealthCheckConfig CustomHealthCheckConfig

The custom health check configuration of the function. This applies only to Custom Runtime and Custom Container.

cpu

number

The CPU specification of the function in vCPUs. The value must be a multiple of 0.05 vCPU.

1.5

diskSize

integer

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

512

instanceConcurrency

integer

The concurrency of a single instance.

10

gpuMemorySize

integer

The GPU memory size of the function in MB. The value must be a multiple of 1024 MB.

2048

layersArnV2

array

The list of layer ARNs.

string

The Alibaba Cloud Resource Name (ARN) of the layer.

acs:fc:cn-hangzhou:official:layers/Python310/versions/2

Examples

Success response

JSON format

{
  "codeChecksum": "5434025278388143772",
  "codeSize": 1024,
  "createdTime": "2016-08-15T15:00:00.000+0000",
  "customContainerConfig": {
    "args": "[\"-arg1\", \"value1\"]",
    "command": "[\"/code/myserver\"]",
    "image": "registry-vpc.cn-hangzhou.aliyuncs.com/fc-demo/helloworld:v1beta1",
    "accelerationType": "Default",
    "instanceID": "cri-xxxxxxxxxx",
    "webServerMode": true
  },
  "layers": [
    "md5#layername#version"
  ],
  "description": "This is a demo hello world function",
  "environmentVariables": {
    "key": "{\"key\":\"value\"}"
  },
  "functionId": "2d28e0e9-9ba5-4eed-8b1a-d3d9cd24****",
  "functionName": "demo-function",
  "handler": "index.handler",
  "lastModifiedTime": "2016-08-15T17:00:00.000+0000",
  "memorySize": 512,
  "runtime": "python3.9",
  "timeout": 10,
  "initializationTimeout": 60,
  "initializer": "index.handler",
  "caPort": 9000,
  "instanceType": "e1",
  "instanceSoftConcurrency": 5,
  "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
  },
  "cpu": 1.5,
  "diskSize": 512,
  "instanceConcurrency": 10,
  "gpuMemorySize": 2048,
  "layersArnV2": [
    "acs:fc:cn-hangzhou:official:layers/Python310/versions/2"
  ]
}

Error codes

See Error Codes for a complete list.

Release notes

See Release Notes for a complete list.