Follow

Follow
Build an Azure Serverless Function with nodejs
and test locally

Build an Azure Serverless Function with nodejs and test locally

Bawantha Rathnayaka's photo
Bawantha Rathnayaka
ยทOct 15, 2022ยท

2 min read

Play this article

In this article, I will show how to create an azure serverless function with node js and test your function locally. ๐Ÿค—

what is an azure function?

Azure Function is a serverless solution that allows you to write less code, maintain less infrastructure, and save on costs. Instead of worrying about deploying and maintaining servers, the cloud infrastructure provides all the up-to-date resources needed to keep your applications running.

what will we need?

  1. Visual studio code
  2. Azure tools extension - VS Code Extension
  3. Azure function core tools - NPM Package

Steps:

1. Create a function app using vs code extension

first, click the azure tool extension icon in the left sidebar and click + icon on the workspace tab and select create function

Untitled.png

after that, you will get to select a template for your function. today we will create an HTTP trigger function

Recording 2022-10-15 at 12.26.29.gif

you can learn other types of function please refer this link

Your final code will look like this.

code.png

2. Run your function

after that you can test your function locally without an azure account

type npm run start in your vs code terminal and you will get a URL to test your function in your local machine.

image.png

you can test your function in a postman application like that

image.png

Tadaaaa ๐Ÿฅณ your first azure serverless function is up and running.

ย 
Share this