Giter VIP home page Giter VIP logo

tcfcli's Introduction

tcf cli


什么是 tcf

tcf 全称为 tencent cloud function,是腾讯云无服务器云函数 SCF(Serverless Cloud Function)产品的命令行工具。通过 tcf 命令行工具,您可以方便的实现函数打包、部署、本地调试,也可以方便的生成云函数的项目并基于 demo 项目进一步的开发。

tcf 通过一个函数模板配置文件,完成函数及相关周边资源的描述,并基于配置文件实现本地代码及配置部署到云端的过程。

目前 tcf 以开源形式发布,您可以在本项目中查看命令行源代码及更多帮助文档,并可以通过项目 issue 反馈问题。

功能特性

通过 tcf 命令行工具,你可以:

  • 快速初始化云函数项目
  • 在本地开发及测试你的云函数代码
  • 使用模拟的 COS、CMQ、Ckafka、API 网关等触发器事件来触发函数运行
  • 验证 TCSAM 模板配置文件
  • 打包、上传函数代码,创建函数及更新函数配置

运行环境

tcf 可以在 Windows、Linux、Mac 上运行。tcf 基于 Python 开发完成,因此在安装及运行前需要系统中安装有 Python 环境。更详细信息可见安装及配置

快速入门

安装 tcf

前置依赖

在安装 tcf 前,请确保系统中已经安装好了如下软件:

  • Python 2.7+ 或 Python 3.6+
  • pip

通过 pip 安装 tcf

通过使用如下命令完成 tcf 安装:

$ pip install tcf

通过执行如下命令及输出确保 tcf 安装已成功:

$ tcf --version
TCF CLI, version 0.1.0

配置 tcf

从腾讯云控制台获取到账号的 APPID,SecretId及 SecretKey 信息,并配置到 tcf 中,作为 tcf 调用云 API 时的认证信息。

例如获取到的账号 APPID 为 1253970223,SecretId 和 SecretKey 分别为 AKIxxxxxxxxxx 及 uxxlxxxxxxxx,期望在广州区使用云函数。则通过如下命令完成 tcf 的配置 :

$ tcf configure set --region ap-guangzhou --appid 1253970223 --secret-id AKIxxxxxxxxxx --secret-key uxxlxxxxxxxx

初始化模板项目

选择进入到合适的代码目录,例如 cd ~

通过执行如下命令,创建运行环境为 Python 2.7,名称为 testscf 的项目。

$ tcf init --runtime python2.7 --name testscf

此命令会在当前目录下创建 testscf 项目目录。

打包项目

执行 $ cd testscf 进入项目目录。

可以通过 ls 命令看到,当前项目目录下包括了 README 说明文档,hello_world 代码目录,template.yaml 配置文件。

通过执行如下打包命令:

$ tcf package --template-file template.yaml

tcf 会依据 template.yaml 文件内的描述,将 hello_world 代码目录内的代码生成部署程序包,并生成 deploy 配置文件。

此时再次通过 ls 命令,可以看到项目目录内多了 deploy.yaml 部署用配置文件,以及类似 32b29935-1ec1-11e9-be82-9801a7af1801.zip 的部署包。

部署云函数

通过执行如下命令,完成本地代码包及函数配置部署到云端:

$ tcf deploy --template-file deploy.yaml 

运行成功完成部署后,可以通过进入腾讯云云函数的控制台,检查函数是否已经成功部署。

详细使用指导

tcfcli's People

Contributors

alfredhuang211 avatar dorasang avatar nevenmoore avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.