tencent cloud



Last updated: 2022-02-16 16:15:27

    1. API Description

    Domain name for API request: scf.tencentcloudapi.com.

    This API is used to create a function based on the input parameters.

    A maximum of 100 requests can be initiated per second for this API.

    We recommend you to use API Explorer
    Try it
    API Explorer provides a range of capabilities, including online call, signature authentication, SDK code generation, and API quick search. It enables you to view the request, response, and auto-generated examples.

    2. Input Parameters

    The following request parameter list only provides API request parameters and some common parameters. For the complete common parameter list, see Common Request Parameters.
    This document describes the parameters for Signature V1. It's recommended to use the V3 signature, which provides higher security. Note that for Signature V3, the common parameters need to be placed in the HTTP Header. See details.

    Parameter Name Required Type Description
    Action Yes String Common parameter. The value used for this API: CreateFunction.
    Version Yes String Common parameter. The value used for this API: 2018-04-16.
    Region Yes String Common parameter. For more information, please see the list of regions supported by the product.
    FunctionName Yes String Name of the new function. The name can contain 2 to 60 characters, including English letters, digits, hyphens (-), and underscores (_). The name must start with a letter and cannot end with a hyphen or underscore.
    Code Yes Code Function code. Note: COS, ZipFile, and DemoId cannot be specified at the same time.
    Handler No String Function handler name. It supports the format of "file name.handler name" where the file name and handler name are separated with a "." (for Java, it is in the format of "package name.class name::handler name"). File and handler names can contain 2–60 letters, digits, underscores, and dashes and must start and end with letters
    Description No String Function description. It can contain up to 1,000 characters including letters, digits, spaces, commas (,), periods (.), and Chinese characters.
    MemorySize No Integer Memory size available for function during execution. Default value: 128 MB. Value range: 64 or 128-3072 MB in increments of 128 MB
    Timeout No Integer Maximum execution duration of function in seconds. Value range: 1-900 seconds. Default value: 3 seconds
    Environment No Environment Function environment variable
    Runtime No String Function runtime environment. Valid values: Python2.7, Python3.6, Nodejs6.10, Nodejs8.9, Nodejs10.15, Nodejs12.16, Php5, Php7, Go1, Java8, CustomRuntime. Default value: Python2.7
    VpcConfig No VpcConfig Function VPC configuration
    Namespace No String Function namespace
    Role No String Role bound to the function
    InstallDependency No String Specifies whether to install dependency online. TRUE: yes. Default to FALSE. It is only available for Node.js functions.
    ClsLogsetId No String CLS Logset ID to which the function logs are shipped
    ClsTopicId No String CLS Topic ID to which the function logs are shipped
    Type No String Function type. The default value is Event. Enter Event if you need to create a trigger function. Enter HTTP if you need to create an HTTP function service.
    CodeSource No String Code source. Valid values: ZipFile, Cos, Demo
    Layers.N No Array of LayerVersionSimple List of layer versions to be associate with the function. Layers will be overwritten sequentially in the order in the list.
    DeadLetterConfig No DeadLetterConfig Dead letter queue parameter
    PublicNetConfig No PublicNetConfigIn Public network access configuration
    CfsConfig No CfsConfig File system configuration parameter, which is used for the function to mount the file system
    InitTimeout No Integer The function initialization timeout period. It defaults to 65s for general cases and 90s for image deployment functions.
    Tags.N No Array of Tag Tag parameter of the function. It is an array of key-value pairs.
    AsyncRunEnable No String Whether to enable the async attribute. TRUE: yes; FALSE: no
    TraceEnable No String Whether to enable event tracking. TRUE: yes; FALSE: no
    ProtocolType No String Protocols supported by HTTP-triggered functions. Valid value: WS (WebSockets)
    ProtocolParams No ProtocolParams Parameters of the specified protocol

    3. Output Parameters

    Parameter Name Type Description
    RequestId String The unique request ID, which is returned for each request. RequestId is required for locating a problem.

    4. Example

    Example1 Creating function

    Input Example

    &<Common request parameters>

    Output Example

    "Response": {
      "RequestId": "eac6b301-a322-493a-8e36-83b295459397"

    5. Developer Resources


    TencentCloud API 3.0 integrates SDKs that support various programming languages to make it easier for you to call APIs.

    Command Line Interface

    6. Error Code

    The following only lists the error codes related to the API business logic. For other error codes, see Common Error Codes.

    Error Code Description
    FailedOperation Operation failed.
    FailedOperation.ApmConfigInstanceId Failed to obtain Apm InstanceId
    FailedOperation.CreateFunction Operation failed.
    FailedOperation.Namespace The namespace already exists. Please do not create it again.
    FailedOperation.OpenService Failed to activate the service.
    FailedOperation.QcsRoleNotFound The role does not exist.
    FailedOperation.TotalConcurrencyMemoryInProgress The user already has a concurrency quota setting task in progress. Please try again later.
    FailedOperation.UnOpenedService The specified service has not been activated. Please submit a ticket for activation.
    InternalError Internal error.
    InternalError.GetRoleError Internal service error.
    InternalError.System Internal system error.
    InternalError.SystemError Internal service error.
    InvalidParameter.Payload Invalid request parameter.
    InvalidParameterValue Incorrect parameter value.
    InvalidParameterValue.Action The value of Action does not conform to the specification. Please fix it and try again. For more information, please visit https://tencentcs.com/5jXKFnBW.
    InvalidParameterValue.ApmConfig ApmConfig input error
    InvalidParameterValue.ApmConfigInstanceId ApmConfigInstanceId input error
    InvalidParameterValue.ApmConfigRegion ApmConfigRegion input error
    InvalidParameterValue.Args The value of Args is incorrect.
    InvalidParameterValue.CfsParameterDuplicate The cfs configuration item already exists.
    InvalidParameterValue.CfsParameterError The value of cfs configuration item does not meet the specification.
    InvalidParameterValue.CfsStructionError Invalid CFS parameter format
    InvalidParameterValue.Cls Cls error.
    InvalidParameterValue.Code Code error.
    InvalidParameterValue.CodeSecret CodeSecret error.
    InvalidParameterValue.CodeSource CodeSource error.
    InvalidParameterValue.Command The value of Command[Entrypoint] is incorrect.
    InvalidParameterValue.Cos Cos error.
    InvalidParameterValue.CosBucketName Invalid CosBucketName.
    InvalidParameterValue.CosBucketRegion The value of CosBucketRegion is invalid. Please modify and try again. See: https://tencentcs.com/5jXKFnBW
    InvalidParameterValue.CosObjectName Invalid CosObjectName.
    InvalidParameterValue.DeadLetterConfig The value of DeadLetterConfig is invalid. Please modify and try again. See https://tencentcs.com/5jXKFnBW.
    InvalidParameterValue.Description Description error.
    InvalidParameterValue.DnsInfo The configuration of the environment variable DNS[OS_NAMESERVER] is incorrect.
    InvalidParameterValue.EipConfig EipConfig parameter error.
    InvalidParameterValue.Environment Environment error.
    InvalidParameterValue.EnvironmentExceededLimit The size of the environment variable exceeds the limit. Please keep it within 4 KB.
    InvalidParameterValue.EnvironmentSystemProtect You cannot modify the function's system environment variables or runtime environment variables.
    InvalidParameterValue.FunctionName The function does not exist.
    InvalidParameterValue.GitCommitId The value of GitCommitId does not conform to the specification. Please fix it and try again. For more information, please visit https://tencentcs.com/5jXKFnBW.
    InvalidParameterValue.GitUrl The format of GitUrl is incorrect.
    InvalidParameterValue.Handler Handler error.
    InvalidParameterValue.IdleTimeOut IdleTimeOut input parameter error
    InvalidParameterValue.ImageUri The input of imageUri is incorrect.
    InvalidParameterValue.Layers Layers parameter error.
    InvalidParameterValue.LimitExceeded The parameter exceeds the length limit.
    InvalidParameterValue.Memory The value of Memory does not conform to the specification. Please fix it and try again. For more information, please visit https://tencentcs.com/5jXKFnBW.
    InvalidParameterValue.MemorySize MemorySize error.
    InvalidParameterValue.Namespace Namespace error.
    InvalidParameterValue.NodeSpec NodeSpec parameter error
    InvalidParameterValue.NodeType NodeType parameter error
    InvalidParameterValue.ProtocolType ProtocolType input parameter error
    InvalidParameterValue.PublicNetConfig The PublicNetConfig parameter is invalid.
    InvalidParameterValue.RegistryId The value Enterprise Edition image ID [RegistryId] is incorrect.
    InvalidParameterValue.Runtime Runtime error.
    InvalidParameterValue.Stamp The value of Stamp does not meet the specification. Please fix it and try again.
    InvalidParameterValue.TempCosObjectName Invalid TempCosObjectName.
    InvalidParameterValue.TraceEnable The value of TraceEnable is invalid. Please modify and try again.
    InvalidParameterValue.Type Type error.
    InvalidParameterValue.VpcNotSetWhenOpenCfs A VPC needs to be activated together with CFS configuration.
    InvalidParameterValue.WebSocketsParams WebSocketsParams input parameter error
    InvalidParameterValue.ZipFile A non-standard zip file was detected. Please recompress and try again.
    InvalidParameterValue.ZipFileBase64BinasciiError Failed to Base64-decode the compressed file: Incorrect padding. Please fix it and try again.
    LimitExceeded.Eip The EIP resource exceeded the limit.
    LimitExceeded.Function If the number of functions exceeds the upper limit, you can apply for an increase by submitting a ticket.
    LimitExceeded.InitTimeout The value of InitTimeout has reached the upper limit. You can submit a ticket to increase it at https://tencentcs.com/7Fixwt63.
    LimitExceeded.Memory The memory exceeds the upper limit.
    LimitExceeded.Timeout Timeout exceeds the upper limit.
    MissingParameter.Code Failed to import Code.
    MissingParameter.Runtime Runtime is missing.
    ResourceInUse The resource is in use.
    ResourceInUse.Function This function already exists.
    ResourceInUse.FunctionName This FunctionName already exists.
    ResourceNotFound The resource does not exist.
    ResourceNotFound.CfsMountInsNotMatch Unable to find the specified mount point under the specified CFS
    ResourceNotFound.CfsStatusError CFS not available
    ResourceNotFound.CfsVpcNotMatch VPCs of the CFS instance and the SCF function are different.
    ResourceNotFound.Cmq Cmq does not exist.
    ResourceNotFound.Demo Demo does not exist.
    ResourceNotFound.GetCfsMountInsError An error occurred while getting the CFS mount target information.
    ResourceNotFound.GetCfsNotMatch An error occurred while getting the CFS information.
    ResourceNotFound.ImageConfig Failed to find the specified ImageConfig. Please create it first.
    ResourceNotFound.Layer The layer does not exist.
    ResourceNotFound.Namespace Namespace does not exist.
    ResourceNotFound.Role The role does not exist.
    ResourceNotFound.Vpc The VPC or subnet does not exist.
    ResourceUnavailable.Namespace The Namespace is not available.
    UnauthorizedOperation.CAM CAM authentication failed.
    UnauthorizedOperation.Region Region error.
    UnauthorizedOperation.Role You do not have permissions to access your Cos resources.
    UnauthorizedOperation.TempCosAppid The Appid of TempCos is not consistent with the APPID of the request account.
    UnsupportedOperation Unsupported operation.
    UnsupportedOperation.EipFixed The specified EipFixed does not exist.
    UnsupportedOperation.VpcConfig The specified VpcConfig does not exist.
    Contact Us

    Contact our sales team or business advisors to help your business.

    Technical Support

    Open a ticket if you're looking for further assistance. Our Ticket is 7x24 avaliable.

    7x24 Phone Support