Serverless Development

 

... featuring Microsoft Azure

About Me

1st Career

About Me

2nd Career

About our group

Vendor Neutral

1st Tuesday of the month

(except January 2019: is 2nd Tuesday)

5:30pm - 8:30pm

 

Richmond Heights Community Center

"Dale" Room

 

Free and open to the public!

https://www.meetup.com/stl-serverless/events/254589340/

  • December 4th

    • Serverless Monitoring, Testing & Security

    • Featuring Google Cloud

Coming in 2019

  • Serverless frameworks

  • Special guest speakers

  • Hands-on workshops

  • and...

Starting in January 2019,

we'll meet at Daughtery Offices

Help Wanted!

Looking for a Backup Co-organizer

Avram Peters

Daughtery Business Solutions

Speakers Wanted

Meeting Sponsors Wanted

Tell about your company while we enjoy your refreshments

Daughtery Business Solutions

Other Help Wanted

Overview

  • A very brief review of serverless
  • Introduction to serverless on Azure
  • Development setup
  • Project setup
  • Automating builds & deployment
  • Lab

First, a very brief review...

What is serverless?

Let's start with what it isn't

Serverless does not mean, "No servers"

Serverless computing is the abstraction of servers, infrastructure, and operating systems. When you build serverless apps you don’t need to provision and manage any servers, so you can take your mind off infrastructure concerns. Serverless computing is driven by the reaction to events and triggers happening in near-real-time—in the cloud. As a fully managed service, server management and capacity planning are invisible to the developer and billing is based just on resources consumed or the actual time your code is running.

Microsoft Azure:

https://azure.microsoft.com/en-us/overview/serverless-computing/

Serverless lets you think about servers less.

In summary...

Serverless Providers

Many others

Gartner's 2018 IaaS Magic Quadrant

https://www.bmc.com/blogs/gartner-magic-quadrant-cloud-iaas/

Path to Serverless

Path to Serverless

Bare Metal

Virtual Machines

IaaS

PaaS

CaaS

FaaS

Value Line

Serverless includes...

Storage

Queues

Notifications

API Gateways

Functions

Monitoring & Logging

and much, much more...

Serverless Runtimes

Advantages of Serverless

  • Development simplicity
  • Zero provisioning or management
  • Scale up based on events
  • Scale to zero
  • Highly available
  • Usage-based billing

Scale up based on events

[ { "item": 1} ]

Item(1)

Scale up based on events

[ { "item": 1},

...

{"item" : 3} ]

Item(1)

Item(2)

Item(3)

Scale to Zero

  • Zero or few customers
    • New Project
    • Startup
  • Development 7am - 7pm
  • Periodic loads
    • Evening batch runs
  • Occasional, sporadic loads
    • "Forgot password"
    • CI Build
    • Testing

Highly Available

Usage-based Billing

  • Zero or few customers
    • No charge until customers start using it
  • High loads 7am - 7pm
    • No charge after 7pm
  • Periodic loads
    • No charge until batch job runs
  • Occasional, sporadic loads
    • No charge until load appears

Disadvantages of Serverless

  • Development complexity
  • Testing complexity
  • Deployment complexity
  • Cold start performance

These topics and more will form the basis for future talks

Serverless Architectural Patterns

  • Request-Response
  • Event-Driven

Request-Response

request

trigger

return

response

Http Trigger

Azure Function

f

Event-Driven

event

trigger

Function

Add 1080p video to

storage

Transcode

to 720p

Save to 720p storage

event

trigger

notification hub

Serverless on Microsoft Azure

  • Overview of Azure Services
  • Azure Functions

There are many Azure Services

A few key services you might use in a serverless app

  • Resource groups (billing and deployment)
  • API Management (defining APIs)
  • Function Apps (compute)
  • Logic Apps (visual workflow)
  • Cosmos DB (multi-model database)
  • Cloud storage (file storage)
  • Event Grid (event routing service)
  • Azure Active Directory (identity)
  • Application Insights (monitoring)
  • More...

Azure Functions

  • Getting started
  • Demo

Azure Functions Getting Started

  • Add Resource Group
  • Create Function App
  • Create Function
  • Test Function
  • Demo

Add Resource Group

What's a Resource Group?

resource group - A container that holds related resources for an Azure solution. The resource group can include all the resources for the solution, or only those resources that you want to manage as a group. You decide how you want to allocate resources to resource groups based on what makes the most sense for your organization.

Example Resource Group

Microservice

Function 1

Function 3

Function 4

Function 5

Storage

Queues

Function 2

Function App

Create Function App

Create Function App

Configure Function App

Add Function

Add Function

The Generated Function

RandomNumber Function

module.exports = async function (context, req) {
    context.log('JavaScript HTTP trigger function processed a request.');

    context.log.info({'req.query': req.query})
    context.log.info({'req.body': req.body})

    const min = req.query.min || (req.body && req.body.min) ? parseInt((req.query.min || req.body.min)) : 1
    const max = req.query.max || (req.body && req.body.max) ? parseInt((req.query.max || req.body.max)) : 100
    const randomVal = Math.floor(Math.random() * (max - min + 1) + min)

    const result = {
        min: min,
        max: max,
        randomVal: randomVal 
    }

    context.res = {
        status: 200, // Defaults to 200, but included here for illustration
        body: result
    }
}

POST Test

GET Test

Postman Testing

First, click "Get Function URL" to copy URL

Postman GET Test

Postman POST Test

Development setup

  • Command Line Interface
    • Azure CLI
    • Azure Core Tools version 2.x
    • .NET Core
  • IDE Setup

Azure CLI setup

  • http://bit.ly/install_azure_cli

Install on Windows

Install on Mac

Install Core Tools

Install .NET Core

CLI Examples

# list versions
az --version

# login
az login   # this opens a browser
az login -u <username> -p <password>

# Add a resource group
# https://docs.microsoft.com/en-us/azure/azure-resource-manager/cli-azure-resource-manager
az group create --name MyResourceGroup --location "South Central US"


Creating a function using CLI

https://docs.microsoft.com/en-us/azure/azure-functions/functions-create-first-azure-function-azure-cli

IDE Setup

  • VS Code
    • By far the most feature rich
    • Great integration for creating, packaging and deploying Azure Functions
  • JetBrains IDEA - Azure Toolkit for IntelliJ
    • Minimal
    • Not useful for Azure Functions
  • Eclipse - Azure Toolkit for Eclipse
    • I didn't test this

VS Code Demo

Project setup

Automating builds & Deployments

Azure Functions

Gradle Plugin Demo

Summary

  • Microsoft Azure is a very good competitor to AWS
  • However, it's a bit behind AWS, though catching up
  • Tooling is still very weak, except VS Code is excellent
  • Definitely worth a look if you're wanting to do serverless 

Resources

  • https://azure.microsoft.com
  • https://azure.microsoft.com/en-us/overview/serverless-computing/
  • https://docs.microsoft.com/en-us/azure/azure-functions/functions-create-first-azure-function-azure-cli
  • Me
    • jackfrosch@stlserverless.com
    • LinkedIn: in/jackfrosch
    • Twitter @jackfrosch

Next Meeting:

Monitoring, Security, & Testing serverless

featuring Google Cloud Platform

Questions?

Lab

Serverless Development featuring Azure

By Jack Frosch

Serverless Development featuring Azure

  • 1,627