This blog will take you through the Azure Serverless Application Platform and provide you with a detailed understanding of the concepts of Serverless computing and real-world use cases to enhance your underlying architecture.
The picture represents the advancement from IaaS to PaaS platforms. Everything around these days and trend is to develop the product, time to market, the speed of innovation and also differentiation against some of the competitors is most important. This leads the companies to invest more in PaaS instead of IaaS or more moving towards PaaS in terms of cloud adoption and this is what is termed “Digital Transformation” term.
Since 2000, a significant percentage of fortune 500 companies are gone due to digital marketing. Companies are focusing more on digital strategies across the certain area like empowering employees, optimizing operations, and also support services which transform the product into the business representation to engage more with the customers.
It is good to see that companies like Uber, Airbnb and more brought disruption to businesses like taxi or hotels and stuff which used to be an isolated market which is completely opened, because of digitalization.
What is Serverless?
The word “Serverless” means the abstraction of servers. It does not mean the servers are gone. It is more abstracted from the platform services. Here you do not have to manage the servers it is done by service providers like Microsoft, Azure. Serverless is an event-driven and instant scaling platform. If you need more resources you can consume as much as you want.
It is a consumption billing based concept where you pay only for what you use. Let us say there is a socket in your wall through which you consume power and you pay only for the power you used. That is the kind of commodity this platform does to the users. If you look at the IaaS model it is like, if you reserve a room in a hotel even if you do not occupy you should pay for it. So unlike IaaS in Serverless, you pay only for what you use.
Azure Serverless Application Platform
The Serverless Application platform comprises three main entities, which are;
- Functions
- Logic Apps
- Event Grid
It means you can do Computing, Flows, and Eventing. You can run your code inside azure without setting up any type of server and you can set up some flows and triggers which will do multiple actions. You can even setup Event Grid which is introduced very recently where you can set up a push type of model.
For storage, you can use SQL Database, NoSQL Database, Cosmos DB and furthermore. You can even set up security and access control for your database. Also, this platform is suitable for IoT Solutions, Analytics, Artificial Intelligence and more. You can build some smart applications using these features. You can build your solution through visual studio or visual code or use your browser where each has its own set of productivity and capability.
Azure Functions
It makes available all the infrastructure and serverless management capabilities for running the Function application. Azure Functions are built with flexible deployment option, you can develop your code using multiple languages like C#, Node.js, Java, Python, Batch and more. You can expose these functions as API endpoint and functions easily integrate with services like Logic Apps to do a sequence of events. If you have a larger workload then the Durable functions can be a good option and you can also change some functions using a durable function. It is highly scalable and you can code from your Azure portal itself.
Azure Logic Apps
Logic Apps allows you to orchestrate the workflows. It is still growing in terms of its capabilities and features. You have interesting features in Logic Apps like JSON mapping and batching. You can create a logic app in a very simple way by provisioning a template in the browser and create a trigger with a chain of actions. Hence it is trigger based or event based and you can even have a hybrid scenario where the logic apps will be talking to your on-premises through data gateway on your system.
On the other hand, Logic Apps is totally about connectivity so it offers tons and tons of connectors and it also allows you to build your custom connectors.
Azure Event Grid
It is one of the latest entrants in the Serverless application platform. It is kind of centrally managed intelligent routing type of capability within Azure where you have events from publishers which can be of multiple sources. This platform contains a lot of event handlers as well. Event Grids have built-in support for customized events and it is highly reliable. It allows you to send custom events through postfix type of rules enabling you to have multiple event handlers like Azure Functions, Logic Apps, Azure Automation and WebHooks. It is used to build event-based architecture.
Considerations
There are some considerations in this platform if you want to orchestrate a type of solution where you want to bring in Functions, Logic apps, Event Grids. The following factors are
- Design
- Deployment
- Support
- Pricing
Design
In design, you need to think about security, workload, requirements you need to meet and pricing. Here the personas are determined by having a look at the design and determine who is going to use it. If it is related to business then you must give more importance to the flow, whereas if it is of transaction type or when you need more control then Logic Apps should be considered.
Deployment
In deployment, you must consider automated testing followed by CI/CD.
Support
You need to consider Monitoring, process, and SLA.
Pricing
Better understanding on pricing is very important for considering Serverless application platform for your use. Let us see what are all the workloads and their pricing for Functions, Logic Apps, and Event Grids.
Plan
All three categories have the consumption plan. In addition, Azure Function alone has App service plan.
Price/Unit of measure
You pay only for what you have consumed.
For more detail about pricing you can check the below links:
Scenarios where Serverless application platform can be considered
Smart Parking solutions
Let us consider a real-time example of collecting a parking receipt where the submitted receipt would go to Microsoft Flow and gets stored in Azure Blob Storage in the next phase, when raised as an event from Blob Storage it would reach Event Grid and gets pushed to function, from where it is sent to Computer Vision API to do Optical character recognition and finally gets transmitted to Service Bus Queue.
Business Process
Here is a business scenario where you want to resize your images in an online photo book. Here the uploaded photo would end up in a Blob storage which would eventually raise an event and they would be handled by a function where the image would be cropped to fit the desired space.
Demo: Photo resizing
The Agenda of the demo is to upload a picture of a dog and have it resized correctly.
To upload pictures, a function is created which will first trace the location of the files and upload them to a blob, which results in an event for creating the blob. This event is captured or reported in an Event Grid from where it is notified to another function that resizes the image.
The event raised will be represented as follows:
RAW BODY
"topic": "/subscriptions/0bf156ac-9aa8-4597-bb2a-a845afe01415/resourceGroupsiRG_MiddiewareFriday/provicers/Microso=t.Storage/s7orageAccounts/imagestoreaccoLne, "subject": "AlobServices/default/containers/images/blobs/BizTalk360Run.jpg", "eventType": IMicrosoft.S:orage.BlobCreated", "eventTime": '2018-02-11T15:43:27.2672993Z", "id": "5b465a03-001e-0026-774F-a348a0057dc8", "data": { "api": "Putblob", "clientRequestld": "4cfa726a-0f42-11e8-b766-07de12ed6b96", "requestld": "5b465a03-001e-0026-774f-a34820000000", "eTag": "0x8D57166316DC2E1", "contertType": "image/fpeg", "contertLength": 511749, "blobType": "BlockBlob", "ur1": "https://imagestorea:count.blob.core.windows.ne:/images/BizTalk360Run.fpg" "sequercer": "000000000000037000000000008BEBD3", "storageDiagnostics": { "batchld": "54a982cc-897f-4224-b202-98f9O110ce30" } }, "dataVersion": "", "metadataVersion": "1"
The function performs the operation of resizing images. Here we can create a function out of the templates in C# which response to Event Grid. This function will extract the URL out of the event data. The function specified would be as follows,
This Function downloads the image and resize it to the instructions in the code and creates a new blob image in the thumbnail container.
You can also raise an event when an image is deleted from the blob. This event can be subscribed by a Logic App which can then initiate a workflow to send an email notification about the image deleted activity.
Cost consideration for the demo scenario
These are the cost estimation for the Azure Functions and Event Grids for their executions and operations.
As Event Grid is a concern the workload of a million pictures per month, here the Event Grid produces 1000000 published events, delivery attempt and advanced matches. In advanced matches, they can be used to consider the match pattern about the container and we also have a monthly grant of hundred thousand operations that amount to (2.9 million operations * 0.506) producing a total monthly cost of 1.5 Euro.
In Azure function, there will be 1000000 executions with 1-second execution duration followed by resource consumption of 1000000 seconds in total. This translates to e 500,000 GigaBytes approx. with monthly free grant and billable consumption to be 400,000 and 100,000 GigaBytes respectively. Finally, the resource consumption price and total monthly cost would be 1.4 Euro approx at the rate of 0.000014 euro per GB
Now if we look at the Total Cost of Ownership for Azure storage it would be as depicted in the below picture. The Standard connector would be used to trigger an action for the notification. Hence the total cost would be 1.28 Euro per month and the Total Cost of Ownership would be 6 Euros.
Challenges in leveraging the Serverless application platform
Cost of implementation
Even though your total cost ownership and solution which you are building is small, there are other things that could impact your cost. In the case of cost of implementation Workload, Pricing and Support is the most challenging part followed by regulation and security.
Maturity of the service
Now a lot of services are GA, but some of the capabilities may be connectors are in the preview. They might not work as expected. You also need to think about integration with other cloud services and Enterprise features.
You can also watch the video of this session Azure Serverless Application Platform here.