调用UpdateFunction接口更新函数信息。
请求头
除公共请求头,该接口还需要指定以下请求头。关于公共请求头,请参见公共请求参数文档。
名称 | 类型 | 是否必选 | 示例 | 描述 |
---|---|---|---|---|
If-Match | String | 否 | e19d5cd5af0378da05f63f891c7467af> |
用于确保实际更改的资源和期望更改的资源是一致的,该值来自CreateFunction、GetFunction和UpdateFunction的响应。 |
X-Fc-Code-Checksum | String | 否 | 5434025278388143772> |
函数代码包的CRC-64值。 |
请求语法
PUT /services/{serviceName}/functions/{functionName}
请求参数
名称 | 类型 | 位置 | 是否必选 | 示例值 | 描述 |
---|---|---|---|---|---|
serviceName | String | Path | 否 | service_name |
服务的名称。 |
functionName | String | Path | 否 | function_name |
函数的名称。 |
code | Code | Body | 否 |
指定Code ZIP包。 |
|
customContainerConfig | CustomContainerConfig | Body | 否 |
custom-container运行时的相关配置。配置后函数可以使用自定义容器镜像执行函数。 |
|
description | String | Body | 否 | test_description |
函数的描述信息。 |
environmentVariables | Map | Body | 否 |
为函数设置的环境变量,可以在函数中获取环境变量的值。更多信息,请参见环境变量简介。 |
|
handler | String | Body | 否 | index.handler |
函数执行的入口,具体格式和语言相关。更多信息,请参见函数入口。 |
memorySize | Integer | Body | 否 | 512 |
函数的内存规格,单位为MB,内存大小为64 MB的倍数。不同的函数实例类型,内存规格存在差异,更多信息,请参见实例规格。 |
runtime | String | Body | 否 | python3 |
函数运行的语言环境。当前支持nodejs4.4、nodejs6、nodejs8、nodejs10、nodejs12、python2.7、python3、java8、java11、php7.2、dotnetcore2.1、custom及custom-container。 |
timeout | String | Body | 否 | 60 |
函数运行的超时时间,单位为秒,默认60秒。最小1秒,最长10分钟。函数超过这个时间后会被终止执行。 |
initializationTimeout | Integer | Body | 否 | 60 |
初始化函数运行的超时时间,单位为秒,默认3秒。最小1秒,最长5分钟。初始化函数超过这个时间后会被终止执行。 |
initializer | String | Body | 否 | index.handler |
初始化函数执行的入口,具体格式与语言相关,更多信息,请参见Initializer函数。 |
caPort | Integer | Body | 否 | 9000 |
Custom Runtime或Custom Container运行时HTTP Server的监听端口。 |
Code支持两种方式提供函数代码包,在一次请求中必须且只能使用其中一种。
- 指定存储代码包的ossBucketName和ossObjectName。
- 指定zipFile为ZIP包的Base64编码内容。
返回数据
名称 | 类型 | 示例值 | 描述 |
---|---|---|---|
ETag | String | e19d5cd5af0378da05f63f891c7467af |
确保实际修改的函数和期望更改的函数是一致的。该值来自CreateFunction、GetFunction和UpdateFunction的响应。 |
codeChecksum | String | 2825179536350**** |
函数代码包的CRC-64值。 |
codeSize | Long | 421 |
系统返回的函数的代码包大小,单位为Byte。 |
createdTime | String | 2020-04-01T08:14:58Z |
函数的创建时间。 |
customContainerConfig | CustomContainerConfig |
custom-container运行时的相关配置。配置后函数可以使用自定义容器镜像执行函数。 |
|
description | String | test_description |
函数的描述。 |
environmentVariables | Map |
为函数设置的环境变量,可以在函数中获取环境变量的值。更多信息,请参见环境变量简介。 |
|
functionId | String | e68905d5-f81c-4238-a5e4-*** |
系统为每个函数生成的ID,全网唯一。 |
functionName | String | function_name |
函数的名称。 |
handler | String | index.handler |
函数执行的入口,具体格式和语言相关,更多信息,请参见函数入口。 |
lastModifiedTime | Long | 2016-08-15T17:00:00.000+0000 |
函数上一次被更新的时间。 |
memorySize | Integer | 512 |
函数的内存规格,单位为MB,内存大小为64 MB的倍数。不同的函数实例类型,内存规格存在差异,更多信息,请参见实例规格。 |
runtime | String | python3 |
函数运行的语言环境。当前支持nodejs4.4、nodejs6、nodejs8、nodejs10、nodejs12、python2.7、python3、java8、java11、php7.2、dotnetcore2.1、custom及custom-container。 |
timeout | Integer | 10 |
函数运行的超时时间,单位为秒,默认60秒。最小1秒,最长10分钟。函数超过这个时间后会被终止执行。 |
initializationTimeout | Integer | 60 |
初始化函数运行的超时时间,单位为秒,默认3秒。最小1秒,最长5分钟。初始化函数超过这个时间后会被终止执行。 |
initializer | String | index.handler |
初始化函数执行的入口,具体格式与语言相关,更多信息,请参见Initializer函数。 |
caPort | Integer | 9000 |
Custom Runtime或Custom Container运行时HTTP Server的监听端口。 |
示例
请求示例
PUT /2016-08-15/services/service_name/functions/function_name HTTP/1.1
公共请求头
{
"handler":"index.handler",
"cAPort":9000,
"code":{
"zipFile":"samplecode"
}
}
正常返回示例
JSON
格式
HTTP/1.1 200
ETag:e19d5cd5af0378da05f63f891c7467af
Content-Type:application/json
HTTP/1.1 200 OK
公共响应头
{
"functionId": "e68905d5-f81c-4238-a5e4-***",
"functionName": "function_name",
"description": "test_description",
"cAPort": 9000,
"runtime": "python3",
"handler": "index.handler",
"timeout": 60,
"initializer": "index.handler",
"initializationTimeout": 30,
"codeSize": 421,
"codeChecksum": "2825179536350****",
"memorySize": 256,
"environmentVariables": {
"testKey": "TEST_KEY"
},
"createdTime": "2020-04-01T08:14:58Z",
"lastModifiedTime": "2020-04-02T06:30:56Z",
"instanceConcurrency": 1
}
在文档使用中是否遇到以下问题
更多建议
匿名提交