Azure Serverless Real-Time Application and Its Challenges

DZone 's Guide to

Azure Serverless Real-Time Application and Its Challenges

Learn how you can imlement an order processing scenario with Azure serverless components and some of the challenges you might face.

· Cloud Zone ·
Free Resource

Image title

What is Serverless?

Serverless computing is the abstraction of servers, infrastructure, and operating systems. When you build serverless apps you do not need to provision and manage any servers, so you can take your mind off infrastructure concerns. Azure offers a lot of serverless services for organizations to build business orchestrations solving critical operations.

This blog takes up for discussion, one such Order Processing orchestration in an E-commerce domain. Further, it analyses the challenges in managing and monitoring that serverless application and how Serverless360 turns out to be a solution.

Order Processing Azure Serverless Application

Northwind, an eCommerce company, needs to process the orders placed by its customers. Here are the business requirements to be achieved in the serverless orchestration which solves a specific part of the Order Processing application to manage orders for books:

  1. Filter orders for "Book" and execute
  2. Segregate orders for hard copy and soft copy
  3. Retrieve the book price from the Database
  4. Generate Invoice
  5. Notify Customer on order confirmation

Image title

Below is the order processing system built using Azure Serverless services

  1. Service Bus Queues and Topics to handle order details as messages
  2. Function App to compute order filtering and invoice
  3. Storage Account Table to store pricing information
  4. Logic App to define the entire workflow

Below is the workflow:

  1. Customer places an order in the eCommerce website
  2. The website submits a new order message to the Service Bus Queue
  3. Azure Function filters all the orders for the focused item (Books) to push them to a Topic
  4. The other orders will be sent to a Service Bus Queue
  5. The Book order will be further be segregated based on order copy type using Topic Subscription Rules
  6. The Azure function will retrieve the price of the ordered Book from the storage table and compute the order price
  7. An invoice will be created based on the computed price returned by the function
  8. The notification will be sent to the customer with Product details and invoice through Microsoft Outlook

Implementation of Business Orchestration in The Azure Portal

In this orchestration, Azure serverless applications like Azure Logic App, Functions, Service Bus, Storage tables were used. Let’s see how to provision these entities in the Azure portal.

Create the Service Bus Queue — orderprocessingqueue

A prerequisite to creating a Service Bus Queue or Topic is a Service Bus namespace. Create a new namespace with a name unique across Azure

To create the Namespace in the Azure portal:

  • Click on the + Create a resource, select Integration and then Service Bus.

Image title

  • Enter a name for the namespace which should be unique across Azure. Select Pricing tier, Subscription, Resource Group, and Location. Click Create.

Image title

  • Now that the Service Bus Namespace is created, inside the Namespace, click + Queue button to create a Queue that handles the order message.
  • Enter the details required to create the queue and click Create.

Image title

  • Orderprocessingqueue is now created. Similarly, the queue with the name product-queue needs to be created to process the order details of products other than the book.

Create the Topic and Topic Subscription

This Topic will have two Subscriptions to filter messages based on labels — Hard Copy or Soft Copy. These Subscriptions will contain the order messages of the books based on the respective copy.

To create the Topic and Topic Subscription

  1. Inside the Service Bus Namespace created, Click + Topic button to create the topic
  2. Here the name of the topic will be orderprocessingtopic. Inside the topic, click + Subscription to create the Subscription. In this scenario, two topic subscriptions are needed.

Image title

Create the Functions — ordervalidator and priceretriever

This function will take care of segregating the messages from the orderprocessingqueue queue. if it is a book, the message is submitted to Topic orderprocessingtopic. In case of all other products, the message is pushed into productqueue. There is another function called priceretriever, which retrieves the price of the selected book and computes the final price to send invoice and notification.

To create the Function:

  • Click on the + Create a resource, select Compute, and then Function Apps.
  • Give the details as required and click Create. Here in our scenario, the name of this function will be ordervalidator.
  • Follow the same steps to create another function named priceretriever

Image title

  • Copy and paste the below code to the functions.

Code for codevalidator

using System.Net;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Primitives;
using Newtonsoft.Json;
public static async Task<bool> Run(HttpRequest req, ILogger log)
string requestBody = await new StreamReader(req.Body).ReadToEndAsync();
dynamic data = JsonConvert.DeserializeObject(requestBody);
string label = data.Label;
return label.Equals("Book")?true:false;

Code for priceretriever

using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Extensions.Http;
using Microsoft.Azure.WebJobs.Host;
using Microsoft.WindowsAzure.Storage;
using Microsoft.WindowsAzure.Storage.Table;
using Newtonsoft.Json;
using System;
using System.IO;
namespace ItemPriceFunction
public static class Function1
public static IActionResult Run([HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)]HttpRequest req, TraceWriter log)
log.Info("C# HTTP trigger function processed a request.");
string requestBody = new StreamReader(req.Body).ReadToEnd();
dynamic data = JsonConvert.DeserializeObject(requestBody);
string name = data.Properties.BookName;
// Retrieve the storage account from the connection string.
CloudStorageAccount storageAccount = CloudStorageAccount.Parse("Connection String");
// Create the table client.
CloudTableClient tableClient = storageAccount.CreateCloudTableClient();
// Retrieve a reference to the table.
CloudTable table = tableClient.GetTableReference("orderprocessingtable");
TableOperation insertOperation = TableOperation.Retrieve("HarryPotter","01" );
var tableQueryResult = table.ExecuteAsync(insertOperation).GetAwaiter().GetResult();
string price="";
foreach (var variable in ((DynamicTableEntity)tableQueryResult.Result).Properties.Values)
return new OkObjectResult(price);

Create the Storage Table – orderprocessingtable

This Storage Table stores the price of the products in the catalog. The function priceretriever picks up the price of the products in the order and computes the order value.

To create the Storage Table:

  • A storage account should be created. To create the storage account, Search Storage Account on search and Inside the storage account, click Add.
  • Enter the details as required. For our scenario, the name the storage account will be orderprocessingsa.

Image title

  • To create a storage table, click the storage account orderprocessingsa and select Tables -> + Table to create the table. For our scenario, the name of the storage table will be orderprocessingtable.
  • To insert the value inside the table, click Storage Explorer and select Tables ->orderprocessingtable and click +Add to the data.

Image title

Create the Logic app – OrderProcessiongLogicApp

This Logic app will orchestrate those above-created resources to process the order. This will process the order from the application and validate it and create the notification.

To create the Logic app:

  1. Search Logic Apps in the Azure portal
  2. Inside the Logic Apps, Click Add.
  3. Enter the details as required. For our scenario, the name the Logic app will be OrderProcessingLogicApp.

Orchestration with Logic App

Image title


  1. Logic App is designed with a Service Bus trigger on receiving a new order message
  2. The Azure Function segregates the order messages based on the label
  3. The condition checks for the book product and puts the message into Service Bus Topic named orderprocessingtopic if it is a book.
  4. Orders for all other products are pushed to the Service Bus Queue name productqueue.
  5. Subsequently, the function priceretriever gets triggered and retrieves the price from the Storage Table.
  6. The processed order information will be sent to invoice generation tool and the customer gets notified through Microsoft outlook on the order confirmation.

This whole process happens in these 4 stages:

  1. Order details processing:
  2. Whenever a new order message is received in the orderprocessingqueue, the Logic app will be automatically triggered to process the order message. When a new order message received in the orderprocessingqueue it will trigger the Function action. The Function ordervalidator segregates the orders based on the Label of the message. This will return the Boolean value "true" if the product is a book or "false" if not. The Condition will segregate and send the order message to the respective entities based on the return value of the ordervalidator Function. Below will be the orchestration till the condition.

    Image title

  3. Segregation of orders based on their type:
  4. When the above condition fails, The order message will be sent to productqueue and if that condition passes, It will send the message to the orderprocessingtopic. Here is the orchestration when the condition is passed.

    Image title

    When the Condition fails, the order message will be sent to productqueue,

    Image title

  5. Book Type Validation:
  6. Here when a Segregation condition passes, it will send the order message to topic orderprocessingtopic with the subscriptions HardCopy and SoftCopy.

    Image title

    When the order message is received in any of the topic subscriptions, it will trigger the priceretriever function. This Function will retrieve the price from the Storage Table based on the Book name. Below will be the orchestration part that invokes and handles the priceretriever.

    Image title

Invoice and Notification:

  • For Invoice and Notification, there are a lot of Logic App connectors like Stripe and FreshBooks that can be used.
  • Notification channels like Outlook, Gmail etc., are also available as Logic App Connectors to send invoice notification to the customer.

Challenges We Might Face with Azure Entities

This orchestration has simplified the order processing of the products, but users might have some challenges while managing and monitoring these resources that participate in the above orchestration. Here are the challenges that the user might face:

  1. Processing Dead Lettered messages on orderprocessingtopic and productqueue
  2. Defining topic subscription rules in orderprocessingtopic to filter out the order messages into Hard copy or Soft Copy subscription
  3. Monitoring the health status of the entities to generate a consolidated report every hour
  4. Monitoring the entities for any violation against configuration on their defined properties
  5. Monitoring the entities for any error
  6. Automating dead lettered message processing

There could be more challenges you may face in implementing cloud-native integration solutions.


In this blog, we discussed and arrived at a solution for the questions below:

  • How to implement the order processing scenario using Azure serverless components?
  • The challenges that the user will encounter in managing and monitoring this application in the Azure portal?

azure, azure functions, azure service bus, logic apps

Published at DZone with permission of surya venkat . See the original article here.

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}