Enable Javascript

Please enable Javascript to view website properly

Toll Free 1800 889 7020

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

Azure: Function As Service Introduction

Serverless Computing

Azure Function As Service Introduction

Code execution modus operandi where server-side logic is created to run on stateless, event-driven, short-lived compute containers that are run entirely by third parties (MS in our case).

Incidentally, computing without a server does not work without a server; instead, it allows a third party to manage and provide your server execution.

The Azure serverless offering from Microsoft Azure is called 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. To ensure that the function remains idempotent is to ascertain that the same input isn’t processed twice. In an asynchronous, highly parallelized environment run 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 necessary state information with our data, if no further processing is required, allowing the work to exit beautifully.

Azure functions in particular have some built-in protective devices that you can use. 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 the 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 from 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 several ways: following example shows how to hop your FAAS URL from POSTMAN:

Copy the FAAS URL and paste it in postman, add a new ‘key’ as ‘Name’ in the ‘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 load 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: Dynamics 365

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
Software Development Team
Need Software Development Team?
captcha
🙌

Thank you!
We will contact soon.

Oops! Something went wrong.

Recent Blogs

Categories

NSS Note
Some of our clients
team