All Products
Search
Document Center

Function Compute:CreateFunctionInput

Last Updated:Jan 14, 2026

Parameter

Type

Description

Example

object

The request parameters for creating a function.

code InputCodeLocation

The function code in a ZIP package. Specify either code or customContainerConfig.

cpu

number

The CPU specification of the function in vCPUs. The value must be a multiple of 0.05 vCPU. The minimum value is 0.05 and the maximum value is 16. The ratio of CPU to memory size (in GB) must be between 1:1 and 1:4.

1

customContainerConfig CustomContainerConfig

The configuration for the custom container runtime. After you configure this parameter, the function can use a custom container image to run. Specify either code or customContainerConfig.

customDNS CustomDNS

The custom DNS configuration.

customRuntimeConfig CustomRuntimeConfig

The custom runtime configuration.

description

string

The description of the function.

my function

diskSize

integer

The disk size of the function in MB. Valid values are 512 MB and 10240 MB.

512

environmentVariables

object

The environment variables of the function. These variables can be accessed in the runtime environment.

string

The value of the environment variable.

value1

functionName

string

The name of the function. The name can contain only letters, digits, underscores (_), and hyphens (-). It cannot start with a digit or a hyphen (-). The name must be 1 to 64 characters in length.

my-function-1

gpuConfig GPUConfig

The GPU configuration of the function.

handler

string

The entry point for the function execution. The format varies based on the runtime.

index.handler

instanceConcurrency

integer

The maximum concurrency of the instance.

1

instanceLifecycleConfig InstanceLifecycleConfig

The configuration for instance lifecycle hooks.

internetAccess

boolean

Specifies whether the function can access the Internet. The default value is true.

true

layers

array

A list of layers. Multiple layers are merged in descending order of their array index. The content of a layer with a smaller index overwrites files with the same name in a layer with a larger index.

string

The ARN of the layer.

acs:fc:cn-beijing:186824xxxxxx:layers/fc_layer/versions/1

logConfig LogConfig

The log configuration. Logs generated by the function are written to the configured Logstore.

memorySize

integer

The memory size of the function in MB. The value must be a multiple of 64 MB. The minimum value is 128 MB and the maximum value is 32 GB. The ratio of CPU to memory size (in GB) must be between 1:1 and 1:4.

512

nasConfig NASConfig

The NAS configuration. After you configure this parameter, the function can access the specified NAS resources.

ossMountConfig OSSMountConfig

The OSS mount configuration.

role

string

The RAM role that you grant to Function Compute. After you set this parameter, Function Compute assumes this role to generate temporary access credentials. The function can use these temporary credentials to access specified Alibaba Cloud services, such as OSS and Tablestore.

acs:ram::188077086902****:role/fc-test

runtime

string

The runtime environment of the function. Supported runtimes include the following: nodejs12, nodejs14, nodejs16, nodejs18, nodejs20, go1, python3, python3.9, python3.10, python3.12, java8, java11, php7.2, dotnetcore3.1, custom, custom.debian10, custom.debian11, custom.debian12, and custom-container.

python3.10

timeout

integer

The timeout period for the function to run, in seconds. The minimum value is 1, the maximum value is 86400, and the default value is 3. The function execution is terminated if it exceeds this time.

60

tracingConfig TracingConfig

The Tracing Analysis configuration. After you integrate Function Compute with Tracing Analysis, you can record the time consumed by requests in Function Compute, view the cold start time of functions, and record the time consumed by internal function calls.

vpcConfig VPCConfig

The VPC configuration. After you configure this parameter, the function can access the specified VPC resources.

tags

array

A list of tags.

Tag

The tag information.

disableOndemand

boolean

Specifies whether to disable the creation of on-demand instances. If this feature is enabled, on-demand instances are not created. Only provisioned instances can be used.

sessionAffinity

string

The affinity policy for Function Compute invocation requests. Set this parameter to MCP_SSE to implement request affinity for the MCP SSE protocol. Set it to GENERATED_COOKIE to use cookie-based affinity. Set it to HEADER_FIELD to use header-based affinity. If you do not set this parameter or set it to NONE, no affinity is applied. Requests are then routed based on the default scheduling policy of Function Compute.

MCP_SSE

enableLongLiving

boolean

Specifies whether to allow provisioned instances of GPU-accelerated functions to be long-lasting. If this feature is enabled, the created function instances are not injected with STS tokens.

resourceGroupId

string

instanceIsolationMode

string

The isolation mode of the instance.

sessionAffinityConfig

string

When you set the sessionAffinity type, you must set the related affinity configuration. For MCP_SSE affinity, fill in the MCPSSESessionAffinityConfig configuration. For cookie-based affinity, fill in the CookieSessionAffinityConfig configuration. For header field-based affinity, fill in the HeaderFieldSessionAffinityConfig configuration.

{\"sseEndpointPath\":\"/sse\", \"sessionConcurrencyPerInstance\":20}

idleTimeout

integer

The idle timeout period before an instance is released.

100

disableInjectCredentials

string

Specifies whether to prevent STS token injection. Valid values: None, Env, Request, and All. None: Injects the token in all locations. Env: Does not inject the token into environment variables. Request: Does not inject the token into the request, including the context and header. All: Does not inject the token in any location.

Env

polarFsConfig PolarFsConfig

The PolarFS configuration. After you configure this parameter, the function can access the specified PolarFS resources.