全部產品
Search
文件中心

:UpdateFunction

更新時間:Sep 09, 2026

更新函數資訊。

調試

您可以在OpenAPI Explorer中直接運行該介面,免去您計算簽名的困擾。運行成功後,OpenAPI Explorer可以自動產生SDK程式碼範例。

調試

授權資訊

下表是API對應的授權資訊,可以在RAM權限原則語句的Action元素中使用,用來給RAM使用者或RAM角色授予調用此API的許可權。具體說明如下:

  • 操作:是指具體的許可權點。

  • 存取層級:是指每個操作的存取層級,取值為寫入(Write)、讀取(Read)或列出(List)。

  • 資源類型:是指操作中支援授權的資源類型。具體說明如下:

    • 對於必選的資源類型,用前面加 * 表示。

    • 對於不支援資源級授權的操作,用全部資源表示。

  • 條件關鍵字:是指雲產品自身定義的條件關鍵字。

  • 關聯操作:是指成功執行操作所需要的其他許可權。操作者必須同時具備關聯操作的許可權,操作才能成功。

操作

存取層級

資源類型

條件關鍵字

關聯操作

fc:UpdateFunction

update

*Function

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

無 無

請求文法

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

路徑參數

名稱

類型

必填

描述

樣本值

serviceName

string

是

服務名稱。

demoService

functionName

string

是

函數名稱。

demoFunction

請求參數

名稱

類型

必填

描述

樣本值

If-Match

string

否

用於確保實際變更的資源和期望變更的資源是一致的,該值來自 CreateFunction 、 GetFunction 和 UpdateFunction 的回應。

e19d5cd5af0378da05f63f891c7467af

functionUpdateFields

object

否

更新函數結構體。

code Code

否

Code 支援兩種方式提供函數程式碼套件,在一次請求中必須且只能使用其中一種:

  • 指定儲存程式碼套件的 ossBucketName 和 ossObjectName。

  • 指定 zipFile 為 ZIP 套件的 Base64 編碼內容。

customContainerConfig CustomContainerConfig

否

Custom Container 執行階段的相關設定。設定後函數可以使用自訂容器映像執行函數。

layers

array

否

層的清單。

說明

多個層會按照陣列索引從大到小的順序進行合併,索引小的層的內容會覆蓋索引大的層的同名檔案。

string

否

層資源的名稱。

layername

description

string

否

函數描述。

test desc

environmentVariables

object

否

為函數設定的環境變數,可以在函數中取得環境變數的值。更多資訊,請參見環境變數。

string

否

環境變數設定。

{"key":"value"}

handler

string

否

函數執行的進入點,具體格式和語言相關。詳細資訊,請參見函數進入點。

index.handler

memorySize

integer

否

函數的記憶體規格,單位為 MB,記憶體大小為 64 MB 的倍數。不同的函數執行個體類型,記憶體規格存在差異。更多資訊,請參見執行個體規格。

512

runtime

string

否

函數執行的語言環境。目前支援 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 和 custom-container。更多資訊,請參見支援的函數執行環境清單。

python3.9

timeout

integer

否

函數執行的逾時時間,單位為秒,最小 1 秒,預設 3 秒。函數超過這個時間後會被終止執行。

60

initializationTimeout

integer

否

初始化函數執行的逾時時間,單位為秒,最小 1 秒,預設 3 秒。初始化函數超過這個時間後會被終止執行。

60

initializer

string

否

初始化函數執行的進入點,具體格式和語言相關。詳細資訊,請參見函數進入點。

index.handler

caPort

integer

否

自訂、自訂容器執行階段 HTTP Server 的監聽連接埠。

9000

InstanceConcurrency

integer

否

執行個體最大並行度。

10

instanceSoftConcurrency

integer

否

執行個體軟並行度,用於優雅擴容。當執行個體上的並行數超過軟並行度時,會觸發執行個體擴容。例如,您的執行個體啟動較慢,可以透過設定合適的軟執行個體並行度,提前啟動執行個體。

取值小於或等於 instanceConcurrency。

5

instanceType

string

否

函數的執行個體類型,取值如下:

  • e1:彈性執行個體。

  • c1:效能執行個體。

  • fc.gpu.tesla.1:GPU Tesla 系列執行個體類型。

  • fc.gpu.ampere.1:GPU Ampere 系列執行個體類型。

  • fc.gpu.ada.1:GPU Ada 系列執行個體類型。

  • g1:同 fc.gpu.tesla.1。

e1

instanceLifecycleConfig InstanceLifecycleConfig

否

執行個體生命週期設定。

customDNS CustomDNS

否

函數自訂 DNS 設定。

customRuntimeConfig CustomRuntimeConfig

否

Custom Runtime 函數詳細設定。

customHealthCheckConfig CustomHealthCheckConfig

否

函數自訂健康檢查設定,僅適用於 Custom Runtime 和 Custom Container。

cpu

number

否

函數的 CPU 規格,單位為 vCPU,為 0.05 vCPU 的倍數。

1.5

diskSize

integer

否

函數的磁碟規格,單位為 MB,可選值為 512 MB 或 10240 MB。

512

gpuMemorySize

integer

否

函數的 GPU 視訊記憶體規格,單位為 MB,為 1024 MB 的倍數。

2048

X-Fc-Account-Id

string

否

您的阿里雲帳號(主帳號)ID。

188077086902****

X-Fc-Code-Checksum

string

否

函數程式碼套件的 CRC-64 值。

1506052139770049xxxx

X-Fc-Date

string

否

函數的呼叫開始日期,格式為 EEE,d MMM yyyy HH:mm:ss GMT。

Wed, 11 May 2022 09:00:00 GMT

X-Fc-Trace-Id

string

否

呼叫函數的 ID,與返回參數 requestId 對應。

test-trace-id

返回參數

名稱

類型

描述

樣本值

object

更新函數的傳回值。

codeChecksum

string

函數程式碼套件的 CRC64 值。

5434025278388143772

codeSize

integer

系統傳回的函數程式碼套件大小,單位為 Byte。

1024

createdTime

string

函數建立時間。

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

customContainerConfig CustomContainerConfig

Custom Container 執行階段的相關設定,設定後函數可以使用自訂容器映像執行函數。

layers

array

層的清單。

說明

多個層會按照陣列索引從大到小的順序進行合併,索引小的層的內容會覆蓋索引大的層的同名檔案。

string

層資源的名稱。

md5#layername#version

description

string

函數描述。

This is a demo hello world function

environmentVariables

object

為函數設定的環境變數,可以在函數中取得環境變數的值。更多資訊,請參見環境變數。

string

環境變數設定。

{"key":"value"}

functionId

string

系統為每個函數產生的唯一 ID。

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

functionName

string

函數名稱。

demo-function

handler

string

函數的執行進入點。

index.handler

lastModifiedTime

string

函數上次修改時間。

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

memorySize

integer

函數設定的記憶體大小,單位為 MB。

512

runtime

string

函數執行的語言環境。目前支援 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 和 custom-container。更多資訊,請參見支援的函數執行環境清單。

python3.9

timeout

integer

執行的逾時時間,單位為秒。

10

initializationTimeout

integer

初始化函數執行的逾時時間,單位為秒,最小 1 秒,預設 3 秒。初始化函數超過這個時間後會被終止執行。

60

initializer

string

初始化函數執行的進入點,具體格式與語言相關。

index.handler

caPort

integer

Custom Runtime 或 Custom Container 執行階段 HTTP Server 的監聽連接埠。

9000

instanceType

string

函數的執行個體類型,取值如下:

  • e1:彈性執行個體。

  • c1:效能執行個體。

  • fc.gpu.tesla.1:GPU Tesla 系列執行個體類型。

  • fc.gpu.ampere.1:GPU Ampere 系列執行個體類型。

  • fc.gpu.ada.1:GPU Ada 系列執行個體類型。

  • g1:同 fc.gpu.tesla.1。

e1

instanceSoftConcurrency

integer

執行個體軟並行度,用於優雅擴容。當執行個體上的並行數超過軟並行度時,會觸發執行個體擴容。例如,您的執行個體啟動較慢,可以透過設定合適的軟執行個體並行度,提前啟動執行個體。

取值小於或等於 instanceConcurrency。

5

instanceLifecycleConfig InstanceLifecycleConfig

執行個體生命週期設定。

customDNS CustomDNS

函數自訂 DNS 設定。

customRuntimeConfig CustomRuntimeConfig

Custom Runtime 函數詳細設定。

customHealthCheckConfig CustomHealthCheckConfig

函數自訂健康檢查設定,僅適用於 Custom Runtime 和 Custom Container。

cpu

number

函數的 CPU 規格,單位為 vCPU,為 0.05 vCPU 的倍數。

1.5

diskSize

integer

函數的磁碟規格,單位為 MB,可選值為 512 MB 或 10240 MB。

512

instanceConcurrency

integer

單一執行個體的並行度。

10

gpuMemorySize

integer

函數的 GPU 視訊記憶體規格,單位為 MB,為 1024 MB 的倍數。

2048

layersArnV2

array

層的 ARN 清單。

string

層資源定位符。

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

樣本

正常返回樣本

JSON格式

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

錯誤碼

訪問錯誤中心查看更多錯誤碼。

變更歷史

更多資訊,參考變更詳情。