Create and Test a JavaScript Node.js Serverless Function on Azure

jeremylikness

Jeremy Likness ⚡️

Posted on September 13, 2019

Create and Test a JavaScript Node.js Serverless Function on Azure

This article is part of #ServerlessSeptember. You'll find other helpful articles, detailed tutorials, and videos in this all-things-Serverless content collection. New articles are published every day — that's right, every day — from community members and cloud advocates in the month of September.

Find out more about how Microsoft Azure enables your Serverless functions at https://docs.microsoft.com/azure/azure-functions/.

The Azure Functions app serves as the host for serverless functions. It is a unit of deployment and scale that defines features for your app such as your language and runtime, security settings, and root URL endpoint.

Create an Azure Functions App

This video is designed for anyone new to Azure Functions, even if you're not migrating from AWS Lambda. It walks through how to create the host, write simple code using JavaScript and Node.js, and test the function from your browser and the command line.

You can view the source code for the sample app and deploy the migrated code directly to Azure with a single-click in the “AWSMigration” GitHub repository.

GitHub logo JeremyLikness / AWSMigration

Migrate from AWS Lambda to Azure Functions

Move AWS Lambda to Azure Functions

This is the source code for the "Moving from Lambda to Azure Functions" video series that demonstrates how to migrate from AWS Lambda to Azure Functions.

🎦 Watch the video series (YouTube playlist)

Quick Start

Free Azure Account Get your Free Azure Account

You can get started quickly with the migrated function. Simply click or tap the "Deploy to Azure" button. Be sure to enter a unique prefix (for example, use your initials or add a sequence). After the deployment is done, you can access and test the function.

Deploy to Azure

To enable the cache, navigate to the storage account after it is created. Click on Tables under Table service then add a table named primes.

The Code

This repository contains code for all related projects.

Source ("Pure") Function

The function itself determines whether a number passed is prime or not. The pure function is available in src\isItAPrime.js

In the next article, we'll explore how to integrate the primes code from our AWS Lambda function, including setting up a cache using Azure Table Storage.

Resources

  1. Create your free Azure account
  2. JavaScript Developer Reference for Azure Functions
  3. How to Use Azure Table Storage from Node.js
💖 💪 🙅 🚩
jeremylikness
Jeremy Likness ⚡️

Posted on September 13, 2019

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related