How to Setup Serveless – Setup

Serverless computing is a cloud-computing execution model in which the cloud provider runs the server, and dynamically manages the allocation of machine resources. Pricing is based on the actual amount of resources consumed by an application, rather than on pre-purchased units of capacity.  Source: Wikipedia

In this section, you would need to have Azure or AWS access. Both of these are free to download and you can gain trial.

Serverless CLI Installation

Serverless CLI is an npm package that should be installed globally to access the CLI.


Steps:

  • Install NodeJS on your system.

Azure Functions Serverless Framework plugin requires Node v6.5.0.

  • Execute node --version to verify you have the proper NodeJS installed.
  • Now install serverless using,
npm install -g serverless 
  • Verify the installation by running sls --help.

For Serverless CLI to work:

  1. You must have a cloud provider like AWS or Azure that provide the serverless environment.
  2. You must allow Serverless CLI access to your account through IAMService Principal or similar mechanisms.

Azure Credentials

  1. The easiest way to provide azure credentials to Serverless CLI is by running serverless deploy. It will provide an interactive way to set up the credentials.
  2. Alternatively, you can follow the hard way,
    1. You must have Azure CLI installed.
    2. Login to Azure.
      az login
      

    The above Command will give you a code and will ask you to log in with credentials (aka.ms/devicelogin).

  1. Now that you are logged in, you should be able to fetch your subscription information by running,
    az account list
    

    The above command will give the below object as output.

{
  "cloudName": "AzureCloud",
  "id": "some_ID,
  "isDefault": true,
  "name": "My Azure Subscription",
  "registeredProviders": [],
  "state": "Enabled",
  "tenantId": "5bd108149c-4cbe-b7c9-bcd05cb035c2",
  "user": {
    "name": "you@domain.com",
    "type": "user"
  }
}
  1. Next step is to create a service principal. Run the below-given command,
    az ad sp create-for-rbac
    

    The above command will produce,

{
  "appId": "19f7b7c1-fc4e-4c8aaf-22fffc23b4c9",
  "displayName": "azure-cli-1900",
  "name": "http://azure-cli-1900",
  "password": "38d82600f2-4e80c5-65192f9bb2d0",
  "tenant": "16f43fe8-17db-476f-b2b3-ba3752a03a33"
}
  1. Finally set environmental variables for Subscription ID so that Serverless CLI can authorize itself.
export azureSubId='<subscriptionId>' # From step 3
export azureServicePrincipalTenantId='<tenant>'
export azureServicePrincipalClientId='<name>'
export azureServicePrincipalPassword='<password>'

#cloudcomputing #Serverless #AWS #AZURE #CloudComputing #ServerlessCLI
#technology #AzureService

Leave a comment

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: