Updates function information.
Try it now
Test
RAM authorization
|
Action |
Access level |
Resource type |
Condition key |
Dependent action |
|
fc:UpdateFunction |
update |
*Function
|
None | None |
Request syntax
PUT /2021-04-06/services/{serviceName}/functions/{functionName} HTTP/1.1
Path Parameters
|
Parameter |
Type |
Required |
Description |
Example |
| serviceName |
string |
Yes |
The service name. |
demoService |
| functionName |
string |
Yes |
The function name. |
demoFunction |
Request parameters
|
Parameter |
Type |
Required |
Description |
Example |
| If-Match |
string |
No |
Used to ensure that the resource being modified matches the expected resource. The value is obtained from the responses of CreateFunction, GetFunction, and UpdateFunction. |
e19d5cd5af0378da05f63f891c7467af |
| functionUpdateFields |
object |
No |
The request struct for updating a function. |
|
| code | Code |
No |
Code supports two methods to provide the function code package. You must use one and only one method in a single request:
|
|
| customContainerConfig | CustomContainerConfig |
No |
The configuration for the Custom Container runtime. After configuration, the function can use a custom container image to execute the function. |
|
| layers |
array |
No |
The list of layers. Note
Multiple layers are merged in descending order of array index. Files in a layer with a smaller index overwrite files with the same name in a layer with a larger index. |
|
|
string |
No |
The name of the layer resource. |
layername |
|
| description |
string |
No |
The function description. |
test desc |
| environmentVariables |
object |
No |
The environment variables set for the function. You can retrieve the values of environment variables within the function. For more information, see Environment variables. |
|
|
string |
No |
The environment variable configuration. |
{"key":"value"} |
|
| handler |
string |
No |
The entry point for function execution. The specific format is language-dependent. For more information, see Function entry point. |
index.handler |
| memorySize |
integer |
No |
The memory specification of the function in MB. The value must be a multiple of 64 MB. Memory specifications vary by function instance type. For more information, see Instance specifications. |
512 |
| runtime |
string |
No |
The language runtime environment for the function. Valid values: 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, and custom-container. For more information, see Supported function runtime environments. |
python3.9 |
| timeout |
integer |
No |
The timeout for function execution in seconds. Minimum value: 1. Default value: 3. The function is terminated if it exceeds this time limit. |
60 |
| initializationTimeout |
integer |
No |
The timeout for the initializer function in seconds. Minimum value: 1. Default value: 3. The initializer function is terminated if it exceeds this time limit. |
60 |
| initializer |
string |
No |
The entry point for the initializer function execution. The specific format is language-dependent. For more information, see Function entry point. |
index.handler |
| caPort |
integer |
No |
The listening port of the HTTP Server for custom and custom container runtimes. |
9000 |
| InstanceConcurrency |
integer |
No |
The maximum concurrency of an instance. |
10 |
| instanceSoftConcurrency |
integer |
No |
The soft concurrency of an instance, used for graceful scaling. When the concurrency on an instance exceeds the soft concurrency, instance scaling is triggered. For example, if your instance starts slowly, you can set an appropriate soft concurrency to start instances in advance. The value must be less than or equal to instanceConcurrency. |
5 |
| instanceType |
string |
No |
The instance type of the function. Valid values:
|
e1 |
| instanceLifecycleConfig | InstanceLifecycleConfig |
No |
The instance lifecycle configuration. |
|
| customDNS | CustomDNS |
No |
The custom DNS configuration for the function. |
|
| customRuntimeConfig | CustomRuntimeConfig |
No |
The detailed configuration for Custom Runtime functions. |
|
| customHealthCheckConfig | CustomHealthCheckConfig |
No |
The custom health check configuration for the function, applicable only to Custom Runtime and Custom Container. |
|
| cpu |
number |
No |
The CPU specification of the function in vCPU. The value must be a multiple of 0.05 vCPU. |
1.5 |
| diskSize |
integer |
No |
The disk specification of the function in MB. Valid values: 512 MB or 10240 MB. |
512 |
| gpuMemorySize |
integer |
No |
The GPU memory specification of the function in MB. The value must be a multiple of 1024 MB. |
2048 |
| X-Fc-Account-Id |
string |
No |
The ID of your Alibaba Cloud account. |
188077086902**** |
| X-Fc-Code-Checksum |
string |
No |
The CRC-64 value of the function code package. |
1506052139770049xxxx |
| X-Fc-Date |
string |
No |
The start date of the function invocation in the format of EEE,d MMM yyyy HH:mm:ss GMT. |
Wed, 11 May 2022 09:00:00 GMT |
| X-Fc-Trace-Id |
string |
No |
The invocation ID of the function, which corresponds to the requestId in the response. |
test-trace-id |
Response elements
|
Element |
Type |
Description |
Example |
|
object |
The return value of the update function operation. |
||
| codeChecksum |
string |
The CRC64 value of the function code package. |
5434025278388143772 |
| codeSize |
integer |
The size of the function code package returned by the system, in bytes. |
1024 |
| createdTime |
string |
The time when the function was created. |
2016-08-15T15:00:00.000+0000 |
| customContainerConfig | CustomContainerConfig |
The configuration of the Custom Container runtime. After this is configured, the function can use a custom container image to execute the function. |
|
| layers |
array |
The list of layers. Note
Multiple layers are merged in descending order of array index. Files in a layer with a smaller index overwrite files with the same name in a layer with a larger index. |
|
|
string |
The name of the layer resource. |
md5#layername#version |
|
| description |
string |
The function description. |
This is a demo hello world function |
| environmentVariables |
object |
The environment variables set for the function. You can retrieve the values of environment variables within the function. For more information, see Environment variables. |
|
|
string |
The environment variable configuration. |
{"key":"value"} |
|
| functionId |
string |
The unique ID generated by the system for each function. |
2d28e0e9-9ba5-4eed-8b1a-d3d9cd24**** |
| functionName |
string |
The function name. |
demo-function |
| handler |
string |
The execution entry point of the function. |
index.handler |
| lastModifiedTime |
string |
The time when the function was last modified. |
2016-08-15T17:00:00.000+0000 |
| memorySize |
integer |
The memory size configured for the function, in MB. |
512 |
| runtime |
string |
The language runtime environment for the function. Valid values: 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, and custom-container. For more information, see Supported function runtime environments. |
python3.9 |
| timeout |
integer |
The execution timeout period, in seconds. |
10 |
| initializationTimeout |
integer |
The timeout for the initializer function in seconds. Minimum value: 1. Default value: 3. The initializer function is terminated if it exceeds this time limit. |
60 |
| initializer |
string |
The entry point for the initializer function execution. The specific format is language-dependent. |
index.handler |
| caPort |
integer |
The listening port of the HTTP Server for Custom Runtime or Custom Container runtime. |
9000 |
| instanceType |
string |
The instance type of the function. Valid values:
|
e1 |
| instanceSoftConcurrency |
integer |
The soft concurrency of an instance, used for graceful scaling. When the concurrency on an instance exceeds the soft concurrency, instance scaling is triggered. For example, if your instance starts slowly, you can set an appropriate soft concurrency to start instances in advance. The value must be less than or equal to instanceConcurrency. |
5 |
| instanceLifecycleConfig | InstanceLifecycleConfig |
The instance lifecycle configuration. |
|
| customDNS | CustomDNS |
The custom DNS configuration for the function. |
|
| customRuntimeConfig | CustomRuntimeConfig |
The detailed configuration for Custom Runtime functions. |
|
| customHealthCheckConfig | CustomHealthCheckConfig |
The custom health check configuration for the function, applicable only to Custom Runtime and Custom Container. |
|
| cpu |
number |
The CPU specification of the function in vCPU. The value must be a multiple of 0.05 vCPU. |
1.5 |
| diskSize |
integer |
The disk specification of the function in MB. Valid values: 512 MB or 10240 MB. |
512 |
| instanceConcurrency |
integer |
The concurrency of a single instance. |
10 |
| gpuMemorySize |
integer |
The GPU memory specification of the function in MB. The value must be a multiple of 1024 MB. |
2048 |
| layersArnV2 |
array |
The list of layer ARNs. |
|
|
string |
The layer resource locator. |
acs:fc:cn-hangzhou:official:layers/Python310/versions/2 |
Examples
Success response
JSON format
{
"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"
]
}
Error codes
See Error Codes for a complete list.
Release notes
See Release Notes for a complete list.