Posts

Showing posts with the label Azure

Azure Durable Functions #4 – Orchestrator Constraints

There are some constraints when adding code in to the orchestrator code. It is because of the replay behavior in orchestrator. When you adding code in to Orchestrator make sure you follow the following rules. (Not hard to follow  :) ) 1. Orchestrator should be deterministic This means we should not add following type of code in to it. Getting current date time : This is because when it replays value will be changed Generating random numbers or Guids : This is because when it replays value will be changed Getting values from a DB : This is because when replayed values in the DB could be changed If you want to have such values in the orchestrator you could Pass it to orchestrator in the parameter when calling it Create a separate function activity to get the value and call it in the orchestrator 2. Orchestrator should be non blocking No I/O calls or Thread.sleep should be used 3. Orchestrator should never initiate any async operation This is because orchest...

Azure Durable Functions #3 – Patterns : Fan In Fan Out

Image
Fan In Fan out is one of the main usages of Azure Durable Functions Fan-out/fan-in refers to the pattern of executing multiple functions in parallel, and then waiting for all to finish. Often some aggregation work is done on results returned from the functions. Let’s see how to achieve this pattern using Azure Durable Functions. If this is the first time you creating a durable function please follow my post Here , it will have the steps on how to create a durable function and activity functions. Problem to solve: You have to generate a invoice for a customer, which should include around 20 orders. So First you need to calculate the order amounts for each order then generate the complete invoice. let’s see how to solve this using Azure durable functions Fan In Fan Out Patten Step 1: Add two Activity Functions for orderCalculation & InvoiceGenerations public class OrderCalculationActivity { [FunctionName("OrderCalculationActivity")] ...

Azure Durable Function #2–Patterns : Function Chaining

Image
let’s discuss some common implementations of Azure Durable Function. If you want to learn what Azure Durable functions are please read my Previous Article Azure Durable Functions #1 Introduction " Function chaining refers to the pattern of executing a sequence of functions in a particular order. Often the output of one function needs to be applied to the input of another function” Problem to solve : You have a workflow with 3 steps you need to pass output of the previous step to the next steps. Lets solve this with Azure Durable Functions. Step 1: Create a HttpTrigger Function This will be the starter function which will call the orchestrator function. Step 2: Add Durable Function Nuget in to your Project Microsoft.Azure.WebJobs.Extensions.DurableTask Step 3: Add a new Function with Trigger Type – Durable Function Orchestrator Once you add the function you would see it comes with set of code for you. [FunctionName("Orchestrator")] ...

Azure Durable Functions #1 Introduction

Image
Azure Durable Functions are extension of Azure functions which let you write stateful functions in a serverless environment. Let’s discuss some key points about durable functions in this post. Why Durable Functions? Azure Durable functions came in to picture to solve some scenarios which was difficult to solve using regular azure functions. Issue 1 : Solving Fan in Fan Out Pattern Suppose you have an option in your application where user can select a particular customer and select to generate the invoice for a particular period and send customer and email. Customer would have around 50-75 orders and orders will have custom logics to handle based on order type. So you need to perform logic and calculate the order amount then sum the total amount. So basically you need to achieve following scenario. Solving such a pattern is not that easy with regular function. Issue 2 : Exception Handling in Function chain. You have a function chain. where you use azure queue to pass...

Azure Function Binding Declaration Types

If you are familiar with azure function you may already know there are many types of binding. If you are new for azure function bindings you can read more details here . When adding an output binding for your function code there are two ways of doing it. 1. Declarative Binding 2. Imperative Binding Declarative Binding Suppose we have a CosmosDB output Binding. In Declarative Binding we can specify the binding details in the Run method parameter. This is the most common way most of us using public static class WriteOneDoc { [FunctionName("WriteOneDoc")] public static void Run ( [QueueTrigger("todoqueueforwrite")] string queueMessage, [CosmosDB( databaseName: "ToDoItems", collectionName: "Items", ConnectionStringSetting = "CosmosDBConnection")] out dynamic document, ILogger log) { document = new { De...

Store your Event streams in Azure Event Hub

Image
Scenario : Suppose you have a CRM system where you manage all your Customer relationships. There will be 1000 of users connected in this system. You need to have a activity feed panel which will be visible in user’s home page where he can see the activities happening in their company. Ex: New appointment is added with a Customer who I am working with New Document has been added So you need to capture all the events triggering in your CRM system , process them and store to show in user’s activity feed pane. Problem to Solve: There will be thousands of events happening at a second so we need a proper messaging service to store the events which will auto scale with the events load and which enables batch processing and parallel processing. Solution: There are many storage options in azure which could solve the problem we have on hand. Picking what suits best is the tricky part. Lets compare few options available a pick the best. 1. Azure Service Bus Azure Service Bus mainly serving for en...

Azure Search #2–Creating Search Service

Image
  Let’s see how we can create a azure search service and how we can manage and scale it. Step 1: Select Search service from add new Log in to Azure portal Click New –> Web & Mobile Under that select Azure Search . Step 2: Give a name & select pricing tier after selecting the Azure Search you will get the following blade. enter the name you need to use for the search service. then you have to select the pricing tier, by clicking on Pricing tier option in the blade. when selecting pricing tier you need to identify your application requirements and select it. Anyway it is always better you start with a lower tier and scale it up when the application need varies. Azure provides you the facility of scaling up or down the tier based on you need. Then click create search service will be created for you. Pricing Tiers mainly contains 3 categories. 1.Free multi-tenant shared service 2.Basic provides dedicated computing resources for production workloads at ...

Azure Search #3 - Azure Search Index

  When you want to have Azure Search integrated with your application data first thing you have to do is creating a Azure Search index under your search service. One Search service can contain multiple indexes. An index is a persistent store of documents and other constructs used by an Azure Search service. A document is a single unit searchable data in your index. Index is like a table in SQL database. But there are some differences. When creating a index a given data field has set of attributes and a field type. Lets first look at what are the possible data types we can store in Azure search index.   Type Description Edm.String Text that can optionally be tokenized for full-text search Collection(Edm.String) A list of strings that can optionally be tokenized for full-text search Edm.Boolean Contains true/false values Edm.Int32 32-bit integer values Edm.Int64 64-bit integer values Edm.Double Double-precision numeric data Edm.DateTimeOff...

Azure Push Notification with Web API

Image
Before explaining how to to push notification to hub using Web API, let us see what is azure push notifications hub provides. Azure Notification Hubs provide an easy-to-use, multiplatform, scaled-out push infrastructure that enables you to send mobile push notifications from any backend (in the cloud or on-premises) to any mobile platform. With Notification Hubs you can easily send cross-platform, personalized push notifications, abstracting the details of the different platform notification systems (PNS). With a single API call, you can target individual users or entire audience segments containing millions of users, across all their devices. Step 1 : Create Push Notification Hub Log on to the Azure Portal , and then click +NEW at the top left of the screen. Click on New , then Web + Mobile . Scroll down if necessary and click Notification Hub . Add All the details and create the hub Step 2 : Add Keys After creating the hub next you need to add keys...

Azure Search #1

Image
  I will be writing a series of post on azure search step by step. Each post I will be explaining different areas in azure search. As this is the first post I will be explaining what azure search is and what are the applications of azure search. What is Azure Search ? A search-as-a-service solution allowing developers to incorporate great search experiences into applications without managing infrastructure or needing to become search experts. If I elaborate the definition bit more,Azure search provides lot of services, which allows developer to add high search experience to their end users, without been a search expert. In other words developer has to call some API calls to azure search all the search algorithms will be executed by azure search service and result will be returned. this makes developer life easier and giving end user a high search experience. Why we need search? Search box in an application has been the main entry point of most of the applications. If we una...