Building Serverless applications with Azure Functions

Speaker: Andrew Westgarth

blogs.msdn.microsoft.com/appserviceteam

Functions is a service event based experience to accelerate you development. Before cloud it was all up to you, your hardware, your VMs, etc. You have to pre-plan, procurement would take years. When you maxed out the capacity, what do you do? What happens when the server goes down? How often should I back up? Lots of decisions for you.

Then came IaaS but a big company is managing it for you. Questions like how many servers you need is inconsequential. A number of decisions went away.

Is it PaaS time? You have more questions. Which packages do I need? What is this going to cost me? Who is monitoring my app?

The new kid on the block is Serverless which gets rid of more questions because Azure takes care of it.

Serverless is an abstraction of servers driven by events. There are still servers below it but you don’t have to manage them. You just deploy your code and it runs, no administration. Serverless scales incredibly quick. Fast to get started with reduced DevOps, ease of scale with focus on business logic.

Azure Functions is all about processing events with Serverless code. You as devs can compose your app quickly and easily. Develop your functions in C#, Python in preview, Node.js, F#, PHP, etc. No barrier in what language you work in. You can schedule event-driven tasks. Functions are scaled based on demand. Easily integrate in Logic Apps. Compiles at save time.

Hello World HTTP Trigger

  1. In Market under Compute, Functions app
  2. IDE environment:
    1. Functions on the left-hand side, can have multiple functions
    2. Expose the Functions URL and the function is available immediately
    3. Code window
    4. Project view on the right-hand side
    5. Test runner
    6. Keys
  3. Write code, test, save and run.
  4. Integration, Management and Monitor capabilities.

Azure Functions architecture

Build on top of App Service and WebJobs SDK.

Timer example

Variety of templates in the UI to get started quickly. Sample apps, experimental templates.

  1. Timer trigger in C#
  2. Function already started
  3. Script change takes effect immediately
  4. Save and run

Abstraction

Serverless compute takes away the compute. Bindings abstract away the service integration.

Function Programming Model

Function is a single unit of work that is run again and again. Can be trigger by event. Executed based on the trigger that Is assigned, timer, HTTP manually. Functions have input and outputs. There are bindings like authLevel, name, type, direction. At the guts of it is the code that devs should be focusing on.

Chaining functions with queue

With publisher-consumer pattern.

  1. New function Publisher in Queue with name
  2. Integrate
    1. Trigger HTTP
    2. Output binding is Azure Storage Queue
  3. Write code.
  4. Create consumer, new function Consumer of type QueueTrigger
  5. Function started, message on the queue, go to consumer and run

This is an example of how to daisy chain, with HTTP or chaining functions to other events. Pubsub model with only 2 script files. Able to be productive really fast inside the tooling.

Scaling

What happens when the service becomes powerful and needs to run a lot to workload? How do we deal with sudden bursts of requests? App Service is deployed in every data center acros the globe and offers high scale, with dedicated App Service plan where you pay for VMs but you are responsible on the scale and the new model that comes with Serverless where you pay on consumption basis, you pay on number of executions and the platform takes care of the scaling for you.

If you have an Azure subscription you get 1 million execution and 400 00 GB-s per month included for free.

Serverless patterns with Azure Functions

  • Timer based processing
  • Azure service event processing
  • Serverless web app architecture
  • Real-time stream processing: IoT, smart watches – get the data into Stream Analytics, transform, store.
  • Real-time bot messaging: use Cortana Analytics to answer questions sent to chatbots
  • Serverless mobile backends
  • SaaS event processing

Integrating with third-parties

  • Manual trigger
  • Input is external file, reading a file store from a third party
  • Take the document and put it in a Blob Storage

HowTo

  1. External File binding (still in Preview), select and configure external connection.
  2. Output to Blob Storage.

Coming soon: Azure Functions running on premise in a private cloud.

Developer experience: write Azure Functions in VS2015 (in Preview), soon also in VS2017.

Get started

  • functions.azure.com
  • tryappservice.azure.com

You don’t have to hand over a credit card.

Advertisements