Creates a function.
Operation description
Resources of Function Compute are scheduled and run based on functions. A function usually refers to a code snippet that is written by a user and can be independently executed to respond to events and requests.
Debugging
Authorization information
The following table shows the authorization information corresponding to the API. The authorization information can be used in the Action
policy element to grant a RAM user or RAM role the permissions to call this API operation. Description:
- Operation: the value that you can use in the Action element to specify the operation on a resource.
- Access level: the access level of each operation. The levels are read, write, and list.
- Resource type: the type of the resource on which you can authorize the RAM user or the RAM role to perform the operation. Take note of the following items:
- The required resource types are displayed in bold characters.
- If the permissions cannot be granted at the resource level,
All Resources
is used in the Resource type column of the operation.
- Condition Key: the condition key that is defined by the cloud service.
- Associated operation: other operations that the RAM user or the RAM role must have permissions to perform to complete the operation. To complete the operation, the RAM user or the RAM role must have the permissions to perform the associated operations.
Operation | Access level | Resource type | Condition key | Associated operation |
---|---|---|---|---|
fc:CreateFunction | create | *All Resources * |
| none |
Request syntax
POST /2023-03-30/functions HTTP/1.1
Request parameters
Parameter | Type | Required | Description | Example |
---|---|---|---|---|
body | CreateFunctionInput | Yes | The information about function configurations. |
Response parameters
Examples
Sample success responses
JSON
format
{
"codeChecksum": "2825179536350****",
"codeSize": 412,
"cpu": 1,
"createdTime": "2023-04-01T08:15:27Z",
"customContainerConfig": {
"accelerationInfo": {
"status": "Ready"
},
"accelerationType": "default",
"acrInstanceId": "cri-xxxxxxxxxx",
"command": [
"arg1"
],
"entrypoint": [
"/code/bootstrap"
],
"healthCheckConfig": {
"failureThreshold": 1,
"httpGetUrl": "/ready",
"initialDelaySeconds": 1,
"periodSeconds": 1,
"successThreshold": 2,
"timeoutSeconds": 2
},
"image": "registry-vpc.cn-hangzhou.aliyuncs.com/fc-demo/helloworld:v1beta1",
"port": 9000,
"registryConfig": {
"authConfig": {
"password": "abc***",
"userName": "admin"
},
"certConfig": {
"insecure": true,
"rootCaCertBase64": "cm9vdF9jYV9jZXJ0"
},
"networkConfig": {
"securityGroupId": "sg-xxxxxxxxxxxxxx",
"vSwitchId": "vsw-xxxxxxxxxxxxxx",
"vpcId": "vpc-xxxxxxxxxxxxxx"
}
},
"resolvedImageUri": "stand-sh-registry-vpc.cn-shanghai.cr.aliyuncs.com/fc-demo2/springboot-helloworld@sha256:68d1****0d64d6"
},
"customDNS": {
"dnsOptions": [
{
"name": "ndots",
"value": "2"
}
],
"nameServers": [
"8.8.x.x"
],
"searches": [
"ns1.svc.cluster-domain.example"
]
},
"customRuntimeConfig": {
"args": [
"arg1"
],
"command": [
"/code/bootstrap"
],
"healthCheckConfig": {
"failureThreshold": 1,
"httpGetUrl": "/ready",
"initialDelaySeconds": 1,
"periodSeconds": 1,
"successThreshold": 2,
"timeoutSeconds": 2
},
"port": 9000
},
"description": "my function",
"diskSize": 512,
"environmentVariables": {
"key": "value1"
},
"functionArn": "acs:fc:cn-shanghai:123:functions/functionName",
"functionId": "aa715851-1c20-4b89-a8fb-***",
"functionName": "my-function-1",
"gpuConfig": {
"gpuMemorySize": 2048,
"gpuType": "fc.gpu.ampere.1"
},
"handler": "index.handler",
"instanceConcurrency": 1,
"instanceLifecycleConfig": {
"initializer": {
"handler": "index.initializer",
"timeout": 10
},
"preStop": {
"handler": "index.initializer",
"timeout": 10
}
},
"internetAccess": true,
"lastModifiedTime": "2023-05-01T08:15:27Z",
"lastUpdateStatus": "InProgress",
"lastUpdateStatusReason": "The system is currently processing the acceleration optimization for the image.",
"lastUpdateStatusReasonCode": "ImageOptimizing",
"layers": [
{
"arn": "acs:fc:cn-beijing:186824xxxxxx:layers/fc_layer/versions/1",
"size": 421
}
],
"logConfig": {
"enableInstanceMetrics": true,
"enableRequestMetrics": true,
"logBeginRule": "DefaultRegex",
"logstore": "test-logstore",
"project": "test-project"
},
"memorySize": 512,
"nasConfig": {
"groupId": 100,
"mountPoints": [
{
"enableTLS": true,
"mountDir": "/home/test",
"serverAddr": "***-uni85.cn-hangzhou.nas.com:/"
}
],
"userId": 100
},
"ossMountConfig": {
"mountPoints": [
{
"bucketName": "my-bucket",
"bucketPath": "/my-dir",
"endpoint": "http://oss-cn-shanghai.aliyuncs.com",
"mountDir": "/mnt/dir",
"readOnly": true
}
]
},
"role": "acs:ram::188077086902****:role/fc-test",
"runtime": "python3.10",
"state": "Pending",
"stateReason": "Function creating",
"stateReasonCode": "Creating",
"timeout": 60,
"tracingConfig": {
"params": {
"key": "tracing_analysis_jaeger_endpoint"
},
"type": "Jaeger"
},
"vpcConfig": {
"securityGroupId": "sg-bp18hj1wtxgy3b0***",
"vSwitchIds": [
"vsw-bp1ozpcrdc6r****"
],
"vpcId": "vpc-***",
"role": "acs:ram::188077086902****:role/fc-test"
}
}
Error codes
For a list of error codes, visit the Service error codes.
Change history
Change time | Summary of changes | Operation |
---|---|---|
2024-02-22 | The internal configuration of the API is changed, but the call is not affected | View Change Details |
2023-08-30 | API Description Update | View Change Details |
2023-08-30 | API Description Update. The response structure of the API has changed | View Change Details |
2023-07-05 | The request parameters of the API has changed | View Change Details |
2023-06-28 | Add Operation | View Change Details |