函数工作流 FUNCTIONGRAPH-创建函数 - CreateFunction:请求示例

时间:2025-12-08 18:41:21

请求示例

  • 创建名为xxx的python2.7函数,内存大小为128MB,超时时间3s,添加加密环境变量password,添加磁盘挂载。
    POST https://{Endpoint}/v2/{project_id}/fgs/functions
    
    {
      "func_name" : "xxx",
      "package" : "xxx",
      "runtime" : "Python2.7",
      "handler" : "index.py",
      "type" : "v2",
      "memory_size" : 128,
      "timeout" : 3,
      "code_type" : "inline",
      "mount_config" : {
        "mount_user" : {
          "user_id" : -1,
          "user_group_id" : -1
        },
        "func_mounts" : [ {
          "mount_resource" : "268xxx-d3xx-4cxx-98xx-d1dbxxx",
          "local_mount_path" : "/mnt",
          "mount_type" : "sfsTurbo"
        } ]
      },
      "encrypted_user_data" : "{\"password\":\"1234\"}",
      "func_code" : {
        "file" : "xxxxx",
        "link" : ""
      }
    }
  • 创建名为xxx的python3.9函数,内存大小为128MB,超时时间3s,代码由OBS上传。
    POST https://{Endpoint}/v2/{project_id}/fgs/functions
    
    {
      "func_name" : "xxx",
      "package" : "xxx",
      "runtime" : "Python3.9",
      "handler" : "index.py",
      "type" : "v2",
      "memory_size" : 128,
      "timeout" : 3,
      "code_type" : "obs",
      "code_url" : "https:xxx"
    }
  • 创建名为xxx的自定义镜像函数,内存大小为128MB,超时时间3s,代码由SWR上传。
    POST https://{Endpoint}/v2/{project_id}/fgs/functions
    
    {
      "func_name" : "xxx",
      "package" : "xxx",
      "runtime" : "Custom Image",
      "handler" : "-",
      "type" : "v2",
      "memory_size" : 128,
      "timeout" : 3,
      "code_type" : "obs",
      "code_url" : "https:xxx",
      "xrole" : "xxx",
      "custom_image" : {
        "enabled" : true,
        "image" : "swr.xxx"
      }
    }
  • 创建名为xxx的python3.10函数,内存大小为512MB,超时时间30s,配置委托为fgs_default_agency,配置VPC与内网域名。
    {
      "func_name": "xxx",
      "package": "default",
      "runtime": "Python3.10",
      "timeout": 30,
      "handler": "index.handler",
      "func_vpc": {
        "vpc_id": "07d030e7-xxxx-xxxxx-xxxx-ba7ce53b87b3",
        "subnet_id": "e7e56144-xxxx-xxxxx-xxxx-44a2e5c1b2da",
        "is_safety": false
      },
      "memory_size": 512,
      "code_type": "inline",
      "xrole": "fgs_default_agency",
      "domain_names": "[{\"id\":\"ffxxxxxxxxxfd3b80188b3e6f81exxxx\",\"domain_name\":\"test.com.\"}]"
    }
support.huaweicloud.com/api-functiongraph/functiongraph_06_0108.html