0
0
Azurecloud~30 mins

Durable Functions for workflows in Azure - Mini Project: Build & Apply

Choose your learning style9 modes available
Durable Functions for workflows
📖 Scenario: You are building a simple workflow using Azure Durable Functions to manage a multi-step process. This workflow will orchestrate two tasks: sending a welcome email and updating a database record. Durable Functions help keep track of the workflow state even if the system restarts.
🎯 Goal: Create a Durable Function workflow with an orchestrator function that calls two activity functions: one to send a welcome email and another to update a database record. The workflow should run these tasks in order.
📋 What You'll Learn
Create an orchestrator function named OrchestratorFunction.
Create two activity functions named SendWelcomeEmail and UpdateDatabaseRecord.
The orchestrator should call SendWelcomeEmail first, then UpdateDatabaseRecord.
Use the Durable Functions context to call activity functions.
Ensure the orchestrator returns a completion message.
💡 Why This Matters
🌍 Real World
Durable Functions are used to build reliable, stateful workflows in cloud applications, such as order processing, user onboarding, and batch jobs.
💼 Career
Understanding Durable Functions is valuable for cloud developers and architects working with Azure to create scalable and fault-tolerant workflows.
Progress0 / 4 steps
1
Create the activity function SendWelcomeEmail
Write a Python Azure Function named SendWelcomeEmail that takes a name parameter and returns the string "Welcome email sent to {name}".
Azure
Need a hint?

Define an async function named main that takes name as a string parameter and returns the welcome message.

2
Create the activity function UpdateDatabaseRecord
Write a Python Azure Function named UpdateDatabaseRecord that takes a user_id parameter and returns the string "Database record updated for user {user_id}".
Azure
Need a hint?

Define a new async function named update_database_record that takes user_id and returns the update message.

3
Create the orchestrator function OrchestratorFunction
Write a Python Azure Durable Functions orchestrator named OrchestratorFunction that calls the activity functions SendWelcomeEmail with "Alice" and then UpdateDatabaseRecord with "user123" in order. Use the context.call_activity method and return a string combining both results separated by a comma.
Azure
Need a hint?

Use context.call_activity to call each activity function with the given parameters. Return a combined string of both results.

4
Complete the Durable Functions setup with function registrations
Add the necessary code to register the orchestrator function OrchestratorFunction and the activity functions main and update_database_record with Azure Functions using df.Orchestrator and df.Activity. Export these as main for each function.
Azure
Need a hint?

Use df.Activity.create to register activity functions and df.Orchestrator.create to register the orchestrator function. Assign them to main or the function name as needed.