Hermann  Frami

Hermann Frami

1656990300

Serverless Tencent SCF

serverless-tencent-scf

This plugin enables [Tencent SCF (Serverless Cloud Function)] (https://cloud.tencent.com/product/scf) support for [Serverless Framework] (https://github.com/serverless/serverless).

Getting started

Pre-requisites

  • Node.js v8.x+
  • Serverless CLI v1.35.0+ (install via npm i -g serverless)
  • Qcloud account   - APPID   - SecretId   - SecretKey

example

The project file structure is similar to this:

├── index.js
├── package.json
└── serverless.yml

serverless.yml:

service: hello-world

provider:
  name: tencent
  region: ap-guangzhou
  runtime: Nodejs8.9
  stage: dev
  credentials: ~/.tencentcloud/credentials.ini # must provide absolute path

plugins:
  - serverless-tencent-scf

package:
  exclude:
    - ./**
  include:
    - index.js

functions:
  hello:
    handler: index.hello
    description: hello world function
    memorySize: 128
    timeout: 3
    events:
      - timer:
          name: 5m
          cron: "*/5 * * * *"

For more examples of trigger configuration, please refer to example/serverless.yml

package.json:

{
  "devDependencies": {
    "serverless-tencent-scf": "*"
  }
}

index.js:

"use strict";

exports.hello = (event, context, callback) => {
  callback(null, "Hello world!");
};

API key configuration credentials.ini:

[default]
tencent_secret_id=AKIxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
tencent_secret_key=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
tencent_app_id=1251******

This file contains sensitive information, please do not put it in the project directory, it is recommended to put it in your personal directory and configure it to provider.credentials with an absolute path.

If you do not configure provider.credentials, the default credential configuration of [tencentcli] (https://github.com/TencentCloud/tencentcloud-cli) will be used, but some features cannot work because there is no APPID, see FAQ.

The following is the access to each information.

Development & Publishing

Initial Tencent SCF plugin:

serverless plugin install --name serverless-tencent-scf

Deploy or update scf to Tencent Cloud:

serverless deploy

  TIP: The command sls is shortcut of serverless, so you can simply use sls deploy

Removed from Tencent Cloud scf:

serverless remove

Remote call

serverless invoke -f hello

Log query

serverless logs -f hello

FAQ

APPID

In the example provider.credentials is additionally configured with tencent_app_id, which is optional and only required by some functions.

Here are the features that need to use APPID

  • Release package file larger than 10MB

If not configured, an error will be displayed when performing the above functions.

cos Authorization

When the package file is larger than 10MB, it will upload package via user's own cos. The upload operation requires the account to have the read and write permissions of the transfer bucket (scf-deployment). If you are using sub-account, you can login owner account [associate CAM policy] (https://cloud.tencent.com/document/product/436/11714) to sub-account

Of course you can also do [more precise CAM authorization] (https://cloud.tencent.com/document/product/598/11084)

Role Authorization

Here are the features that need to grant permissions to the scf role.

  - When the package file is larger than 10MB, it will upload package file via cos, and scf needs to access the user-uploaded package file.   - cos trigger

Usually it is automate authorized by the tool, but if you are using a sub-account secret key, and the current cloud account does not have initial role creation and authorization, and there is no permission to perform initial operations, an error will be reported.

You can use the primary account to execute serverless tencent initcam, which will initialize the role authorization, so that scf can access other business resources (such as object storage, API gateway, etc.)

Visit [Tencent Cloud - Access Management - Roles] (https://console.cloud.tencent.com/cam/role) to view the strategy that the scf role (SCF_QcsRole) is bound to.

proxy

To use a proxy, configure the https_proxy environment variable

Read this in other languages: English, 简体中文

Author: tencentyun
Source Code: https://github.com/tencentyun/serverless-tencent-scf 
License: MIT license

#serverless #tencent #cloud #function 

What is GEEK

Buddha Community

Serverless Tencent SCF
Hermann  Frami

Hermann Frami

1655426640

Serverless Plugin for Microservice Code Management and Deployment

Serverless M

Serverless M (or Serverless Modular) is a plugin for the serverless framework. This plugins helps you in managing multiple serverless projects with a single serverless.yml file. This plugin gives you a super charged CLI options that you can use to create new features, build them in a single file and deploy them all in parallel

splash.gif

Currently this plugin is tested for the below stack only

  • AWS
  • NodeJS λ
  • Rest API (You can use other events as well)

Prerequisites

Make sure you have the serverless CLI installed

# Install serverless globally
$ npm install serverless -g

Getting Started

To start the serverless modular project locally you can either start with es5 or es6 templates or add it as a plugin

ES6 Template install

# Step 1. Download the template
$ sls create --template-url https://github.com/aa2kb/serverless-modular/tree/master/template/modular-es6 --path myModularService

# Step 2. Change directory
$ cd myModularService

# Step 3. Create a package.json file
$ npm init

# Step 3. Install dependencies
$ npm i serverless-modular serverless-webpack webpack --save-dev

ES5 Template install

# Step 1. Download the template
$ sls create --template-url https://github.com/aa2kb/serverless-modular/tree/master/template/modular-es5 --path myModularService

# Step 2. Change directory
$ cd myModularService

# Step 3. Create a package.json file
$ npm init

# Step 3. Install dependencies
$ npm i serverless-modular --save-dev

If you dont want to use the templates above you can just add in your existing project

Adding it as plugin

plugins:
  - serverless-modular

Now you are all done to start building your serverless modular functions

API Reference

The serverless CLI can be accessed by

# Serverless Modular CLI
$ serverless modular

# shorthand
$ sls m

Serverless Modular CLI is based on 4 main commands

  • sls m init
  • sls m feature
  • sls m function
  • sls m build
  • sls m deploy

init command

sls m init

The serverless init command helps in creating a basic .gitignore that is useful for serverless modular.

The basic .gitignore for serverless modular looks like this

#node_modules
node_modules

#sm main functions
sm.functions.yml

#serverless file generated by build
src/**/serverless.yml

#main serverless directories generated for sls deploy
.serverless

#feature serverless directories generated sls deploy
src/**/.serverless

#serverless logs file generated for main sls deploy
.sm.log

#serverless logs file generated for feature sls deploy
src/**/.sm.log

#Webpack config copied in each feature
src/**/webpack.config.js

feature command

The feature command helps in building new features for your project

options (feature Command)

This command comes with three options

--name: Specify the name you want for your feature

--remove: set value to true if you want to remove the feature

--basePath: Specify the basepath you want for your feature, this base path should be unique for all features. helps in running offline with offline plugin and for API Gateway

optionsshortcutrequiredvaluesdefault value
--name-nstringN/A
--remove-rtrue, falsefalse
--basePath-pstringsame as name

Examples (feature Command)

Creating a basic feature

# Creating a jedi feature
$ sls m feature -n jedi

Creating a feature with different base path

# A feature with different base path
$ sls m feature -n jedi -p tatooine

Deleting a feature

# Anakin is going to delete the jedi feature
$ sls m feature -n jedi -r true

function command

The function command helps in adding new function to a feature

options (function Command)

This command comes with four options

--name: Specify the name you want for your function

--feature: Specify the name of the existing feature

--path: Specify the path for HTTP endpoint helps in running offline with offline plugin and for API Gateway

--method: Specify the path for HTTP method helps in running offline with offline plugin and for API Gateway

optionsshortcutrequiredvaluesdefault value
--name-nstringN/A
--feature-fstringN/A
--path-pstringsame as name
--method-mstring'GET'

Examples (function Command)

Creating a basic function

# Creating a cloak function for jedi feature
$ sls m function -n cloak -f jedi

Creating a basic function with different path and method

# Creating a cloak function for jedi feature with custom path and HTTP method
$ sls m function -n cloak -f jedi -p powers -m POST

build command

The build command helps in building the project for local or global scope

options (build Command)

This command comes with four options

--scope: Specify the scope of the build, use this with "--feature" tag

--feature: Specify the name of the existing feature you want to build

optionsshortcutrequiredvaluesdefault value
--scope-sstringlocal
--feature-fstringN/A

Saving build Config in serverless.yml

You can also save config in serverless.yml file

custom:
  smConfig:
    build:
      scope: local

Examples (build Command)

all feature build (local scope)

# Building all local features
$ sls m build

Single feature build (local scope)

# Building a single feature
$ sls m build -f jedi -s local

All features build global scope

# Building all features with global scope
$ sls m build -s global

deploy command

The deploy command helps in deploying serverless projects to AWS (it uses sls deploy command)

options (deploy Command)

This command comes with four options

--sm-parallel: Specify if you want to deploy parallel (will only run in parallel when doing multiple deployments)

--sm-scope: Specify if you want to deploy local features or global

--sm-features: Specify the local features you want to deploy (comma separated if multiple)

optionsshortcutrequiredvaluesdefault value
--sm-paralleltrue, falsetrue
--sm-scopelocal, globallocal
--sm-featuresstringN/A
--sm-ignore-buildstringfalse

Saving deploy Config in serverless.yml

You can also save config in serverless.yml file

custom:
  smConfig:
    deploy:
      scope: local
      parallel: true
      ignoreBuild: true

Examples (deploy Command)

Deploy all features locally

# deploy all local features
$ sls m deploy

Deploy all features globally

# deploy all global features
$ sls m deploy --sm-scope global

Deploy single feature

# deploy all global features
$ sls m deploy --sm-features jedi

Deploy Multiple features

# deploy all global features
$ sls m deploy --sm-features jedi,sith,dark_side

Deploy Multiple features in sequence

# deploy all global features
$ sls m deploy  --sm-features jedi,sith,dark_side --sm-parallel false

Author: aa2kb
Source Code: https://github.com/aa2kb/serverless-modular 
License: MIT license

#serverless #aws #node #lambda 

Serverless Applications - Pros and Cons to Help Businesses Decide - Prismetric

In the past few years, especially after Amazon Web Services (AWS) introduced its Lambda platform, serverless architecture became the business realm’s buzzword. The increasing popularity of serverless applications saw market leaders like Netflix, Airbnb, Nike, etc., adopting the serverless architecture to handle their backend functions better. Moreover, serverless architecture’s market size is expected to reach a whopping $9.17 billion by the year 2023.

Global_Serverless_Architecture_Market_2019-2023

Why use serverless computing?
As a business it is best to approach a professional mobile app development company to build apps that are deployed on various servers; nevertheless, businesses should understand that the benefits of the serverless applications lie in the possibility it promises ideal business implementations and not in the hype created by cloud vendors. With the serverless architecture, the developers can easily code arbitrary codes on-demand without worrying about the underlying hardware.

But as is the case with all game-changing trends, many businesses opt for serverless applications just for the sake of being up-to-date with their peers without thinking about the actual need of their business.

The serverless applications work well with stateless use cases, the cases which execute cleanly and give the next operation in a sequence. On the other hand, the serverless architecture is not fit for predictable applications where there is a lot of reading and writing in the backend system.

Another benefit of working with the serverless software architecture is that the third-party service provider will charge based on the total number of requests. As the number of requests increases, the charge is bound to increase, but then it will cost significantly less than a dedicated IT infrastructure.

Defining serverless software architecture
In serverless software architecture, the application logic is implemented in an environment where operating systems, servers, or virtual machines are not visible. Although where the application logic is executed is running on any operating system which uses physical servers. But the difference here is that managing the infrastructure is the soul of the service provider and the mobile app developer focuses only on writing the codes.

There are two different approaches when it comes to serverless applications. They are

Backend as a service (BaaS)
Function as a service (FaaS)

  1. Backend as a service (BaaS)
    The basic required functionality of the growing number of third party services is to provide server-side logic and maintain their internal state. This requirement has led to applications that do not have server-side logic or any application-specific logic. Thus they depend on third-party services for everything.

Moreover, other examples of third-party services are Autho, AWS Cognito (authentication as a service), Amazon Kinesis, Keen IO (analytics as a service), and many more.

  1. Function as a Service (FaaS)
    FaaS is the modern alternative to traditional architecture when the application still requires server-side logic. With Function as a Service, the developer can focus on implementing stateless functions triggered by events and can communicate efficiently with the external world.

FaaS serverless architecture is majorly used with microservices architecture as it renders everything to the organization. AWS Lambda, Google Cloud functions, etc., are some of the examples of FaaS implementation.

Pros of Serverless applications
There are specific ways in which serverless applications can redefine the way business is done in the modern age and has some distinct advantages over the traditional could platforms. Here are a few –

🔹 Highly Scalable
The flexible nature of the serverless architecture makes it ideal for scaling the applications. The serverless application’s benefit is that it allows the vendor to run each of the functions in separate containers, allowing optimizing them automatically and effectively. Moreover, unlike in the traditional cloud, one doesn’t need to purchase a certain number of resources in serverless applications and can be as flexible as possible.

🔹 Cost-Effective
As the organizations don’t need to spend hundreds and thousands of dollars on hardware, they don’t need to pay anything to the engineers to maintain the hardware. The serverless application’s pricing model is execution based as the organization is charged according to the executions they have made.

The company that uses the serverless applications is allotted a specific amount of time, and the pricing of the execution depends on the memory required. Different types of costs like presence detection, access authorization, image processing, etc., associated with a physical or virtual server is completely eliminated with the serverless applications.

🔹 Focuses on user experience
As the companies don’t always think about maintaining the servers, it allows them to focus on more productive things like developing and improving customer service features. A recent survey says that about 56% of the users are either using or planning to use the serverless applications in the coming six months.

Moreover, as the companies would save money with serverless apps as they don’t have to maintain any hardware system, it can be then utilized to enhance the level of customer service and features of the apps.

🔹 Ease of migration
It is easy to get started with serverless applications by porting individual features and operate them as on-demand events. For example, in a CMS, a video plugin requires transcoding video for different formats and bitrates. If the organization wished to do this with a WordPress server, it might not be a good fit as it would require resources dedicated to serving pages rather than encoding the video.

Moreover, the benefits of serverless applications can be used optimally to handle metadata encoding and creation. Similarly, serverless apps can be used in other plugins that are often prone to critical vulnerabilities.

Cons of serverless applications
Despite having some clear benefits, serverless applications are not specific for every single use case. We have listed the top things that an organization should keep in mind while opting for serverless applications.

🔹 Complete dependence on third-party vendor
In the realm of serverless applications, the third-party vendor is the king, and the organizations have no options but to play according to their rules. For example, if an application is set in Lambda, it is not easy to port it into Azure. The same is the case for coding languages. In present times, only Python developers and Node.js developers have the luxury to choose between existing serverless options.

Therefore, if you are planning to consider serverless applications for your next project, make sure that your vendor has everything needed to complete the project.

🔹 Challenges in debugging with traditional tools
It isn’t easy to perform debugging, especially for large enterprise applications that include various individual functions. Serverless applications use traditional tools and thus provide no option to attach a debugger in the public cloud. The organization can either do the debugging process locally or use logging for the same purpose. In addition to this, the DevOps tools in the serverless application do not support the idea of quickly deploying small bits of codes into running applications.

#serverless-application #serverless #serverless-computing #serverless-architeture #serverless-application-prosand-cons

Alice  Klocko

Alice Klocko

1595381040

Tencent Cloud and Serverless Join Forces to Bring the Serverless Movement to China

A few months ago we met with a team from Tencent Cloud to discuss how we could work together to bring the serverless movement to China, and we immediately realized that we both share a similar vision… that serverless is the future of the cloud. We also recognized that Tencent is more ambitious about serverless than other cloud providers. From their leadership team to their engineers, everyone at Tencent impressed us with their commitment to innovating within the serverless space.

Today we are excited to announce that Tencent Cloud is joining our cloud provider partner program as a Premier Partner. If you don’t know Tencent, they are the largest internet company in Asia, providing services for hundreds of millions of people via a wide range of products, like QQ and WeChat. Gamers know them as the company behind Riot Games and League of Legends. Under the covers these popular internet services, and many other similar services from a variety of companies, are powered by the Tencent Cloud.

By partnering with an infrastructure provider with the ambition and talent Tencent has, together, our companies can deliver a serverless cloud experience like no other cloud has, all to empower developers and large enterprises alike. Our shared goal is to enable developers to innovate more than ever, by offering them more use-cases to run on serverless infrastructure. We will also strive to make the developer experience of those use-cases as simple as possible. We want every developer to be able to harness the power of serverless cloud infrastructure, so they can innovate more and manage less.

For enterprises, our collaboration will yield many operational tools that will enable enterprise software teams to not only innovate more quickly, but more safely. We will give teams advanced monitoring and observability features. We will also offer powerful debugging capabilities, streamlined deployment pipelines, security automation and policy enforcement to ensure developer teams are following organizational policies.

#serverless #tencent cloud #serverless

Christa  Stehr

Christa Stehr

1602681082

Overcoming Common Serverless Challenges with Mainframe CICS Programs

By this point most enterprises, including those running on legacy infrastructures, are familiar with the benefits of serverless computing:

  • Greater scalability
  • Faster development
  • More efficient deployment
  • Lower cost

The benefits of agility and cost reduction are especially relevant in the current macroeconomic environment when customer behavior is changing, end-user needs are difficult to predict, and development teams are under pressure to do more with less.

So serverless is a no-brainer, right?

Not exactly. Serverless might be relatively painless for a new generation of cloud-native software companies that grew up in a world of APIs and microservices, but it creates headaches for the many organizations that still rely heavily on legacy infrastructure.

In particular, enterprises running mainframe CICS programs are likely to encounter frustrating stumbling blocks on the path to launching Functions as a Service (FaaS). This population includes global enterprises that depend on CICS applications to effectively manage high-volume transactional processing requirements – particularly in the banking, financial services, and insurance industries.

These organizations stand to achieve time and cost savings through a modern approach to managing legacy infrastructure, as opposed to launching serverless applications on a brittle foundation. Here are three of the biggest obstacles they face and how to overcome them.

Challenge #1

Middleware that introduces complexity, technical debt, and latency. Many organizations looking to integrate CICS applications into a microservices or serverless architecture rely on middleware (e.g., an ESB or SOA) to access data from the underlying applications. This strategy introduces significant runtime performance challenges and creates what one bank’s chief architect referred to as a “lasagna architecture,” making DevOps impossible.

#serverless architecture #serverless functions #serverless benefits #mainframes #serverless api #serverless integration

Hermann  Frami

Hermann Frami

1656990300

Serverless Tencent SCF

serverless-tencent-scf

This plugin enables [Tencent SCF (Serverless Cloud Function)] (https://cloud.tencent.com/product/scf) support for [Serverless Framework] (https://github.com/serverless/serverless).

Getting started

Pre-requisites

  • Node.js v8.x+
  • Serverless CLI v1.35.0+ (install via npm i -g serverless)
  • Qcloud account   - APPID   - SecretId   - SecretKey

example

The project file structure is similar to this:

├── index.js
├── package.json
└── serverless.yml

serverless.yml:

service: hello-world

provider:
  name: tencent
  region: ap-guangzhou
  runtime: Nodejs8.9
  stage: dev
  credentials: ~/.tencentcloud/credentials.ini # must provide absolute path

plugins:
  - serverless-tencent-scf

package:
  exclude:
    - ./**
  include:
    - index.js

functions:
  hello:
    handler: index.hello
    description: hello world function
    memorySize: 128
    timeout: 3
    events:
      - timer:
          name: 5m
          cron: "*/5 * * * *"

For more examples of trigger configuration, please refer to example/serverless.yml

package.json:

{
  "devDependencies": {
    "serverless-tencent-scf": "*"
  }
}

index.js:

"use strict";

exports.hello = (event, context, callback) => {
  callback(null, "Hello world!");
};

API key configuration credentials.ini:

[default]
tencent_secret_id=AKIxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
tencent_secret_key=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
tencent_app_id=1251******

This file contains sensitive information, please do not put it in the project directory, it is recommended to put it in your personal directory and configure it to provider.credentials with an absolute path.

If you do not configure provider.credentials, the default credential configuration of [tencentcli] (https://github.com/TencentCloud/tencentcloud-cli) will be used, but some features cannot work because there is no APPID, see FAQ.

The following is the access to each information.

Development & Publishing

Initial Tencent SCF plugin:

serverless plugin install --name serverless-tencent-scf

Deploy or update scf to Tencent Cloud:

serverless deploy

  TIP: The command sls is shortcut of serverless, so you can simply use sls deploy

Removed from Tencent Cloud scf:

serverless remove

Remote call

serverless invoke -f hello

Log query

serverless logs -f hello

FAQ

APPID

In the example provider.credentials is additionally configured with tencent_app_id, which is optional and only required by some functions.

Here are the features that need to use APPID

  • Release package file larger than 10MB

If not configured, an error will be displayed when performing the above functions.

cos Authorization

When the package file is larger than 10MB, it will upload package via user's own cos. The upload operation requires the account to have the read and write permissions of the transfer bucket (scf-deployment). If you are using sub-account, you can login owner account [associate CAM policy] (https://cloud.tencent.com/document/product/436/11714) to sub-account

Of course you can also do [more precise CAM authorization] (https://cloud.tencent.com/document/product/598/11084)

Role Authorization

Here are the features that need to grant permissions to the scf role.

  - When the package file is larger than 10MB, it will upload package file via cos, and scf needs to access the user-uploaded package file.   - cos trigger

Usually it is automate authorized by the tool, but if you are using a sub-account secret key, and the current cloud account does not have initial role creation and authorization, and there is no permission to perform initial operations, an error will be reported.

You can use the primary account to execute serverless tencent initcam, which will initialize the role authorization, so that scf can access other business resources (such as object storage, API gateway, etc.)

Visit [Tencent Cloud - Access Management - Roles] (https://console.cloud.tencent.com/cam/role) to view the strategy that the scf role (SCF_QcsRole) is bound to.

proxy

To use a proxy, configure the https_proxy environment variable

Read this in other languages: English, 简体中文

Author: tencentyun
Source Code: https://github.com/tencentyun/serverless-tencent-scf 
License: MIT license

#serverless #tencent #cloud #function