CreateFunction
Creates a function.
Operation description
When you create a function by using an OSS code package, if the error "unable to access object xxx in bucket xxx" is returned, you must grant the current user access permissions to the OSS bucket. For example, you can attach the system access policy AliyunOSSReadOnlyAccess or a custom authorization with finer granularity such as oss:GetObject. For details about the policy content, refer to Grant a Resource Access Management (RAM) user the permissions to read all resources in a specific bucket.
Try it now
Test
RAM authorization
|
Action |
Access level |
Resource type |
Condition key |
Dependent action |
|
fc:CreateFunction |
create |
*All Resource
|
None | None |
Request syntax
POST /2023-03-30/functions HTTP/1.1
Request parameters
|
Parameter |
Type |
Required |
Description |
Example |
| body | CreateFunctionInput |
Yes |
The function configuration information. |
Response elements
|
Element |
Type |
Description |
Example |
| Function |
The function configuration information. |
Examples
Success response
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": false,
"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",
"disableInjectCredentials": "Env",
"disableOndemand": false,
"diskSize": 512,
"enableLongLiving": false,
"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",
"idleTimeout": 100,
"instanceConcurrency": 1,
"instanceIsolationMode": "",
"instanceLifecycleConfig": {
"initializer": {
"command": [
"curl -X POST 'http://localhost:9000/preWarm"
],
"handler": "index.initializer",
"timeout": 10
},
"preStop": {
"command": [
"curl -X POST 'http://localhost:9000/preWarm"
],
"handler": "index.initializer",
"timeout": 10
}
},
"internetAccess": true,
"invocationRestriction": {
"disable": false,
"lastModifiedTime": "2026-10-01T10:00:00Z",
"reason": "Function invocation is disabled."
},
"juiceFsConfig": {
"envs": {
"key": ""
},
"mountPoints": [
{
"args": [
""
],
"mountDir": "",
"remoteDir": "",
"token": "",
"volumeName": ""
}
]
},
"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
}
],
"lockInfo": {
"lockedAt": "2025-04-05T10:00:00Z",
"lockedBy": "AgentRun",
"lockedResources": [
"function"
]
},
"logConfig": {
"enableInstanceMetrics": true,
"enableLlmMetrics": false,
"enableRequestMetrics": true,
"logBeginRule": "DefaultRegex",
"logstore": "test-logstore",
"project": "test-project"
},
"memorySize": 512,
"microSandboxConfig": {
"acrInstanceId": "",
"image": "",
"osType": "linux-amd64",
"readyCommand": "curl -fs http://127.0.0.1:8080/health",
"registryConfig": {
"authConfig": {
"password": "abc***",
"userName": "admin"
},
"certConfig": {
"insecure": false,
"rootCaCertBase64": "cm9vdF9jYV9jZXJ0"
},
"networkConfig": {
"securityGroupId": "sg-xxxxxxxxxxxxxx",
"vSwitchId": "vsw-xxxxxxxxxxxxxx",
"vpcId": "vpc-xxxxxxxxxxxxxx"
}
},
"startCommand": "/usr/local/bin/start-service",
"steps": [
{
"args": [
"[\"root\"]"
],
"type": "USER, WORKDIR, ENV, RUN"
}
]
},
"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,
"nonempty": false
}
]
},
"polarFsConfig": {
"groupId": 0,
"mountPoints": [
{
"extraOptions": "--skip-delete-rows-check=false --skip-dir-nlink=0 ",
"instanceId": "pfs-xxx",
"mountDir": "/mnt/polarfs",
"readOnly": false,
"remoteDir": "/share"
}
],
"userId": 0
},
"resourceGroupId": "",
"role": "acs:ram::188077086902****:role/fc-test",
"runtime": "python3.10",
"sessionAffinity": "MCP_SSE",
"sessionAffinityConfig": "{\\\"sseEndpointPath\\\":\\\"/sse\\\", \\\"sessionConcurrencyPerInstance\\\":20}",
"state": "Pending",
"stateReason": "Function creating",
"stateReasonCode": "Creating",
"tags": [
{
"Key": "k1",
"Value": "v1"
}
],
"timeout": 60,
"tracingConfig": {
"params": {
"key": "http://tracing-analysis-dc-hz.aliyuncs.com/adapt_xxx/api/otlp/traces"
},
"type": "Jaeger"
},
"vpcConfig": {
"role": "acs:ram::188077086902****:role/fc-test",
"securityGroupId": "sg-bp18hj1wtxgy3b0***",
"vSwitchIds": [
"vsw-bp1ozpcrdc6r****"
],
"vpcId": "vpc-***"
}
}
Error codes
See Error Codes for a complete list.
Release notes
See Release Notes for a complete list.