部署无服务器之腾讯云篇

部署无服务器之腾讯云篇

安装

1.查询你的python版本是否符合要求
在cmd中输入以下命令回车:

python

2.安装pip

curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py 
sudo python get-pip.py //运行安装脚本

2.安装scf

pip install scf

jsonschema 3.0.1 has requirement six>=1.11.0, but you’ll have six 1.4.1 which is incompatible.
如果出现这种错误请升级下six

sudo pip install six --upgrade --ignore-installed six

4.查看scf是否安装成功

WARNING: The script scf is installed in '/Users/jiatui/Library/Python/2.7/bin' which is not on PATH.

WARNING: The script scf is installed in ‘/Users/jiatui/Library/Python/2.7/bin’ which is not on PATH…
如果出现这种警告请配置下环境变量

export PATH=/Users/jiatui/Library/Python/2.7/bin:$PATH

5.配置 scf cli
https://console.cloud.tencent.com/cam/capi 查询你的APPID,SecretId,SecretKey,执行以下命令

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

新建项目

1.执行以下命令,新建一个函数

$ scf init --runtime nodejs8.9 --name testscf

2.进入刚刚新建的函数目录,执行打包yaml配置的命令:

$ scf package --template-file template.yaml

3.部署函数到云

$ scf package --template-file template.yaml

执行

本地调用:

scf native generate-event cos post | scf native invoke --template template.yaml

使用模拟事件给函数传参

//生成如下的文件,格式为JSON
{
"key1":"value1",
"key2":"value2"
}
//执行:
scf native invoke --template template.yaml --event event.json

API调用

点击此处查看如何配置API
按照上面的8个步骤配置好即可。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值