JavaScript Required

We're sorry, but we doesn't work properly without JavaScript enabled.

Looking for an Expert Software Development Team? Take two weeks Trial! Try Now

Azure: Function As Service Introduction

Serverless Computing

Azure Function As Service Introduction

The code execution modus operandi where server side logic is made to run on a stateless, event-driven, short lived compute containers that are fully managed by a third party(in our case MS).

Incidentally, serverless computing doesn’t actually run without servers, instead its actually letting a third party manage and provision your server execution.

The Azure serverless offering from Microsoft Azure is called as Azure Functions.

Some of the basic benefits:

Features

Idempotent

Mathematically a function is idempotent, if it satisfies f(f(x)) = f(x), which means whenever it is applied twice, it gives the same result as if it were applied once. In order to ensure that the function remains idempotent is to ascertain that the same input isn’t processed twice. In an asynchronous, highly parallelized environment ran by short-lived compute containers, we need to implement extra catches to prevent subsequent steps are not impacted by a particular step of execution. To ensure consistency, we need to store the required state information with our data, allowing a function to exit elegantly, if no further processing is required.

Azure functions in particular have some built-in defensive devices that you can make use of. For example, for a storage queue triggered function, a queue message processing will be retired five times in case of failure, after which it will be dumped into a poison-message queue.

Stateless

Azure functions are best examples of stateless protocols, meaning every time it is invoked, it will forget the details of its previous runs.

Asynchronous

These are all event driven and asynchronous: I am sending across a request and am not waiting for a response from the other end. It is thus necessary to use non-blocking, awaiting calls in functions.

Scalability

Serverless computing makes it easy to scale the appliance by provisioning more compute resources as required and deallocating whenever the surge goes down. As a result the developer can now take a break of the fear of failing overflow of user requests, while at the same time descoping resources when the peak time is over.

Execution limitations

Steps to create an azure function

Path:

Click Home → Create a resource → Compute → Function App

Step 1:

Select Subscription: note that all the resources in a given Azure Subscription are billed together

Select a Resource group: a resource group, by definition,is a container of resources that share the same lifecycle, permission and policies.

Function App name: give a proper name, without an ‘_’

Publish as a ‘Code’

Runtime stack: Here you can specify what you wish your source be compiled and exposed as/the runtime you are going to use:

.Net Core/Node.Js/Python/Java/Powershell core

Region: which GEO you are going to use to hoist your FAS

Click Review + Create

Step 2:

Click ‘Create’ to finish the wizard.

Alternately you can switch to ‘Hosting’ tab to validate:

Storage account: implies the under what storage account under given Azure subscription you are creating the FAS.

Operating System: you can implement the service on Linux/Windows

Plan: this is where you can specify how you wish to pay as you run your FAS. The most easy to use one is ‘Consumption’ which ensures ‘pay-as-you-go’.

It will take some time for the Azure app to create and get deployed.

Step 3:

Once deployed, click ‘go to resources’ → Functions (on the left pane) → create new function → select ‘In portal’ → Continue →

For now we are going with WebHook + API → create

Step 4:

Select Functions from left hand pane → On the content pane, you will see the following code:

#r "Newtonsoft.Json" using System.Net; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Primitives; using Newtonsoft.Json; public static async Task<IActionResult> Run(HttpRequest req, ILogger log) { log.LogInformation("C# HTTP trigger function processed a request."); string name = req.Query["name"]; string requestBody = await new StreamReader(req.Body).ReadToEndAsync(); dynamic data = JsonConvert.DeserializeObject(requestBody); name = name ?? data?.name; return name != null ? (ActionResult)new OkObjectResult($"Howdie, {name}, How are you?") : new BadRequestObjectResult("Please pass a name on the query string or in the request body"); }

Test it

You can try firing the function in a number of ways: following example shows hot to hop your FAAS URL from POSMAN:

Copy the FAAS URL and paste it in postman, add a new ‘key’ as ‘Name’ in ‘Params’ tab and do a Post. It will print ‘Howdie %Your name value%’

You can test it in the function window itself by pressing ‘run’

Create a new function

You can choose from palette of available templates:

These apart, there a loads of other templates that can make your code freely be integrated with pointers like IoT, EventHubs, EventGrid, etc.

Example of Service Bus Queue trigger

Here is a small example that can tell you how to communicate between Logic apps with FAAS.

The following example shows a logic app that can post a message to a channel whenever the message is received as a HTTP request.

Further actions: Dynamics365

We can collaborate various integration to third party systems using FAAS and thereby making easy communication between Dynamics 365 implementation to communicate back and forth, depending on the type of communication/interaction to engage. You can select a FAAS to use when you have an ephemeral system that needs a low frequency-high volume/high frequency-low volume record to exchange. You can expose your available entities from D365 to a third party system, by routing it through Logic apps and then using oAuth2 to relinquish security.

Function as service introduction
Ast Note

Some of our clients

team