Funcraft: Alibaba Cloud Function Compute Development Kit
Published: 2021-11-30 09:21:18

Almost every cloud platform offers their own unique development kits. Alibaba Cloud provides several options to develop and deploy the serverless workloads. In the past, I have mainly used the in-portal deployment options; for the smaller functions I even write the code in-line. As the project grows and becomes cumbersome, it's better to find an SDK that offers a proper development environment. An IDE, if you may. 

## Setting up

The [Funcraft by Alibaba Cloud](https://github.com/alibaba/funcraft/blob/master/README-en.md) is a free and open source SDK that you can use to develop the functions and test them locally on your device. All you would need to [install](https://github.com/alibaba/funcraft/blob/master/docs/usage/installation.md) is Docker and the [Funcraft (@alicloud/fun)](https://www.npmjs.com/package/@alicloud/fun) package from NPM repositories. The Docker engine is needed to run and debug the functions locally. If you do not wish to run the serverless on your machine, then you won't require this. 

> Installation of Docker is simple, and takes only a few minutes. Alibaba Cloud provides the [documentation](https://github.com/alibaba/funcraft/blob/master/docs/usage/installation.md#install-docker) using which you can deploy Docker on your own machine for development purposes. Plus, it saves a lot of costs from your Alibaba Cloud budget. 

## First Function

Once you have the Funcraft set up, I recommend using the [Alibaba Cloud Serverless extension](https://www.alibabacloud.com/help/doc-detail/126086.htm) for Visual Studio Code. This extension contains several support and utility methods that you can use to create, develop, debug and deploy the serverless instances. 

> You can use the [credentials](https://www.alibabacloud.com/help/doc-detail/53045.htm) from your Alibaba Cloud Account Management to setup the Funcraft as well as the Alibaba Cloud CLI. You would need to use this to deploy the functions on the cloud platform. VS Code would use the RAM accounts from Alibaba Cloud.

You can perform several operations using the VS Code extension:

1. Preview all the resources and their regions.
1. Edit the resources.
1. Create new resources (serverless, for example) in the regions you want to create them.
1. Run and debug the resources as needed.
1. Get support (such as autocomplete, etc.) based on the runtime/framework selected.
1. Deploy the resources to the cloud.

On top of this, since the extension is closely integrated with the VS Code, you receive language autocompletion and syntax highlights and formatting too. 

The extension creates the serverless in your local machine. Since it is a file in a folder, you can version control the serverless as well. 

## Deployment

From Visual Studio Code, you can deploy the serverless instances directly to the cloud. 

> Have you configured the credentials already? Select **Bind New Account** under **Remote Resources** tab to link your Alibaba Cloud to the extension.

To deploy, just click on the Deploy button in the **Local Resources** tab, this should deploy the services and functions (a service contains functions, for more on this, please check the [Alibaba Cloud documentation](https://www.alibabacloud.com/help/product/50980.htm))

## Conclusion

In short, the Alibaba Cloud Serverless extension and the Funcraft are a very easy way to develop and deploy enterprise grade serverless resources. Both the products are free and open source, and you can try our the Alibaba Cloud Function Compute product free of cost ([for development purposes](https://www.alibabacloud.com/help/doc-detail/54301.htm)).

That's about it for this one, I hope you learned something new about Alibaba Cloud Function Compute. :)