Five Life Lessons from Plant Parenthood

My school teachers must have hated me. I was nearly impossible to teach if I couldn’t appreciate the practical value of what I was learning. For subjects like chemistry and physics, this was simple…

Smartphone

独家优惠奖金 100% 高达 1 BTC + 180 免费旋转




Deploying your first serverless program in less than 10 minutes

Serverless computing is a cloud computing execution model in which the cloud provider 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 There are several use cases where Serverless Computing adds the advantage in terms of time to delivery and operational costs. Amazon AWS Lambda, Google Cloud Functions are the popular provides in the market today.

Choosing the cloud provider is upto you, for example if you are already in AWS ecosystem and using services like DynamoDB/ EC2 / Pub Sub then if make sense to use AWS Lambda. In this post i am using Google Cloud Functions to write my Hello World Serverless program.

gcloud is command-line interface tool which makes your life easy for creating/ updating/ deploying the Google Cloud services like AppEngine/ Datastore/ Cloud Functions etc,

Now login to your Google Cloud account by typing command gcloud auth login this will take you to the browser where you can login with your Google Cloud account.

Once the Oauth process done, type the command gcloud init this will take you through the process to create and setup your Google Cloud Project. It looks something like below

Currently Google Cloud Functions are in beta and supports javascript + NodeJS platform only. So in this post we are going to create a nodeJS function and deploy it into Google Cloud Functions. First create a folder and do npm init there (You can leave all npm defaults)

Now create a file index.js and put your first function

Into the index.js file add the following content

You are now ready with your cloud function, The only thing the above function doing is sending Hello World text in response.

You need to create a cloud storage bucket before deploying your first cloud function. You can do it by running the following command

Note: This is one time task, you can reuse the same bucket for uploading multiple functions. Now the last step for us to do is deploying our function to Google Cloud Functions. By running the following command you can deploy your function to Google Cloud Functions

This will deploy your local function into Google Cloud Functions, on a successful deployment you will see logs some thing like following

Add a comment

Related posts:

Tired of taking notes? Why not do something instead.

Life is full of distractions. It seems that everyone is always trying to multitask, which has led to a severe lack of ability to focus. In the college environment, distractions have a big impact on…

Week 11 Draft Kings Plays

Good Morning! Happy Saturday! We are coming off a much better week than the week before last. I didn’t cash in with tournaments, but I did win 100 percent of my cash games, so still a great week. I…

What Causes a Rolling Blackout? Common Triggers and Factors That Contribute to Energy Scarcity

Rolling blackouts are temporary, planned power outages that occur when demand for electricity exceeds supply. Groups of customers are cut off from the grid to balance supply and demand, with each…