全部產品
Search
文件中心

:UpdateFunction - 更新函數

更新時間:Jan 14, 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

用於確保實際更改的資源和期望更改的資源是一致的,該值來自 CreateFunctionGetFunctionUpdateFunction 的響應。

e19d5cd5af0378da05f63f891c7467af

functionUpdateFields

object

更新函數結構體。

code Code

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

  • 指定儲存程式碼封裝的 ossBucketNameossObjectName

  • 指定 zipFile 為 ZIP 包的 Base 64 編碼內容。

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

函數啟動並執行語言環境。目前支援 nodejs20nodejs18nodejs16nodejs14nodejs12nodejs10nodejs8nodejs6nodejs4.4python3.10python3.9python3python2.7java11java8go1php7.2dotnetcore3.1dotnetcore2.1custom.debian10customcustom-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

function 的 GPU 顯存規格,單位為 MB,為 1024MB 的倍數

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

函數啟動並執行語言環境。目前支援 nodejs20nodejs18nodejs16nodejs14nodejs12nodejs10nodejs8nodejs6nodejs4.4python3.10python3.9python3python2.7java11java8go1php7.2dotnetcore3.1dotnetcore2.1custom.debian10customcustom-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

function 的 GPU 顯存規格,單位為 MB,為 1024MB 的倍數

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

錯誤碼

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

變更歷史

更多資訊,參考變更詳情