赛尔校园公共服务平台 Logo
平台使用
阿里云
百度云
移动云
智算服务
教育生态
登录 →
赛尔校园公共服务平台 Logo
平台使用 阿里云 百度云 移动云 智算服务 教育生态
登录
  1. 首页
  2. 阿里云
  3. 函数计算 FC 2.0
  4. 开发参考
  5. API参考
  6. API参考(2021-04-06推荐)
  7. API目录
  8. 函数
  9. UpdateFunction - 更新函数

UpdateFunction - 更新函数

  • 函数
  • 发布于 2025-04-16
  • 0 次阅读
文档编辑
文档编辑

更新函数信息。

调试

您可以在OpenAPI Explorer中直接运行该接口,免去您计算签名的困扰。运行成功后,OpenAPI Explorer可以自动生成SDK代码示例。

调试

授权信息

下表是API对应的授权信息,可以在RAM权限策略语句的Action元素中使用,用来给RAM用户或RAM角色授予调用此API的权限。具体说明如下:

  • 操作:是指具体的权限点。
  • 访问级别:是指每个操作的访问级别,取值为写入(Write)、读取(Read)或列出(List)。
  • 资源类型:是指操作中支持授权的资源类型。具体说明如下:
    • 对于必选的资源类型,用背景高亮的方式表示。
    • 对于不支持资源级授权的操作,用全部资源表示。
  • 条件关键字:是指云产品自身定义的条件关键字。
  • 关联操作:是指成功执行操作所需要的其他权限。操作者必须同时具备关联操作的权限,操作才能成功。
操作访问级别资源类型条件关键字关联操作
fc:UpdateFunctionupdate
*Function
acs:fc:{#regionId}:{#accountId}:services/{#ServiceName}/functions/{#FunctionName}
    无
无

请求语法

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

请求参数

名称类型必填描述示例值
If-Matchstring否

用于确保实际更改的资源和期望更改的资源是一致的,该值来自 CreateFunction 、 GetFunction 和 UpdateFunction 的响应。

e19d5cd5af0378da05f63f891c7467af
serviceNamestring是

服务名称。

demoService
functionNamestring是

函数名称。

demoFunction
functionUpdateFieldsobject否

更新函数结构体。

codeCode否

Code 支持两种方式提供函数代码包,在一次请求中必须且只能使用其中一种:

  • 指定存储代码包的 ossBucketName 和 ossObjectName。
  • 指定 zipFile 为 ZIP 包的 Base64 编码内容。
customContainerConfigCustomContainerConfig否

Custom Container 运行时的相关配置。配置后函数可以使用自定义容器镜像执行函数。

layersarray否

层的列表。

说明 多个层会按照数组下标从大到小的顺序进行合并,下标小的层的内容会覆盖下标大的层的同名文件。
string否

层资源的名称。

layername
descriptionstring否

函数描述。

test desc
environmentVariablesobject否

为函数设置的环境变量,可以在函数中获取环境变量的值。更多信息,请参见环境变量。

string否

环境变量配置。

{"key":"value"}
handlerstring否

函数执行的入口,具体格式和语言相关。详细信息,请参见函数入口。

index.handler
memorySizeinteger否

函数的内存规格,单位为 MB,内存大小为 64 MB 的倍数。不同的函数实例类型,内存规格存在差异。更多信息,请参见实例规格。

512
runtimestring否

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

函数运行的超时时间,单位为秒,最小 1 秒,默认 3 秒。函数超过这个时间后会被终止执行。

60
initializationTimeoutinteger否

初始化函数运行的超时时间,单位为秒,最小 1 秒,默认 3 秒。初始化函数超过这个时间后会被终止执行。

60
initializerstring否

初始化函数执行的入口,具体格式和语言相关。详细信息,请参见函数入口。

index.handler
caPortinteger否

自定义、自定义容器运行时 HTTP Server 的监听端口。

9000
InstanceConcurrencyinteger否

实例最大并发度。

10
instanceSoftConcurrencyinteger否

实例软并发度,用于优雅扩容。当实例上的并发数超过软并发度时,会触发实例扩容。例如,您的实例启动较慢,可以通过设置合适的软实例并发度,提前启动实例。

取值小于或等于 instanceConcurrency。

5
instanceTypestring否

函数的实例类型,取值如下:

  • 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
instanceLifecycleConfigInstanceLifecycleConfig否

实例生命周期配置。

customDNSCustomDNS否

函数自定义 DNS 配置。

customRuntimeConfigCustomRuntimeConfig否

Custom Runtime 函数详细配置。

customHealthCheckConfigCustomHealthCheckConfig否

函数自定义健康检查配置,仅适用于 Custom Runtime 和 Custom Container。

cpufloat否

函数的 CPU 规格,单位为 vCPU,为 0.05 vCPU 的倍数。

1.5
diskSizeinteger否

函数的磁盘规格,单位为 MB,可选值为 512 MB 或 10240 MB。

512
gpuMemorySizeinteger否

function 的 GPU 显存规格,单位为 MB,为 1024MB 的倍数

2048
X-Fc-Account-Idstring否

您的阿里云账号(主账号)ID。

188077086902****
X-Fc-Code-Checksumstring否

函数代码包的 CRC-64 值。

1506052139770049xxxx
X-Fc-Datestring否

函数的调用开始日期,格式为EEE,d MMM yyyy HH:mm:ss GMT。

Wed, 11 May 2022 09:00:00 GMT
X-Fc-Trace-Idstring否

调用函数的 ID,与返回参数 requestId 对应。

test-trace-id

返回参数

名称类型描述示例值
headersobject
ETagstring

用于更改函数的 ETag,以确保实际更改的函数和期望更改的函数是一致的。

5e547e5605e1dc17a78a6191bc18fbc5
object

更新函数的返回值。

codeChecksumstring

函数代码包的 CRC64 值。

5434025278388143772
codeSizelong

系统返回的函数代码包的大小,单位为 Byte。

1024
createdTimestring

函数创建时间。

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

Custom Container 运行时的相关配置,配置后函数可以使用自定义容器镜像执行函数。

layersarray

层的列表。

说明 多个层会按照数组下标从大到小的顺序进行合并,下标小的层的内容会覆盖下标大的层的同名文件。
layerstring

层资源的名称。

md5#layername#version
descriptionstring

函数描述。

This is a demo hello world function
environmentVariablesobject

为函数设置的环境变量,可以在函数中获取环境变量的值。更多信息,请参见环境变量。

string

环境变量配置。

{"key":"value"}
functionIdstring

系统为每个函数生成的唯一 ID。

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

函数名称。

demo-function
handlerstring

函数的执行入口。

index.handler
lastModifiedTimestring

函数上次修改时间。

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

函数设置的内存大小,单位为 MB。

512
runtimestring

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

运行的超时时间,单位为秒。

10
initializationTimeoutinteger

初始化函数运行的超时时间,单位为秒,最小 1 秒,默认 3 秒。初始化函数超过这个时间后会被终止执行。

60
initializerstring

初始化函数执行的入口,具体格式和语言相关。

index.handler
caPortinteger

Custom Runtime 或 Custom Container 运行时 HTTP Server 的监听端口。

9000
instanceTypestring

函数的实例类型,取值如下:

  • 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
instanceSoftConcurrencyinteger

实例软并发度,用于优雅扩容。当实例上的并发数超过软并发度时,会触发实例扩容。例如,您的实例启动较慢,可以通过设置合适的软实例并发度,提前启动实例。

取值小于或等于 instanceConcurrency。

5
instanceLifecycleConfigInstanceLifecycleConfig

实例生命周期配置。

customDNSCustomDNS

函数自定义 DNS 配置。

customRuntimeConfigCustomRuntimeConfig

Custom Runtime 函数详细配置。

customHealthCheckConfigCustomHealthCheckConfig

函数自定义健康检查配置,仅适用于 Custom Runtime 和 Custom Container。

cpufloat

函数的 CPU 规格,单位为 vCPU,为 0.05 vCPU 的倍数。

1.5
diskSizeinteger

函数的磁盘规格,单位为 MB,可选值为 512 MB 或 10240 MB。

512
instanceConcurrencyinteger

单个实例的并发度。

10
gpuMemorySizeinteger

function 的 GPU 显存规格,单位为 MB,为 1024MB 的倍数

2048
layersArnV2array

层的 arn 列表

layerstring

层资源定位符

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

错误码

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

变更历史

变更时间变更内容概要操作
2023-07-27OpenAPI 返回结构发生变更查看变更详情
2023-07-27OpenAPI 返回结构发生变更查看变更详情
2023-06-29OpenAPI 返回结构发生变更查看变更详情
2021-06-30OpenAPI 入参发生变更查看变更详情
2021-06-30OpenAPI 返回结构发生变更查看变更详情
2021-06-30OpenAPI 返回结构发生变更查看变更详情
相关文章

CreateFunction - 创建函数 2025-04-16 14:22

创建函数。

DeleteFunction - 删除函数 2025-04-16 14:22

删除函数。删除函数前需要先删除函数的触发器。

UpdateFunction - 更新函数 2025-04-16 14:22

更新函数信息。

GetFunction - 获取函数信息 2025-04-16 14:22

获取函数信息。

GetFunctionCode - 获取函数代码包 2025-04-16 14:22

获取函数代码包的详情。

ListFunctions - 获取函数列表信息 2025-04-16 14:22

获取函数列表。

目录
Copyright © 2025 your company All Rights Reserved. Powered by 赛尔网络.
京ICP备14022346号-15
gongan beian 京公网安备11010802041014号