UpdateFunction - 更新函数

更新时间:
复制为 MD 格式

更新函数信息。

调试

您可以在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 包的 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

函数运行的语言环境。目前支持 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"
  ]
}

错误码

访问错误中心查看更多错误码。

变更历史

更多信息,参考变更详情