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 changedGenerating random numbers or Guids : This is because when it replays value will be changedGetting 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 itCreate 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 orchestrator runs on a single thread, It c…

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

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

publicclassOrderCalculationActivity { [FunctionName("OrderCalculationActivity")]publicstaticdoubleCalCulateOrderAm…

Azure Durable Function #2–Patterns : Function Chaining

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

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")]publicstaticasync Task<List<string>…

Azure Durable Functions #1 Introduction

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 out put of a one…

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 Binding2. Imperative Binding
Declarative BindingSuppose 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
publicstaticclassWriteOneDoc { [FunctionName("WriteOneDoc")]publicstaticvoidRun( [QueueTrigger("todoqueueforwrite")]string queueMessage, [CosmosDB( databaseName: "ToDoItems", collectionName: "Items", ConnectionStringSetting = "CosmosDBConnection")]outdynamic document, ILogger log) { document = new { Description = queueMessage, id = Guid.NewGuid()…

Store your Event streams in Azure Event Hub

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 withNew Document has been addedSo 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 BusAzure Service Bus mainly serving for enterprise …

Azure Search #2–Creating Search Service

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 newLog in to Azure portalClick New –> Web & MobileUnder that select Azure Search .Step 2: Give a name & select pricing tierafter 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 Tiersmainly contains 3 categories.1.Freemulti-tenant shared service 2.Basicprovides dedicated computing resources for production workloads at a smaller scale 3.Standardruns on dedic…