Tencent Cloud SDK
Tencent CloudGitHub
简体中文
简体中文
  • 欢迎
  • 常见问题
  • Python
  • 概述
  • 安装
  • 入门
  • 最佳实践
    • 无服务器云函数
      • 无服务器云函数间调用
      • 定时调用无服务器云函数
      • 原生调用无服务器云函数
        • 绑定到无服务器云函数
        • 使用例程组织无服务器云函数
    • 无服务器数据库
      • 创建和管理无服务器数据库
    • 其他 Tencent Cloud 产品
      • 选择最佳的访问凭据类型
  • API 文档
    • 无服务器云函数
      • 类和方法
        • Client 类
          • easy_invoke 方法
          • routine_invoke 方法
          • select_function 方法
          • select_routine 方法
          • bind_function 方法
          • bind_routine 方法
          • schedule_invoke 方法
          • run_schedule 方法
          • invoke 方法
          • create_function 方法
          • delete_function 方法
          • publish_function_version 方法
          • copy_function 方法
          • update_function_code 方法
          • update_function_configure 方法
          • get_function_result_by_request_id 方法
          • get_function_results 方法
          • list_functions 方法
          • list_function_versions 方法
          • get_function_info 方法
          • create_trigger 方法
          • delete_trigger 方法
          • create_namespace 方法
          • delete_namespace 方法
          • list_namespaces 方法
          • update_namespace 方法
          • get_function_code_download_url 方法
          • download_function_code 方法
          • create_layer 方法
          • delete_layer 方法
          • get_layer_info 方法
          • list_layers 方法
          • list_layer_versions 方法
          • submit_monitor_indicator 方法
        • FunctionSchedule 类
          • cancel 方法
        • FunctionResultFuture 类
          • get_request_id 方法
        • FunctionTrigger 类
          • get_trigger_kind 方法
          • get_trigger_context 方法
          • use_timer 方法
          • use_object_storage_bucket 方法
          • use_message_queue_topic 方法
        • FunctionCode 类
          • get_code_source 方法
          • get_code_context 方法
          • use_object_storage_bucket 方法
          • use_local_zip_archive 方法
          • use_git_repository 方法
        • LayerContent 类
        • fetch_client 函数
        • use_routine_dispatcher 函数
      • 数据类型
        • FunctionResult 类型
        • FunctionInfo 类型
        • FunctionInfoEx 类型
        • FunctionVersionInfo 类型
        • NamespaceInfo 类型
        • LayerInfo 类型
        • FunctionConfigure 类型
        • FunctionResultFilter 类型
        • FunctionFilter 类型
        • ObjectStorageBucketTriggerFilter 类型
        • MessageQueueTopicTriggerFilter 类型
        • LayerFilter 类型
        • FunctionRuntime 枚举器
        • FunctionType 枚举器
        • FunctionResultType 枚举器
        • FunctionTriggerKind 枚举器
        • FunctionCodeSource 枚举器
        • LayerContentSource 枚举器
        • LayerStatus 枚举器
      • 异常
        • InvokeError 异常
        • StatusError 异常
    • 无服务器数据库
      • 类和方法
        • Client 类
          • create_instance 方法
          • delete_instance 方法
          • list_instances 方法
          • set_instance_extranet 方法
        • fetch_client 函数
      • 数据类型
        • InstanceInfo 类型
        • InstanceConfigure 类型
        • DatabaseCharset 枚举器
    • 其他 Tencent Cloud 产品
      • 类和方法
        • Waitable 类
          • wait_for_done 方法
          • has_done 方法
          • set_result 方法
        • ErrorManager 类
          • add_handler 方法
          • remove_handler 方法
          • has_handler 方法
          • clear_all_handler 方法
        • UniversalClient 类
          • action 方法
          • action_for_product 方法
          • select_action 方法
          • get_product_id 方法
          • set_product_id 方法
          • set_access_endpoint 方法
          • set_access_proxies 方法
          • get_last_response_metadata 方法
        • Proxies 类
          • use_proxy_server 方法
          • add_proxy_server 方法
          • remove_proxy_server 方法
      • 数据类型
        • ResponseMetadata 类型
        • ProxyAuth 类型
        • ProxyType 枚举器
        • ErrorHandlerResult 枚举器
        • WaitableStatus 枚举器
      • 异常
        • Error 异常
        • NotFoundError 异常
        • ExistedError 异常
        • OccupiedError 异常
        • ClientError 异常
        • RequestError 异常
        • ResponseError 异常
        • ActionError 异常
        • ActionResultError 异常
  • GitHub 存储库
  • Issues 跟踪器
  • PyPI 项目主页
由 GitBook 提供支持
在本页
  • 简要
  • 参数
  • 返回值
  • 兼容性
  • 异常
  • 示例
  • 适用于

这有帮助吗?

导出为 PDF
  1. API 文档
  2. 无服务器云函数
  3. 类和方法
  4. Client 类

create_function 方法

命名空间和类:tencent.cloud.serverless.functions.Client

简要

调用给定无服务器云函数并获得无服务器云函数的运行结果。

def create_function(self,
    region_id: str,
    namespace_name: str,
    function_name: str,
    function_description: str,
    function_code: FunctionCode,
    function_runtime: str = 'Python3',
    function_type: str = None,
    function_configure: dict = None
)

参数

该方法的参数和参数描述如下:

参数

类型

必选

描述

region_id

str

是

创建的无服务器云函数所在数据中心的唯一标识符。

namespace_name

str

是

创建的无服务器云函数所在命名空间的名称。

function_name

str

是

创建的无服务器云函数名称。

function_description

str

否

创建的无服务器云函数描述正文。

function_code

是

创建的无服务器云函数代码实例。

function_runtime

str

否

function_type

str

否

function_configure

否

创建的无服务器云函数配置。如果该参数被忽略或设置为 None,被创建的函数将采用默认配置。

返回值

该方法返回可等待操作对象,这将允许您等待无服务器云函数资源真正地创建完成。

兼容性

在 Tencent Cloud SDK for Python 0.1.6 或更低版本中,该方法没有返回值。

异常

该方法可能会主动引发以下异常:

ValueError

参数值或类型不符合预期。

ActionError

Tencent Cloud API 错误。例如访问凭据无效、给定无服务器云函数不存在等均会引发该异常。

示例

下面我们将通过一段 Python 代码向您演示如何使用该方法:

function_client.create_function(
    region_id = 'ap-shanghai',
    namespace_name = 'default',
    function_name = 'addend',
    function_description = 'Addition function',
    function_code = functions.FunctionCode().use_object_storage_bucket(
        region_id = 'ap-shanghai-1',
        bucket_id = 'scf-code',
        object_name = 'source.zip'
    ),
    function_runtime = functions.FunctionRuntime.Python,
    function_type = functions.FunctionType.Event,
    function_configure = {
        'handler': 'index.main',
        'memory_size': 128,
        'time_out': 3
    }
)

适用于

Tencent Cloud SDK for Python

产品软件包:tencent-cloud-sdk-serverless-functions >= 0.1.6

上一页invoke 方法下一页delete_function 方法

最后更新于5年前

这有帮助吗?

创建的无服务器云函数运行时名称。如果该参数被忽略,默认运行时为 Python3。建议使用 枚举器成员。

创建的无服务器云函数类型。如果该参数被忽略,默认类型为 Event。建议使用 枚举器成员。

Waitable 类
FunctionCode
FunctionRuntime
FunctionType
FunctionConfigure