All Products
Search
Document Center

:UpdateFunction

Last Updated:Jun 11, 2026

Memperbarui konfigurasi fungsi.

Coba sekarang

Coba API ini di OpenAPI Explorer tanpa perlu penandatanganan manual. Panggilan yang berhasil akan secara otomatis menghasilkan contoh kode SDK sesuai dengan parameter Anda. Unduh kode tersebut dengan kredensial bawaan yang aman untuk penggunaan lokal.

Test

RAM authorization

Tabel berikut menjelaskan otorisasi yang diperlukan untuk memanggil API ini. Anda dapat menentukannya dalam kebijakan Resource Access Management (RAM). Kolom pada tabel dijelaskan sebagai berikut:

  • Action: Aksi yang dapat digunakan dalam elemen Action pada pernyataan kebijakan izin RAM untuk memberikan izin guna melakukan operasi tersebut.

  • API: API yang dapat Anda panggil untuk melakukan aksi tersebut.

  • Access level: Tingkat akses yang telah ditentukan untuk setiap API. Nilai yang valid: create, list, get, update, dan delete.

  • Resource type: Jenis resource yang mendukung otorisasi untuk melakukan aksi tersebut. Ini menunjukkan apakah aksi tersebut mendukung izin tingkat resource. Resource yang ditentukan harus kompatibel dengan aksi tersebut. Jika tidak, kebijakan tersebut tidak akan berlaku.

    • Untuk API dengan izin tingkat resource, jenis resource yang diperlukan ditandai dengan tanda bintang (*). Tentukan Nama Sumber Daya Alibaba Cloud (ARN) yang sesuai dalam elemen Resource pada kebijakan.

    • Untuk API tanpa izin tingkat resource, ditampilkan sebagai All Resources. Gunakan tanda bintang (*) dalam elemen Resource pada kebijakan.

  • Condition key: Kunci kondisi yang didefinisikan oleh layanan. Kunci ini memungkinkan kontrol granular, berlaku baik hanya untuk aksi maupun untuk aksi yang terkait dengan resource tertentu. Selain kunci kondisi spesifik layanan, Alibaba Cloud menyediakan serangkaian common condition keys yang berlaku di semua layanan yang didukung RAM.

  • Dependent action: Aksi dependen yang diperlukan untuk menjalankan aksi tersebut. Untuk menyelesaikan aksi tersebut, pengguna RAM atau role RAM harus memiliki izin untuk melakukan semua aksi dependen.

Action

Access level

Resource type

Condition key

Dependent action

fc:UpdateFunction

update

*Function

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

None None

Sintaks permintaan

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

Path Parameters

Parameter

Type

Required

Description

Example

serviceName

string

Yes

Nama layanan.

demoService

functionName

string

Yes

Nama fungsi.

demoFunction

Parameter permintaan

Parameter

Type

Required

Description

Example

If-Match

string

No

Memastikan bahwa resource yang akan dimodifikasi sama dengan resource yang diharapkan. Nilai ini diperoleh dari tanggapan operasi CreateFunction, GetFunction, atau UpdateFunction.

e19d5cd5af0378da05f63f891c7467af

functionUpdateFields

object

No

Struktur pembaruan fungsi.

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.

Catatan

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 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. 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. 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, set a soft concurrency value to trigger scale-out 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.

2048

X-Fc-Account-Id

string

No

ID akun Alibaba Cloud Anda.

188077086902****

X-Fc-Code-Checksum

string

No

Nilai CRC-64 paket kode fungsi.

1506052139770049xxxx

X-Fc-Date

string

No

Tanggal mulai pemanggilan fungsi. Formatnya adalah EEE,d MMM yyyy HH:mm:ss GMT.

Wed, 11 May 2022 09:00:00 GMT

X-Fc-Trace-Id

string

No

ID yang digunakan untuk memanggil fungsi. ID ini sesuai dengan parameter requestId dalam tanggapan.

test-trace-id

Elemen respons

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.

Catatan

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

1.5

diskSize

integer

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

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.

2048

layersArnV2

array

The Alibaba Cloud Resource Names (ARNs) of the layer.

string

The ARN of the layer.

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

Contoh

Respons sukses

JSONformat

{
  "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"
  ]
}

Kode kesalahan

Lihat Error Codes untuk daftar lengkap.

Catatan rilis

Lihat Release Notes untuk daftar lengkap.