Skip to content

A demo project to be used for hands-on labs for explaining the concepts behind Durable Functions.

License

Notifications You must be signed in to change notification settings

marcduiker/building-a-resilient-workflow-with-durable-functions

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Building a resilient workflow using Durable Functions

XASA Workshop

Congratulations! Today is your first job as a software engineer at XASA, the Xpirit Aeronautics and Space Administration. You are responsible for creating a system which reacts to detected Near-Earth Objects (NEOs).

Known NEOs

A satellite is continuously scanning the skies for these NEOs. The satellite transmits its findings to ground stations which in turn send the data to Azure.

It's your job to ensure the incoming data is analyzed to assess the risk of impact, stored, and to notify the one and only person who can save earth in case of an asteroid threat...

Bruce Willis, who will save us all!

Technical solution

You are tasked with implementing the solution using Azure Functions. The reason behind this is that the number of detected NEOs changes heavily over time. And when nothing is being detected XASA prefers not paying for any infrastructure.

Another team was tasked with the ingestion of the NEO data and this data is already being pushed to an Azure Servicebus topic.

You are tasked with creating two Azure Function apps which are decscribed below.

XASA Onboarding Function App

You will be responsible for automating a part of the onboarding process for new XASA employees. This Function App will contain two functions:

  • An HTTP trigger function which validates the input (username & email) and puts a message on a queue.
  • A Queue trigger function which calls an service to register the user and returns a connectionstring for the Servicebus topic and an API key to call other XASA services. The result is stored in blob storage.
POST --> HTTP trigger --> Queue --> Queue trigger --> Blob

NEO Event Processor Function App

You will also be responsible for creating a Function App that is triggered by messages pushed to the Servicebus topic.

The messages are of type DetectedNEOEvent and contains the following information:

{
    "id" : "77c924dc-883c-4f53-922f-7cddb7325121",
    "date" : "2019-04-23T18:25:43.511Z",
    "distance": 3.5,
    "velocity" : 10,
    "diameter" : 0.52
}
  • Distance is measured in Astronomical Units (AU). Usually between 1-5 AU.
  • Velocity is measured in km/s. Usually between 5-30 km/s
  • Diameter is measured in km. Usually between 0.0001 and 10 km.

The Function App needs to make several calls to other services in order to determine:

  • the kinetic energy of a potential impact.
  • the probability of an impact.
  • the Torino impact.

Torino impact

In addition to these API calls, the processed data needs to be stored to blob storage (for events with a Torino impact > 0) and a notification needs to be sent out to Bruce Willis (for events with a Torino impact > 7).

Topic Message --> Servicebus trigger
                          |
                          V
            NeoEventProcessingOrchestrator
                          |
                          + --> EstimateKineticEnergyActivity
                          |
                          +-->  EstimateImpactProbabilityActivity
                          |
                          + --> EstimateTorinoImpactActivity
                          |
                          When TorinoImpact > 0
                             |
                             + --> StoreProcessedNeoEventActivity
                             |
                             When TorinoImpact > 7
                                |
                                + --> SendNotificationActivity

The final implementation (up to Lab 10) is also in this repo. However, it is lots more fun, and you learn way more, by creating your own solution and following all the labs. Only peek at my solution if you're completely stuck (but I would prefer you asking me, or someone else for help).

I strongly suggest you team up with someone to do pair programming and discuss what you're doing.

Have fun! Marc

Labs

  1. Check Prerequisites
  2. Creating a new function project with an http trigger
  3. Adding a queue output binding
  4. Adding a queue trigger function
  5. Creating a new function project with a servicebus trigger
  6. Creating an orchestration client
  7. Creating the orchestrator function
  8. Calling other services
  9. Storing the ProcessedNeoEvent
  10. Sending a notification
  11. Unit testing the orchestrator
  12. Calling activities in parallel (Fan-out/Fan-in)
  13. Using suborchestrations
  14. Waiting for external events
  15. Counting events using Durable Entities
  16. Creating Azure resources
  17. Publish to Azure
  18. Additional features

License

Please see the licensing information.

About

A demo project to be used for hands-on labs for explaining the concepts behind Durable Functions.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages