更新函数信息。
调试
您可以在OpenAPI Explorer中直接运行该接口,免去您计算签名的困扰。运行成功后,OpenAPI Explorer可以自动生成SDK代码示例。
调试
授权信息
|
操作 |
访问级别 |
资源类型 |
条件关键字 |
关联操作 |
|
fc:UpdateFunction |
update |
*Function
|
无 | 无 |
请求语法
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 支持两种方式提供函数代码包,在一次请求中必须且只能使用其中一种:
|
|
| 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 |
| 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 |
函数运行的语言环境。目前支持 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 |
| 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"
]
}
错误码
访问错误中心查看更多错误码。
变更历史
更多信息,参考变更详情。