{"componentChunkName":"component---src-templates-blog-detail-tsx","path":"/blog/2019-09-18-serverless-scf-cli","result":{"data":{"currentBlog":{"id":"56b79d5f-8104-59ba-b8c8-c6d1b5518ded","frontmatter":{"thumbnail":"https://img.serverlesscloud.cn/qianyi/images/YHl6UWa9s63gXEueAufpULb25PiblSh96vULKgk2padpta42yxwdVnqEQPYNn5WVnM3D7FibEvUqWr7LyF5tsCNA.png","authors":["Anycodes"],"categories":["news"],"date":"2019-09-18T00:00:00.000Z","title":"Serverless 实践：全新命令行工具帮你快速部署云函数","description":"SCF CLI 是腾讯云云函数（Serverless Cloud Function，SCF）产品的命令行工具，想必很多小伙伴已经有所了解，或者试用过了。作为一个可以提高开发者效率的工具，腾讯云 Serverless 团队一直在对 SCF CLI 进行优化工作，本文将给大家介绍新版 SCF CLI 增加的有趣功能！","authorslink":["https://github.com/jiangliu5267"],"translators":null,"translatorslink":null,"tags":["SCF CLI","云函数"],"keywords":"Serverless, SCF CLI, Serverless云函数","outdated":true},"wordCount":{"words":358,"sentences":90,"paragraphs":90},"fileAbsolutePath":"/opt/build/repo/content/blog/2019-09-18-serverless-scf-cli.md","fields":{"slug":"/blog/2019-09-18-serverless-scf-cli/","keywords":["python","serverless","spa","云函数","Serverless","serverlesscloud","网关","cos"]},"html":"<p>SCF CLI 是腾讯云云函数（Serverless Cloud Function，SCF）产品的命令行工具，想必很多小伙伴已经有所了解，或者试用过了。作为一个可以提高开发者效率的工具，腾讯云 Serverless 团队一直在对 SCF CLI 进行优化工作，<strong>本文将给大家介绍新版 SCF CLI 增加的有趣功能！</strong></p>\n<h2 id=\"一、deploy-功能优化\"><a href=\"#%E4%B8%80%E3%80%81deploy-%E5%8A%9F%E8%83%BD%E4%BC%98%E5%8C%96\" aria-label=\"一、deploy 功能优化 permalink\" class=\"anchor\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a><strong>一、Deploy 功能优化</strong></h2>\n<h3 id=\"1：部署可以选择默认-cos\"><a href=\"#1%EF%BC%9A%E9%83%A8%E7%BD%B2%E5%8F%AF%E4%BB%A5%E9%80%89%E6%8B%A9%E9%BB%98%E8%AE%A4-cos\" aria-label=\"1：部署可以选择默认 cos permalink\" class=\"anchor\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a><strong>1：部署可以选择默认 COS</strong></h3>\n<p>只需要在设置的时候，设置 using-cos 就可以，当然也可以 scf configure set --using-cos y 来直接设置：</p>\n<p><img src=\"https://img.serverlesscloud.cn/qianyi/images/YHl6UWa9s63gXEueAufpULb25PiblSh96oRpibnvKVVKO17wt2KnpwKBHR2JgS6TQNicX3BYFWJl511iby8Tq1pnkw.png\" alt=\"Serverless\"></p>\n<p>选择之后，可以在接下来的部署中，默认上传代码到你的 cos，提高部署速度：</p>\n<p><img src=\"https://img.serverlesscloud.cn/qianyi/images/YHl6UWa9s63gXEueAufpULb25PiblSh96XVz8j9yonfBjrJ780SrJ4BLiaRNwAV2xVmzsVdMDd7aSfxczdFYzYfg.jpg\" alt=\"Serverless\"></p>\n<p>即使设置了 cos，在某次 Deploy 时，不想使用 cos，也可以选择不通过 cos 部署，增加 --without-cos:</p>\n<p><img src=\"https://img.serverlesscloud.cn/qianyi/images/YHl6UWa9s63gXEueAufpULb25PiblSh96JDnyY0T5CmwYWNnic1smkZJQN2DJShnzv5wHspXPXv8icmQTTaItRDtA.png\" alt=\"Serverless\"></p>\n<p>想自定义 COS 也可以：--cos-bucket：</p>\n<p><img src=\"https://img.serverlesscloud.cn/qianyi/images/YHl6UWa9s63gXEueAufpULb25PiblSh96sTACYzuGZXFN5niaEQFc0RzUyZQnxJtc7sQyfbDt9qraIscGvoLxvXg.png\" alt=\"Serverless\"></p>\n<p>（由于没有这个 cos，所以上传失败）</p>\n<p>在日常使用过程中，可能会存在部署同样一段代码的情况。</p>\n<p>比如，我部署了 A 代码，又部署了 B 代码。之后，我想重新部署 A 代码，按照传统方法是可以再次上传 A 代码，但如果 Package 比较大，就比较难受了。而新版本的 CLI 经过测试，130M 的 Package 首次部署使用 25s，第二次部署同样的文件，只需要 2s。</p>\n<p><strong>附：COS 的相关计费链接</strong></p>\n<ul>\n<li>免费额度：</li>\n</ul>\n<p><a href=\"https://cloud.tencent.com/document/product/436/6240\">https://cloud.tencent.com/document/product/436/6240</a></p>\n<ul>\n<li>计费概述：</li>\n</ul>\n<p><a href=\"https://cloud.tencent.com/document/product/436/16871\">https://cloud.tencent.com/document/product/436/16871</a></p>\n<ul>\n<li>计费方法：</li>\n</ul>\n<p><a href=\"https://cloud.tencent.com/document/product/436/36522\">https://cloud.tencent.com/document/product/436/36522</a></p>\n<ul>\n<li>产品定价</li>\n</ul>\n<p><a href=\"https://cloud.tencent.com/document/product/436/6239\">https://cloud.tencent.com/document/product/436/6239</a></p>\n<h3 id=\"2：部署历史版本\"><a href=\"#2%EF%BC%9A%E9%83%A8%E7%BD%B2%E5%8E%86%E5%8F%B2%E7%89%88%E6%9C%AC\" aria-label=\"2：部署历史版本 permalink\" class=\"anchor\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a><strong>2：部署历史版本</strong></h3>\n<p>代码部署过程中，如果出现问题，需要恢复历史版本。新版本的 SCF CLI 支持部署历史版本，在大家使用了 using-cos 之后，可以通过 deploy 的参数 --history 来部署历史版本：</p>\n<p><img src=\"https://img.serverlesscloud.cn/qianyi/images/YHl6UWa9s63gXEueAufpULb25PiblSh96iauREHKWb1SQzGyMaVl1OQXAODxz4ia9KsZmrWodQC3NQovBVNeGoK7w.png\" alt=\"Serverless\"></p>\n<p>选择一个历史版本，就可以直接实现文档回滚：</p>\n<p><img src=\"https://img.serverlesscloud.cn/qianyi/images/YHl6UWa9s63gXEueAufpULb25PiblSh96Uk1xQGS42XtJO6hq2c4nZkp583icT68uP88xa4vwomPZMPgtLRK5Tibw.png\" alt=\"Serverless\"></p>\n<h3 id=\"3：打包功能优化\"><a href=\"#3%EF%BC%9A%E6%89%93%E5%8C%85%E5%8A%9F%E8%83%BD%E4%BC%98%E5%8C%96\" aria-label=\"3：打包功能优化 permalink\" class=\"anchor\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a><strong>3：打包功能优化</strong></h3>\n<p>旧版 SCF CLI 会把用户目录下的全部文件打包，新版 SCFCLI 在这方面也做了重点优化，可以直接指定 ZIP，指定某文件，并且打包的时候会默认去除 .git 等隐藏目录，并且在 deploy 之后，默认删除之前的打包信息。</p>\n<p>Yaml 文件可以这样：</p>\n<p><img src=\"https://img.serverlesscloud.cn/qianyi/images/YHl6UWa9s63gXEueAufpULb25PiblSh96uv0Zkaib7sibX0S8cvfwDiaxuufSyCQTLK8ghx5pNicJG6qoicnKnEPJuwA.jpg\" alt=\"Serverless\"></p>\n<h2 id=\"二、新增-delete-功能\"><a href=\"#%E4%BA%8C%E3%80%81%E6%96%B0%E5%A2%9E-delete-%E5%8A%9F%E8%83%BD\" aria-label=\"二、新增 delete 功能 permalink\" class=\"anchor\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a><strong>二、新增 Delete 功能</strong></h2>\n<p>旧版 SCF CLI 不支持 Delete 功能，在新版中，大家可以轻松自在地使用：</p>\n<p><img src=\"https://img.serverlesscloud.cn/qianyi/images/YHl6UWa9s63gXEueAufpULb25PiblSh96CSO9LdzKgvwYMzyEehUx0Qfwq7BmLibHALIXs58XZwcnuKs9OZptFjg.png\" alt=\"Serverless\"></p>\n<p>只需要输入 scf delete --help 就可以看到使用方法和参数描述哦！</p>\n<h2 id=\"三、新增-list-功能\"><a href=\"#%E4%B8%89%E3%80%81%E6%96%B0%E5%A2%9E-list-%E5%8A%9F%E8%83%BD\" aria-label=\"三、新增 list 功能 permalink\" class=\"anchor\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a><strong>三、新增 List 功能</strong></h2>\n<p>以往，如果想查看云函数的内容，或者我部署了哪些函数，是需要去控制台挨个区域、挨个 namespace 查看。现在无需繁琐，通过 List 指令即可实现：</p>\n<p><img src=\"https://img.serverlesscloud.cn/qianyi/images/YHl6UWa9s63gXEueAufpULb25PiblSh96jRoZLlMoYjKViaYjS7BnygORWyP09aEKqEMaIMyHYQMWwd6O4k5YXibw.png\" alt=\"Serverless\"></p>\n<p>同样可以通过 SCF 的 --help 来查看所有用法：scf list --help</p>\n<h2 id=\"四、帮助文档的优化\"><a href=\"#%E5%9B%9B%E3%80%81%E5%B8%AE%E5%8A%A9%E6%96%87%E6%A1%A3%E7%9A%84%E4%BC%98%E5%8C%96\" aria-label=\"四、帮助文档的优化 permalink\" class=\"anchor\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a><strong>四、帮助文档的优化</strong></h2>\n<p>上面的很多说明，都是让大家使用 --help 来查看帮助，那么在新版中，--help 有哪些大的优化呢 —— 全局的帮助文档优化，在任何指令下都可以 --help 查看帮助：</p>\n<p><img src=\"https://img.serverlesscloud.cn/qianyi/images/YHl6UWa9s63gXEueAufpULb25PiblSh966w7Vpzewq0pJ74TdXflJW22FTPhx1TsOovCkG7aP9J1AjPdY0gUW4w.png\" alt=\"Serverless\"></p>\n<p>在指令页面可以进行例子查看：</p>\n<p><img src=\"https://img.serverlesscloud.cn/qianyi/images/YHl6UWa9s63gXEueAufpULb25PiblSh96pPkmXydaDTSgNBfpibysHrGl3icj5Xe6qicoX7LhafibgracKdVicwJtf3Q.jpg\" alt=\"Serverless\"></p>\n<p>每个主要的指令，都会有指令的描述以及使用例子，同时规范了参数描述。</p>\n<h2 id=\"五、api-网关部分\"><a href=\"#%E4%BA%94%E3%80%81api-%E7%BD%91%E5%85%B3%E9%83%A8%E5%88%86\" aria-label=\"五、api 网关部分 permalink\" class=\"anchor\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a><strong>五、API 网关部分</strong></h2>\n<p>现有 SCF CLI 在使用 API 网关的时候每次都需要新建，如果不想新建，就需要注释配置文件或者使用 --skip-event，这让很多用户头疼。新版 SCF CLI 在 API 网关部分增加了 ServiceId 字段：</p>\n<p><img src=\"https://img.serverlesscloud.cn/qianyi/images/YHl6UWa9s63gXEueAufpULb25PiblSh96Ku9Afpqr8CnT4C7FqicnEXRSMBf0wUfDGmK93YhiaJNibWtqJ76H2FtnA.png\" alt=\"Serverless\"></p>\n<p>有了这个字段，大家使用的时候可以直接选择绑定已有网关。新建网关之后，系统会进行提示：</p>\n<p><img src=\"https://img.serverlesscloud.cn/qianyi/images/YHl6UWa9s63gXEueAufpULb25PiblSh96YDBYWaIF9qlIvicRELqUy61XatG8ks1Kanc7UQhrhTZRL8to5WibpvJw.png\" alt=\"Serverless\"></p>\n<p>把对应的网关 ID 填写上即可避免下次创建。这样一个简单的字段增加，给小伙伴们带来了两个优秀的体验：</p>\n<p>    1：可以绑定现有的 API 网关，不需要新建</p>\n<p>    2：可以保证现有网关形态，不会每次新建</p>\n<h2 id=\"六、输出信息优化\"><a href=\"#%E5%85%AD%E3%80%81%E8%BE%93%E5%87%BA%E4%BF%A1%E6%81%AF%E4%BC%98%E5%8C%96\" aria-label=\"六、输出信息优化 permalink\" class=\"anchor\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a><strong>六、输出信息优化</strong></h2>\n<p>有心的小伙伴应该注意到了，本次更新，UI 变化非常大。在我们使用云函数的时候，不同表达会用不同的颜色显示：</p>\n<p><img src=\"https://img.serverlesscloud.cn/qianyi/images/YHl6UWa9s63gXEueAufpULb25PiblSh96TeaLxkmnfbNTt5toAnfpy0RN4GKEUcac5PEQTf74AhfmJvcKib14feA.jpg\" alt=\"Serverless\"></p>\n<p>同时，Deploy 之后，大家不用打开网页看云函数信息，而是通过控制台直接看到：</p>\n<p><img src=\"https://img.serverlesscloud.cn/qianyi/images/YHl6UWa9s63gXEueAufpULb25PiblSh96hXeEeMk0tLHunctaROXEuGibLcicOaVwZJIJ3GghZiaNjQg6Hm7KQ0ictw.png\" alt=\"Serverless\"></p>\n<h1 id=\"实验\"><a href=\"#%E5%AE%9E%E9%AA%8C\" aria-label=\"实验 permalink\" class=\"anchor\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a><strong>实验</strong></h1>\n<h2 id=\"hello-world\"><a href=\"#hello-world\" aria-label=\"hello world permalink\" class=\"anchor\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a><strong>Hello world</strong></h2>\n<p>以 Hello World 为例，通过帮助查看 init 创建指令：</p>\n<p>scf init --help</p>\n<p><img src=\"https://img.serverlesscloud.cn/qianyi/images/YHl6UWa9s63gXEueAufpULb25PiblSh96AarTsFfKgyxUMqYrAibSXYn4aU69nujprzw2wGWficvNsLYTROhM8kTw.png\" alt=\"Serverless\"></p>\n<p>根据例子创建 Python 语言的 hello world：</p>\n<p>scf init --runtime python3.6</p>\n<p><img src=\"https://img.serverlesscloud.cn/qianyi/images/YHl6UWa9s63gXEueAufpULb25PiblSh96DCRnl3ObQYzibibG8dDLs6mH3M7tEdcbBcibCOLQN4D50q0yH8RU5RdVQ.png\" alt=\"Serverless\"></p>\n<p>按照提示：cd hello_world 进行项目编辑</p>\n<p><img src=\"https://img.serverlesscloud.cn/qianyi/images/YHl6UWa9s63gXEueAufpULb25PiblSh96X2Dib8q8brTyrcCxAS1jk8UjOL4ia07QdCtTRfNDWicaoA0o6gn6ib9fuA.png\" alt=\"Serverless\"></p>\n<p>修改代码和配置网关：</p>\n<p><img src=\"https://img.serverlesscloud.cn/qianyi/images/YHl6UWa9s63gXEueAufpULb25PiblSh96NjGicicnNK4sfIoH7Nnl7owr8ZMntGPTHG18xkID6qOvA34TQKtibPtHA.png\" alt=\"Serverless\"></p>\n<p>网关这里要用，我不想新建网关，而是想要用已经有的一个 API 网关：</p>\n<p><img src=\"https://img.serverlesscloud.cn/qianyi/images/YHl6UWa9s63gXEueAufpULb25PiblSh96c3R13zffl2gI58xFsgUGavWv32XFicvWLB3Fdg2rR3SEzltHZ7cFEgg.jpg\" alt=\"Serverless\"></p>\n<p>填写好 serviceeId：</p>\n<p><img src=\"https://img.serverlesscloud.cn/qianyi/images/YHl6UWa9s63gXEueAufpULb25PiblSh96EAaN7BsGZ0nsrr4guPug8CZb9WkccFKmRGyKva1bVHpLJJNoppKDMQ.png\" alt=\"Serverless\"></p>\n<p>然后保存退出，Deploy:</p>\n<p><img src=\"https://img.serverlesscloud.cn/qianyi/images/YHl6UWa9s63gXEueAufpULb25PiblSh96euukc42jyhqAdQYW8rZYwRRKbCkrMW4iaznXgKF5pXQyzoY28a8GIaA.jpg\" alt=\"Serverless\"></p>\n<p>部署之后，输出函数信息：</p>\n<p><img src=\"https://img.serverlesscloud.cn/qianyi/images/YHl6UWa9s63gXEueAufpULb25PiblSh96niaVOpCbUB8Md9Bn3Mkysic7evFQ0Bz0YnHfPd8xxjBoYibX2CXcE8IbQ.png\" alt=\"Serverless\"></p>\n<p>打开 API 网关中 subDomain：</p>\n<p><img src=\"https://img.serverlesscloud.cn/qianyi/images/YHl6UWa9s63gXEueAufpULb25PiblSh969CYQNv2UtzebCwlwoXxLfqbPRl6WRum6tNejOZXybKkicCUkRQIlNWA.png\" alt=\"Serverless\"></p>\n<p>部署成功！</p>\n<h2 id=\"查看函数列表\"><a href=\"#%E6%9F%A5%E7%9C%8B%E5%87%BD%E6%95%B0%E5%88%97%E8%A1%A8\" aria-label=\"查看函数列表 permalink\" class=\"anchor\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a><strong>查看函数列表</strong></h2>\n<p>只需要输入 scf list</p>\n<p><img src=\"https://img.serverlesscloud.cn/qianyi/images/YHl6UWa9s63gXEueAufpULb25PiblSh96vULKgk2padpta42yxwdVnqEQPYNn5WVnM3D7FibEvUqWr7LyF5tsCNA.png\" alt=\"Serverless\"></p>\n<h2 id=\"删除函数\"><a href=\"#%E5%88%A0%E9%99%A4%E5%87%BD%E6%95%B0\" aria-label=\"删除函数 permalink\" class=\"anchor\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a><strong>删除函数</strong></h2>\n<p>只需要输入需要删除的函数相关信息：</p>\n<p>scf delete --name hello_world --region ap-shanghai --namespace default</p>\n<p><img src=\"https://img.serverlesscloud.cn/qianyi/images/YHl6UWa9s63gXEueAufpULb25PiblSh964n04flqku2B3jEvAxehwhXnTb2w4nmpvWYtnCqgfE3wYFFDHWSSS7g.png\" alt=\"Serverless\"></p>\n<p>本文关于命令行工具的介绍和实践就暂告一段落。更多功能，等待各位小伙伴自行挖掘哦！</p>","tableOfContents":"<ul>\n<li>\n<ul>\n<li>\n<p><a href=\"/blog/2019-09-18-serverless-scf-cli/#%E4%B8%80%E3%80%81deploy-%E5%8A%9F%E8%83%BD%E4%BC%98%E5%8C%96\">一、Deploy 功能优化</a></p>\n<ul>\n<li><a href=\"/blog/2019-09-18-serverless-scf-cli/#1%EF%BC%9A%E9%83%A8%E7%BD%B2%E5%8F%AF%E4%BB%A5%E9%80%89%E6%8B%A9%E9%BB%98%E8%AE%A4-cos\">1：部署可以选择默认 COS</a></li>\n<li><a href=\"/blog/2019-09-18-serverless-scf-cli/#2%EF%BC%9A%E9%83%A8%E7%BD%B2%E5%8E%86%E5%8F%B2%E7%89%88%E6%9C%AC\">2：部署历史版本</a></li>\n<li><a href=\"/blog/2019-09-18-serverless-scf-cli/#3%EF%BC%9A%E6%89%93%E5%8C%85%E5%8A%9F%E8%83%BD%E4%BC%98%E5%8C%96\">3：打包功能优化</a></li>\n</ul>\n</li>\n<li><a href=\"/blog/2019-09-18-serverless-scf-cli/#%E4%BA%8C%E3%80%81%E6%96%B0%E5%A2%9E-delete-%E5%8A%9F%E8%83%BD\">二、新增 Delete 功能</a></li>\n<li><a href=\"/blog/2019-09-18-serverless-scf-cli/#%E4%B8%89%E3%80%81%E6%96%B0%E5%A2%9E-list-%E5%8A%9F%E8%83%BD\">三、新增 List 功能</a></li>\n<li><a href=\"/blog/2019-09-18-serverless-scf-cli/#%E5%9B%9B%E3%80%81%E5%B8%AE%E5%8A%A9%E6%96%87%E6%A1%A3%E7%9A%84%E4%BC%98%E5%8C%96\">四、帮助文档的优化</a></li>\n<li><a href=\"/blog/2019-09-18-serverless-scf-cli/#%E4%BA%94%E3%80%81api-%E7%BD%91%E5%85%B3%E9%83%A8%E5%88%86\">五、API 网关部分</a></li>\n<li><a href=\"/blog/2019-09-18-serverless-scf-cli/#%E5%85%AD%E3%80%81%E8%BE%93%E5%87%BA%E4%BF%A1%E6%81%AF%E4%BC%98%E5%8C%96\">六、输出信息优化</a></li>\n</ul>\n</li>\n<li>\n<p><a href=\"/blog/2019-09-18-serverless-scf-cli/#%E5%AE%9E%E9%AA%8C\">实验</a></p>\n<ul>\n<li><a href=\"/blog/2019-09-18-serverless-scf-cli/#hello-world\">Hello world</a></li>\n<li><a href=\"/blog/2019-09-18-serverless-scf-cli/#%E6%9F%A5%E7%9C%8B%E5%87%BD%E6%95%B0%E5%88%97%E8%A1%A8\">查看函数列表</a></li>\n<li><a href=\"/blog/2019-09-18-serverless-scf-cli/#%E5%88%A0%E9%99%A4%E5%87%BD%E6%95%B0\">删除函数</a></li>\n</ul>\n</li>\n</ul>"},"previousBlog":{"id":"a391eb20-aeac-51c4-9330-3a3d18cb674f","frontmatter":{"thumbnail":"https://img.serverlesscloud.cn/qianyi/images/l7x0FXB2eW7ibWsCibiaAIeGFC7dLbCTXG7yYebTv238UXXPJCCravianRBePr9qeGGAEB0HRsBVLh5Nvggtq7P08A.jpg","authors":["周俊鹏"],"categories":["news"],"date":"2019-09-30T00:00:00.000Z","title":"Serverless —— 前端 3.0 时代","description":"《信息简史》中说“进化本身是生物体与环境之间持续不断的信息交换的具体表现”，前端技术的进化也是如此。浩瀚的前端宇宙中，又出现过哪些耀眼的星辰呢？指引前端未来的“北极星”又在何方？腾讯云高级工程师与你畅谈前端的变革史与新时代的希冀。","authorslink":["https://github.com/jiangliu5267"],"translators":null,"translatorslink":null,"tags":["云开发","云函数"],"keywords":"Serverless, Serverless前端开发, Serverless云函数","outdated":null},"wordCount":{"words":321,"sentences":62,"paragraphs":62},"fileAbsolutePath":"/opt/build/repo/content/blog/2019-09-30-serverless-arch-function.md","fields":{"slug":"/blog/2019-09-30-serverless-arch-function/","keywords":["serverless","云函数","前端","Serverless","Node","React"]}},"nextBlog":{"id":"ae4fd2f8-515c-5aec-b584-38427ef33f7e","frontmatter":{"thumbnail":"https://img.serverlesscloud.cn/2020114/1578989800047-part-00492-780.jpg","authors":["Anycodes"],"categories":["guides-and-tutorials","user-stories"],"date":"2019-09-16T00:00:00.000Z","title":"突破传统 OJ 瓶颈，「判题姬」接入云函数","description":"通过 Serverless 实现在线编程","authorslink":["https://www.zhihu.com/people/liuyu-43-97"],"translators":null,"translatorslink":null,"tags":["在线编程","云函数"],"keywords":"Serverless 在线编程,Serverless OJ","outdated":null},"wordCount":{"words":169,"sentences":30,"paragraphs":30},"fileAbsolutePath":"/opt/build/repo/content/blog/2019-09-16-online-Judge.md","fields":{"slug":"/blog/2019-09-16-online-Judge/","keywords":["python","serverless","云函数","代码","函数","serverless"]}},"recommendBlogs":{"edges":[{"node":{"id":"73576d26-e0ce-5f26-9330-64b4f3889157","frontmatter":{"thumbnail":"https://main.qcloudimg.com/raw/3cb7b20955d78ced738e0279bb3f6f41.jpg","authors":["AndreaPasswater"],"categories":["news","engineering-culture"],"date":"2018-03-09T00:00:00.000Z","title":"Serverless 数据解读：2018 报告","description":"Serverless Framework 使用统计数据：事件源、服务结构、运行时长等等。","authorslink":["https://serverless.com/author/andreapasswater/"],"translators":["Aceyclee"],"translatorslink":["https://www.zhihu.com/people/Aceyclee"],"tags":["事件源","服务结构"],"keywords":"Serverless 统计数据,Serverless 事件源,Serverless 服务结构","outdated":null},"wordCount":{"words":212,"sentences":45,"paragraphs":45},"fileAbsolutePath":"/opt/build/repo/content/blog/2018-03-09-serverless-by-the-numbers-2018-data-report.md","fields":{"slug":"/blog/2018-03-09-serverless-by-the-numbers-2018-data-report/","keywords":["go","serverless","无服务器","云函数","服务","使用率","Go","部署"]}}},{"node":{"id":"84876745-cbfb-5c1d-9f6c-7c74338d5d28","frontmatter":{"thumbnail":"https://s3-us-west-2.amazonaws.com/assets.site.serverless.com/images/champions/champions_banner.jpg","authors":["RupakGanguly"],"categories":["news","engineering-culture"],"date":"2018-04-10T00:00:00.000Z","title":"2018 年首批无服务器社区冠军介绍","description":"无服务器社区冠军是无服务器社区的领导者。快来认识一下我们 2018 年度的社区英雄吧！","authorslink":null,"translators":null,"translatorslink":null,"tags":null,"keywords":null,"outdated":null},"wordCount":{"words":194,"sentences":32,"paragraphs":32},"fileAbsolutePath":"/opt/build/repo/content/blog/2018-04-10-announcing-new-2018-serverless-champions.md","fields":{"slug":"/blog/2018-04-10-announcing-new-2018-serverless-champions/","keywords":["serverless","webpack","无服务器","无服务器架构","服务器","serverless","champions","架构","blog","github","框架"]}}},{"node":{"id":"1e1a90fc-3b65-540c-b726-755999e7912a","frontmatter":{"thumbnail":"https://main.qcloudimg.com/raw/8a0db1c9fd8b51c15d0b006291d52bf5.jpg","authors":["AndreaPasswater"],"categories":["news","engineering-culture"],"date":"2018-07-19T00:00:00.000Z","title":"2018 年社区调查：Serverless 使用率大幅增长","description":"我们曾在开发社区进行问卷调查，询问 Serverless 的使用情况。它的使用率增长连我们自己都惊讶不已，下面来看看数据。","authorslink":["https://serverless.com/author/andreapasswater/"],"translators":["Aceyclee"],"translatorslink":["https://www.zhihu.com/people/Aceyclee"],"tags":["Component","Serverless"],"keywords":"Serverless 社区调查,Serverless 使用情况,Serverless 数据","outdated":null},"wordCount":{"words":267,"sentences":50,"paragraphs":49},"fileAbsolutePath":"/opt/build/repo/content/blog/2018-07-19-2018-serverless-community-survey-huge-growth-usage.md","fields":{"slug":"/blog/2018-07-19-2018-serverless-community-survey-huge-growth-usage/","keywords":["go","serverless","无服务器","Serverless","serverless"]}}},{"node":{"id":"8311b008-2b15-5225-8adc-9b75e484177b","frontmatter":{"thumbnail":"https://img.serverlesscloud.cn/2020414/1586880819419-%E5%B0%81%E9%9D%A2%E5%9B%BE%20%286%29.png","authors":["serverless 社区"],"categories":["news"],"date":"2019-04-08T00:00:00.000Z","title":"邀您参加 | K8S&云原生技术开放日-北京站","description":"K8S&云原生技术开放日，将围绕K8S、Serverless等云原生相关技术，从最佳落地实践、不同场景技术改造、应用优化，到开源领域深度技术研究，和技术爱好者们一起探讨。","authorslink":["https://zhuanlan.zhihu.com/ServerlessGo"],"translators":null,"translatorslink":null,"tags":["云原生","Serverless"],"keywords":"serverless 入门,serverless 框架,腾讯云 serverless","outdated":null},"wordCount":{"words":36,"sentences":9,"paragraphs":9},"fileAbsolutePath":"/opt/build/repo/content/blog/2019-04-08-k8s.md","fields":{"slug":"/blog/2019-04-08-k8s/","keywords":["serverless","云原生","serverless","Serverless","技术","原生","serverlesscloud","github"]}}},{"node":{"id":"25f709db-cde0-59d7-81f4-944c46a6dd8a","frontmatter":{"thumbnail":"https://img.serverlesscloud.cn/2020414/1586880571672-%E5%B0%81%E9%9D%A2%E5%9B%BE%20%285%29.png","authors":["serverless 社区"],"categories":["news"],"date":"2019-04-04T00:00:00.000Z","title":"Serverless 技术风暴来袭，开发者该如何应对？","description":"Hello Serverless技术沙龙北京站，将围绕Serverless的应用场景，客户案例，FaaS+BaaS架构的实现方案等，针对未来的无服务形态进行交流和讨论，释放技术想象！","authorslink":["https://zhuanlan.zhihu.com/ServerlessGo"],"translators":null,"translatorslink":null,"tags":["应用场景","Serverless"],"keywords":"serverless 入门,serverless 框架,腾讯云 serverless","outdated":null},"wordCount":{"words":37,"sentences":8,"paragraphs":8},"fileAbsolutePath":"/opt/build/repo/content/blog/2019-04-04-technology-storm.md","fields":{"slug":"/blog/2019-04-04-technology-storm/","keywords":["serverless","Serverless","serverless","serverlesscloud","github","技术","架构","围绕"]}}},{"node":{"id":"4bc4d946-6187-5c3d-91c6-d98c4c4c1314","frontmatter":{"thumbnail":"https://img.serverlesscloud.cn/2020414/1586880172144-%E5%B0%81%E9%9D%A2%E5%9B%BE%20%284%29.png","authors":["serverless 社区"],"categories":["news"],"date":"2019-06-11T00:00:00.000Z","title":"一图读懂无服务器云函数","description":"本图将重要信息进行梳理和提炼，帮助读者更好的理解无服务器云函数的理念和作用","authorslink":["https://zhuanlan.zhihu.com/ServerlessGo"],"translators":null,"translatorslink":null,"tags":["云函数","Serverless"],"keywords":"serverless 入门,serverless 框架,腾讯云 serverless","outdated":null},"wordCount":{"words":31,"sentences":6,"paragraphs":6},"fileAbsolutePath":"/opt/build/repo/content/blog/2019-06-11-one-picture-serverless-cloud-function.md","fields":{"slug":"/blog/2019-06-11-one-picture-serverless-cloud-function/","keywords":["serverless","无服务器","无服务器云函数","云函数","serverless","serverlesscloud","Serverless","github","开发者","函数"]}}},{"node":{"id":"1cd76f95-14a9-5fd5-926b-456af189b7ed","frontmatter":{"thumbnail":"https://img.serverlesscloud.cn/2020326/1585217744291-%E6%91%84%E5%9B%BE%E7%BD%91_400730082_wx.jpg","authors":["朱峰 Ben"],"categories":["news"],"date":"2019-10-14T00:00:00.000Z","title":"由浅入深说 Serverless 之云函数的生命周期","description":"希望通过文章分享帮助大家更深入的了解 Serverless 背后的机制并掌握相关的最佳实践。","authorslink":["https://github.com/jiangliu5267"],"translators":null,"translatorslink":null,"tags":["云函数"],"keywords":"Serverless, Serverless前端开发, Serverless云函数","outdated":null},"wordCount":{"words":74,"sentences":29,"paragraphs":29},"fileAbsolutePath":"/opt/build/repo/content/blog/2019-10-14-serverless-cloud-function.md","fields":{"slug":"/blog/2019-10-14-serverless-cloud-function/","keywords":["faas","java","云函数","函数","触发","实例","事件","数据库","启动","连接","sql","代码"]}}},{"node":{"id":"4f16f8bc-1a35-5394-9029-f7abc2ad6137","frontmatter":{"thumbnail":"https://img.serverlesscloud.cn/qianyi/images/YHl6UWa9s629ucl0iaVcic8rL06uEBM5go4LSXiaHnibDJSBjLGAhGlWz3QZ1RZzd3NeCibjJxOyUApDO7TaPYcwxsw.jpg","authors":["Serverless 中文网"],"categories":["news"],"date":"2019-10-26T00:00:00.000Z","title":"Hello Serverless 实战沙龙回顾","description":"2019 年 10 月 26 日，Hello Serverless 沙龙活动在广州市海珠区腾讯众创空间成功举办，一起看看我们都为大家准备了哪些精彩的演讲吧！","authorslink":["https://github.com/jiangliu5267"],"translators":null,"translatorslink":null,"tags":["Meetup"],"keywords":"Serverless, Serverless技术沙龙,Hello Serverless","outdated":null},"wordCount":{"words":64,"sentences":13,"paragraphs":13},"fileAbsolutePath":"/opt/build/repo/content/blog/2019-10-26-hello-serverless-meetup.md","fields":{"slug":"/blog/2019-10-26-hello-serverless-meetup/","keywords":["go","serverless","云函数","云原生","Serverless","存储","腾讯","serverlesscloud"]}}}],"totalCount":46}},"pageContext":{"isCreatedByStatefulCreatePages":false,"blogId":"56b79d5f-8104-59ba-b8c8-c6d1b5518ded","previousBlogId":"a391eb20-aeac-51c4-9330-3a3d18cb674f","nextBlogId":"ae4fd2f8-515c-5aec-b584-38427ef33f7e","categories":["news"]}}}