Git Product home page Git Product logo

alibaba / serverless-vscode Goto Github PK

View Code? Open in Web Editor NEW
291.0 13.0 37.0 49.74 MB

Aliyun Function Compute extension. Lets you develop your serverless application of Aliyun within VSCode.

License: GNU General Public License v2.0

JavaScript 0.43% TypeScript 87.47% PHP 0.20% Python 0.17% HTML 9.51% CSS 1.52% Shell 0.04% Java 0.35% C# 0.30%
serverless serverless-plugin function-compute fun funcraft aliyun aliyun-fc aliyun-fun alibaba alibabacloud

serverless-vscode's Introduction

Aliyun Serverless VSCode Extension

Version Downloads Installs

Aliyun Serverless VSCode Extension is a graphic development, debugging, and resource-managing tool for Function Compute based on Visual Studio Code (VS Code). This topic describes how to use the extension to create a function and other common features.

Provided by Function Compute, Aliyun Serverless VSCode Extension is a VS Code-based development, debugging, and deployment tool that integrates the features of the Function Compute command line tool Fun and Function Compute SDK. You can use this extension to:

  • Initialize projects and create functions locally.
  • Run, debug, and deploy local functions of your services to Function Compute.
  • Obtain functions and their specifications and invoke functions from Function Compute.
  • Obtain syntax prompts for template files. The prompts include automatic completion, schema validation, and hovering prompts.

Prerequisites

If you want to use all features provided by Aliyun Serverless VSCode Extension, ensure that the following components have been configured locally:

  • VS Code: You can download this component from the Visual Studio Code official website.
  • Docker: For information about how to download and configure this component, visit aliyun/fun.

Install the extension

  • Start VS Code and go to the extension marketplace.
  • Search for Aliyun Serverless, view the details, and install the extension.
  • Restart VS Code. The extension icon is displayed in the left-side activity bar.

Quick start

Bind an Alibaba Cloud account.

In the left-side activity bar, click the Aliyun Serverless VSCode Extension icon, and click Bind New Account.

Enter the account ID, AccessKey ID, AccessKey secret, and the local name of the account in sequence.

After the account is bound, you can view the services and functions of the account.

To view services and functions located in different regions, you can click the More icon in the upper-right corner of the Remote Resources panel. In the drop-down list, select FC: Switch Region.

Create a function

Open an empty directory file in VS Code. Click the function creation icon of the LOCAL RESOURCES panel to initialize a Function Compute project locally.

Specify the service name, function name, runtime, and function type. After all parameters have been specified, the extension will automatically create the function. The new service and function will be displayed in the LOCAL RESOURCES panel.

You can also click the function creation icon to the right of a service in the LOCAL RESOURCES panel to create functions for the service. You must specify the function name, runtime, and function type.

Deploy services and functions

Click the deployment icon of the LOCAL RESOURCES panel to deploy local services and functions to Function Compute.

After the deployment is complete, you can click the refresh icon of the REMOTE RESOURCES panel to view the deployed services and functions.

Click the template file name, service name, and function name in the LOCAL RESOURCES panel, and select Deploy from the context menu to deploy the template file, service, and function granularity.

Other features

Invoke functions locally

In the LOCAL RESOURCES panel, click the invoke icon to the right of a function or click the link in the Handler file to invoke the function.

The logs and results of the function will be displayed in the TERMINAL panel.

The extension creates an event.dat file under the directory that stores the function entry file. You can modify the event.dat file to configure events triggered when the function is invoked.

Debug locally

In the LOCAL RESOURCES panel, click the debugging icon to the right of a function or click the link in the Handler file to debug the function locally.

Set breakpoints in code and start debugging. The debug information will be displayed.

The extension creates an event.dat file under the directory that stores the function entry file. You can modify the event.dat file to configure events triggered when the function is debugged.

Notice

  • If you want to debug functions that run in Python 2.7 or Python 3 runtimes, you must first install the Python extension from the extension marketplace.

  • If you want to debug functions that run in PHP runtimes, you must first install the PHP Debug extension from the extension marketplace.

Invoke functions in Function Compute

In the REMOTE RESOURCES panel, click the invoke icon to the right of a function to invoke the function.

The logs and results of the function will be displayed in the TERMINAL panel.

The extension creates an event.dat file under the root directory of the project. You can modify the event.dat file to configure events triggered when the function is invoked.

Configure parameters in template files

Fun uses YAML template files to describe serverless applications. When you use the extension to create a function, the parameters in the template file will be specified as default values automatically. If you want to configure local services or functions, you can click the service name or function name in the LOCAL RESOURCES panel to go to the descriptions in the template file. The corresponding description blocks will be highlighted and dimmed after a short period of time.

Obtain template prompts

  • Automatic completion

Specifications of resources in the template.yml file are completed automatically according to prompts provided based on the indentation level.

  • Specification validation

All resource specifications in the template.yml file are validated based on the template specification description.

  • Hovering prompts

Resource specifications that can be configured in the template.yml file are prompted when you move the pointer over the resource key. Prompts include specification names, types, and documentation.

Feedback

You can scan the following QR code to join the Function Compute customer DingTalk group for troubleshooting or give feedback in GitHub.

serverless-vscode's People

Contributors

chandaoh avatar coco-super avatar dependabot[bot] avatar rsonghuster avatar squatstonight avatar vangie avatar wss-git avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

serverless-vscode's Issues

集成 Sbox

Is your feature request related to a problem? Please describe.
Funcraft 3.0 已经支持 fun install sbox 功能,希望能集成到 vscode 插件

Describe the solution you'd like
支持在本地资源树上对呀的函数上启动 sbox。

云端资源显示优化

  1. 如图所示,希望单击云端资源时,能在右侧显示相关的配置信息。
    image

  2. 提供下载代码和生成 template.yml 的按钮。如果用户要看云端的代码,可以方便的把云端资源下载下来,变成本地资源管理。

支持 template.yml 内函数属性自动补全

如下 template.yml

ROSTemplateFormatVersion: '2015-09-01'
Transform: 'Aliyun::Serverless-2018-04-03'
Resources:
  my-test:
    Type: 'Aliyun::Serverless::Service'
    Properties:
      Description: 'helloworld'
    my-test:
      Type: 'Aliyun::Serverless::Function'
      Properties:
        Handler: index.handler
        Runtime: nodejs8
        CodeUri: './'

在 CodeUri 后一行输入 Env 不会出现 EnvironmentVariables 补全提示。

空模版文件提供快速构建 ROS 模版方式

Is your feature request related to a problem? Please describe.
新建一个 template.yml,是否有办法快速构建出一个 ROS 模版,现在需要去其他地方复制黏贴或者通过插件创建一个新函数。但是有时候并不想要创建一个新函数。

Describe the solution you'd like
希望可以提供一种从空的 template.yml 模版文件快速构建 ROS 模版的方式

Describe alternatives you've considered

Additional context

run 和 debug 不支持模板路径

╰─➜  fun local invoke puppeteer/html2png -e /Users/vangie/Workspace/puppeteer-example/{{ projectName }}/event.dat

  error: unexpected argument 'projectName'

  Usage: fun local invoke [options] <[service/]function>

  Execute your function in a local environment which replicates the live environment
  almost identically. You can pass in the event body via stdin or by using the -e (--event)
  parameter.

  Options:

    -d, --debug-port <port>      specify the sandboxed container starting in debug mode,
                                 and exposing this port on localhost
    -c, --config <ide/debugger>  output configurations for the specified ide/debugger, where
                                 the ide/debugger can currently only be vscode
    -e, --event <path>           a file containing event data passed to the function during
                                 invoke, If this option is not specified, it defaults to
                                 reading event from stdin
    -h, --help                   output usage information

Local resource 资源管理增强

Is your feature request related to a problem? Please describe.

  1. 在 local resource 中,能否双击函数显示代码?而不是显示 template.yml 中的内容。
  2. 在 local resource 中,单击服务/函数时,除了光标指向 template.yml 中对应的位置外,能否该服务/函数整个区域都闪烁一下,提醒用户这些属性都属于这个服务/函数?

在 fun.yml 文件里也会触发 template.yml 的自动补全

应该只在 template.yml 文件里触发,不影响其他 yml 文件。

runtime: nodejs8
tasks:
  - apt: ndiff
    local: tablestore: # tablestore name
      Type: 'Aliyun::Serverless::TableStore'
      Properties:
        ClusterType: HYBRID
      table: # table name
        Type: 'Aliyun::Serverless::TableStore::Table'
        Properties:
          PrimaryKeyList:
            - Name: uid
              Type: STRING
  - apt: nmap

http trigger 调试 hang

在调试通过 http trigger 触发的函数时,有一定概率 hang。如下图所示。
image

如果此时在此单击函数的 debug 按钮,会出现端口绑定错误。
image

调试 event function 没有该问题。怀疑 fun 支持 http trigger 调试逻辑有 bug。

为本地 run 和 debug 增加配置文件


{
    "templates": {
        "my-app/template.yaml": {
            "handlers": {
                "app.fc_handler": {
                    "event": "ots_evt",
                    "environmentVariables": {},
                    "events" : {
                        "ots_evt": {
                            "type": "file",
                            "value": "./ots_event.dat"
                        },
                        "rds_evt": {
                            "type": "string",
                            "value": "event-as-string"
                        }
                    }
                }
            }
        }
    }
}

支持局部部署服务或函数

Is your feature request related to a problem? Please describe.
有时候并不想全量部署 template.yml 描述的所有资源,只想部署某个特定的服务或者某个特定的函数

Describe the solution you'd like
支持局部部署服务或函数

Describe alternatives you've considered

Additional context

在 Local resource 区域单击函数,template.yml 中光标指向了错误的位置

Describe the bug
点击函数,光标指向了 template.yml 中错误的位置

To Reproduce
Steps to reproduce the behavior:

  1. 在一个服务下创建多个函数
  2. 点击除第一个函数之外任意的函数
  3. 右侧的 template.yml 显示区域中,光标指向了错误的位置

Expected behavior
光标指向该函数所在的位置

Screenshots
image

Desktop (please complete the following information):

  • OS: [MacOS 10.14.6]
  • VSCode Version: [e.g. 1.36.1]
  • Aliyun Serverless Extension Version [e.g. 1.3.0]

Additional context
Add any other context about the problem here.

云端资源信息显示优化

Is your feature request related to a problem? Please describe.

  1. 如果用户没有配置 NAS,建议不显示该信息。而且信息标题是 “文件系统配置”,这个词很模糊,用户会 confuse 是本地还是云端。建议改成 NAS 配置。
  2. 信息的 key value 显示建议按照上边缘对齐。
    image

支持安装倚赖包

在 vscode extension 中,支持右键函数进行 install package,提供 packageType 以及 packageName 输入的填写。

MACOS下输入代码自动向上滚屏

Describe the bug
在macos 10.14.6系统,vscode 1.36.1,python 3.6环境下(其他环境应该也会出现),def handler函数上面有一行提示:FC:Local Run | FC: Local Debug,把代码编辑窗口向下滚动至提示行在最上面不可见时,然后输入代码时,代码视图自动向上滚屏

Snapshot
1

2

To Reproduce
def handler函数上面有一行提示:FC:Local Run | FC: Local Debug,把代码编辑窗口向下滚动至提示行在最上面不可见时,然后输入代码时,代码视图自动向上滚屏

Expected behavior
输入代码时视图不会自动滚屏

Desktop (please complete the following information):

  • OS: MacOS 10.14.6
  • VSCode Version: 1.36.1
  • Python:3.6
  • Aliyun Serverless Extension Version: 1.2.0

Additional context
bug应该来源于def handler上面那行提示 FC: Local Run …… 的显示处理有问题

版本更新通知

image

  1. 提供更新通过,让用户知道发布了新版本
  2. 我们也可以考虑把 What's New 和 Release Notes 分开,What's New 突出介绍新功能(图文并茂),Release Notes 包含修复的问题,新增的功能,已经做的变化。

How to reference libs that are provided by the runtime?

Is your feature request related to a problem? Please describe.
I'd like to use the libs that are provided by the runtime, e.g. the open-cv lib. But since the vscode is unaware of those libs, auto-completion doesn't work for those libs.

Describe the solution you'd like
I don't want to install those libs locally since ensuring the local version and runtime version the same is not fun.

Describe alternatives you've considered
N/A

Additional context
23_37_05__08_01_2019

Allow to config services root path for importing

Is your feature request related to a problem? Please describe.
We use a mono-repo for all our server-side code and all FC code live in a sub directory. When importing remote resources, the plugin always place them in the root director.

Describe the solution you'd like
Make the root path for importing remote resources configurable thru vscode settings or an RC file.

优化vscode插件调试http trigger

目前使用vscode调试http trigger的时候。点击 local debug之后,会自动弹出浏览器窗口进行http触发。 但是如果开发的接口是post接口。每次debug的时候都会新建一个浏览器窗口进行get的请求。导致接口无法正常调试。希望能优化。

支持配置外部 fun 进行 invoke

Is your feature request related to a problem? Please describe.
当前的插件使用内置的 fun,加入 fun 有问题,需要升级,运行用户配置外部的 fun 进行调用。

Describe the solution you'd like
提供一种配置方式把内置的 fun 给替换掉。

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

template.yml 支持 tab 层级色彩

Is your feature request related to a problem? Please describe.
tab 层级色彩更方便用户分清楚不同块层级。

Describe the solution you'd like
不同层级的 tab 显示成不同的颜色

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

支持 Funfile

Is your feature request related to a problem? Please describe.
Funcraft 3.0 支持了 Funfile,需要跟进这个功能

Describe the solution you'd like

  1. Funfile 支持语法高亮、代码提示和错误校验
  2. 支持从 Funfile 文件内执行 fun install或者文件右键触发

支持多个 template.yml 文件

Is your feature request related to a problem? Please describe.
支持多 template.yml 的复杂结构项目

Describe the solution you'd like
在本地资源编码显示多个 template 的多根树

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

支持调用使用 http trigger 的函数

Is your feature request related to a problem? Please describe.
当前 fun 只支持 event function 的调用,希望也能支持远程调用包含 http trigger 的函数。方便用户调试。

Describe the solution you'd like
短期内 fun 能够显示 http function 的 url,方便在浏览器中贴上地址直接测试。系统性解决,可以考虑集成 postman 等调试工具。

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

template.yml 语法校验

  1. 能标记出不支持的字段
  2. 能标记出无效的值
    1. CodeUri 指向一个不存在的目录或者文件也能标记出
    2. Memory 填了一个不支持的值

删除服务/函数

Is your feature request related to a problem? Please describe.
在 fun 中如何服务/函数资源?当前在 template.yml 中删除相关的资源,左侧的 local resource 面板还会显示。

image

fun invoke 替换掉 sdk 调用

Describe the solution you'd like
目前 funcraft 已经支持了 fun invoke,考虑替换掉目前 SDK 调用的方式。

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.