Scenario Describes how to use ali Cloud function computing service command line tool to quickly build a Hexo blog. From November 9th to November 23rd, after completing the experience, you will get “A TOMY Domeika alloy car model”.

Experience resources

ECS server experience resources in 2 hours

This scenario mainly involves the following cloud products and services:

FunctionCompute = FunctionCompute

Functional computing is an event-driven, fully managed computing service. With functional computing, you don’t need to purchase and manage infrastructure such as servers; you just write and upload code. Functional computing prepares you for computing resources, runs tasks flexibly and reliably, and provides log query, performance monitoring, and alarm capabilities. Functional computing helps you build applications quickly by focusing on functional code without having to manage servers. Function calculations scale flexibly, and you only need to pay by usage.

The function computing Serverless service has the following advantages over the self-built service:

  1. Easy to get started, only focus on business logic development, greatly improve the efficiency of project development.

  2. There are too many learning and configuration costs for the self-built solution. For example, different ESS parameters need to be configured for different scenarios, which makes it difficult to maintain and upgrade the system environment.

3) No operation and maintenance, supporting monitoring and alarm of function execution level and granularity.

  1. Elastic capacity expansion in milliseconds ensures elastic high availability.

2. Object storage OSS

Object storage OSS is a massive, secure, low-cost, and highly reliable cloud storage service, providing 99.999999999999% (12 9) data persistence and 99.995% data availability. Multiple storage types to choose from, optimize storage costs.

3. Container image service ACR

Container Image service is an OCI-compliant cloud native product secure hosting and efficient distribution platform for container image, Helm Chart, etc. ACR supports global synchronization acceleration, large-scale/large image distribution acceleration, multi-source build acceleration and other full-link improvements. It is seamlessly integrated with container service ACK to help enterprises reduce delivery complexity and create a one-stop solution for cloud native applications.

4. File storage is NAS

The FILE storage NAS (NAS) is a cloud native distributed file system with high performance and flexible scalability that can be accessed in a large scale. Supports intelligent layering of hot and cold data, effectively reducing data storage costs. Widely used in enterprise-level application data sharing, containers, AI machine learning, Web services and content management, application development and testing, media and entertainment workflow, database backup and other scenarios.

5, the CDN

CDN provides fast, stable, safe and programmable global content distribution acceleration service through extensive network node distribution. It supports the distribution of website, audio and video, download and other content to nodes close to users, so that users can get the required content nearby and improve the response speed and success rate of users’ access.

Serverless Devs developer Tools

Serverless Devs is a component and plug-in Serverless developer platform, developers can plug in the platform to use different Serverless services and frameworks, and can participate in the development of components and plug-ins. Serverless Devs supports both industrial-grade Serverless services and various open source Serverless frameworks. Instead of studying and learning every Serverless tool on the market, developers can quickly and easily “get started” with mainstream Serverless services and frameworks through Serverless Devs.

Function computing service is required

Before using function computation, you need to open the function computation service.

Note: The aliyun sub-account provided in this scenario does not have the operation rights of function computing services, so please use your own Aliyun account for operation. You do not need to worry about the deduction, because the function computing service has a certain amount of free, please refer to the billing method.

Log in to ali Cloud console using your own Ali Cloud account, and then enter the function calculation details page.

Click Free.

Select the function computing Service protocol and click Open now.

After successful opening, you will receive the following prompt.

Enable the CDN service

You need to enable the CDN service before using it.

Note: The Aliyun sub-account provided in this scenario does not have the CDN service operation rights, so please use your own Aliyun account for operation. For details about CDN charging, see CDN Charging Mode.

Use your own Ali Cloud account to log in to ali Cloud console, and then enter the CDN service details page.

Click Open Now.

Select the Content Delivery Network (CDN) service protocol and click Enable Now.

After successful opening, you will receive the following prompt.

Also, maybe open file storage NAS and object storage OSS

Install the Serverless Devs command line tool

Install node.js. Run the following command to download the Node.js installation package.

Wget HTTP: / / https://npm.taobao.org/mirrors/node/v12.4.0/node-v12.4.0-linux-x64.tar.xzCopy the code

Run the following command to decompress the installation package and rename it.

Tar -xvf node-v12.4.0-linux-x64.tar.xz && mv node-v12.4.0-linux-x64/ /usr/local/nodeCopy the code

Run the following command to configure environment variables.

echo "export PATH=$PATH:/usr/local/node/bin" >> /etc/profile
source /etc/profile
Copy the code

Run the following command to install the Serverless-devs tool.

npm install @serverless-devs/s -g
Copy the code

If the following information is displayed, the installation is complete.

Description:

If the installation process is slow, you can use taobao NPM source and run the following installation command:

npm --registry=https://registry.npm.taobao.org install @serverless-devs/s -g
Copy the code

Run the following command to view the version and check whether the installation is correct.

s -v
Copy the code

The result is as follows, and you can see the version of the Serverless-Devs tool.

4. For this project, Docker also needs to be installed.

curl -fsSL https://get.docker.com | bash -s docker --mirror Aliyun
Copy the code

Once the installation is complete, try starting Docker:

sudo systemctl start docker
Copy the code

The aliyun account information was configured

Description:

This scenario provides a free ECS server, but the function computing service is opened under your account. The following configuration information also needs to configure the UID, AccessKry ID, and AccessKey Secret information of your account.

Run the following command to configure account information.

S config add Then enter the following information as prompted.

Cloud vendor: Choose Alibaba Cloud (Alibaba).

AccountID: Check the ID of your main Aliyun account on the account security setting page.

AccessKeyID and AccessKeySecret: View the AccessKeyID and AccessKeySecret of your account on the security information management page.

If you use the aliyun main account, click Continue to use AccessKey in the security prompt dialog box on the security information management page.

If you are using aliyun RAM sub-user, you need to ensure that your sub-user has the function computing management permission AliyunFCFullAccess, please refer to Authorization for RAM User.

As shown in the figure below, you can view your AccessKey ID and AccessKey Secret in the User AccessKey area. If your account has not used an AccessKey, click to create an AccessKey in the upper right corner.

After the Configuration is successful, you will receive the message “Configuration Successful”, as shown in the following figure.

Build the Hexo Blog project

  1. Initialize a Hexo project at the current path by executing the following command.
s init devsapp/start-hexo
Copy the code

A. Enter the project file name start-hexo and press Enter.

B. Install dependent components. Type Yes and press Enter.

C. Select the default credential and press Enter.

The result is as follows.

2. Deploy the Hexo project to the functional computing service. A. Run the following command to go to the project directory.

cd start-hexo
Copy the code

B. Run the following command to deploy the project.

s deploy
Copy the code

The result is as follows.

3. Open the virtual desktop browser, access the test domain name, and view the deployed Hexo blogging system.

Next you can add themes and plug-ins to enrich your blogging system.