Mid Azure

Process Incoming Orders (Queue?

Trigger)

Scenario: When a customer places an order, the backend pushes a message to Azure

Storage Queue.

Azure Function processes it asynchronously.

Trigger: QueueTrigger

Use Case: Payment processing, inventory updates, email notifications.

Code Example (C#)

public class OrderProcessor

[FunctionName("ProcessOrder")]

public void Run(

[QueueTrigger("orders", Connection = "StorageConn")] string

orderJson,

ILogger log)

var order = JsonSerializer.Deserialize<Order>(orderJson);

log.LogInformation($"Processing order #{order.Id}");

// Call payment gateway

// Update inventory

// Send confirmation email

public record Order(int Id, string Product, int Qty);

✅ 2. Schedule Daily Database Backup

(Timer Trigger)

Scenario: Run SQL backup, archive logs, or clean old data every night.

Trigger: TimerTrigger

Use Case: Automation jobs, scheduled cleanups, maintenance tasks.

Code Example

public static class DailyBackup

[FunctionName("DailyDatabaseBackup")]

public static async Task Run(

[TimerTrigger("0 0 2 * * *")] TimerInfo timer,

ILogger log)

log.LogInformation("Starting daily database backup...");

// Call SQL API / storage account to create backup

await BackupService.RunBackupAsync();

log.LogInformation("Backup completed.");

⏰ "0 0 2 * * *" → runs daily at 2 AM

✅ 3. Generate Thumbnails for Uploaded

Images (Blob Trigger)

Scenario: When a user uploads an image, automatically create a thumbnail and store it.

Trigger: BlobTrigger

Use Case: Photo apps, e-commerce product images, document

workflows.

Code Example

[FunctionName("GenerateThumbnail")]

public static async Task Run(

[BlobTrigger("uploads/{name}", Connection = "StorageConn")]

Stream input,

string name,

[Blob("thumbnails/{name}", FileAccess.Write, Connection =

"StorageConn")] Stream output,

ILogger log)

log.LogInformation($"Creating thumbnail for {name}");

using var image = Image.Load(input);

image.Mutate(x => x.Resize(200, 200)); // resize

image.SaveAsJpeg(output);

✅ 4. Send Email Notifications from

Event Grid (Event Grid Trigger)

Scenario: A new user signs up → Event Grid sends event → Function triggers email.

Trigger: EventGridTrigger

Use Case: User signup, audit logs, subscription events.

Code Example

[FunctionName("UserSignupEmail")]

public static async Task Run(

[EventGridTrigger] EventGridEvent eventGridEvent,

ILogger log)

var data = eventGridEvent.Data.ToObjectFromJson<UserEvent>();

log.LogInformation($"New user signup: {data.Email}");

await EmailService.SendWelcomeEmail(data.Email);

✅ 5. Serverless REST API (HTTP

Trigger)

Scenario: Build lightweight APIs without using App Services.

Trigger: HttpTrigger

Use Case: Microservices, webhooks, backend-for-frontend APIs.

Code Example

[FunctionName("GetUserById")]

public static IActionResult Run(

[HttpTrigger(AuthorizationLevel.Function, "get", Route =

"users/{id}")] HttpRequest req,

string id,

ILogger log)

var user = UserDb.GetUser(id);

if (user == null)

return new NotFoundResult();

return new OkObjectResult(user);

✅ 6. Process Messages from Service

Bus (Service Bus Trigger)

Scenario: Enterprise integration between microservices.

Trigger: ServiceBusTrigger

Use Case: Order processing, billing, messaging between systems.

Code Example

[FunctionName("ProcessPayment")]

public static async Task Run(

[ServiceBusTrigger("payments", Connection = "ServiceBusConn")]

string message,

ILogger log)

var payment = JsonSerializer.Deserialize<Payment>(message);

log.LogInformation($"Processing payment {payment.Id}");

await PaymentService.CompleteAsync(payment);

✅ 7. Auto-Delete Expired Files (Blob +

Timer + Logic)

Scenario: Remove files older than 30 days to reduce storage costs.

Trigger: TimerTrigger

Use Case: Data lifecycle automation.

Code Example

[FunctionName("DeleteOldFiles")]

public static async Task Run(

[TimerTrigger("0 */30 * * * *")] TimerInfo timer,

ILogger log)

var client = new BlobContainerClient(

Environment.GetEnvironmentVariable("StorageConn"), "logs");

await foreach (var blob in client.GetBlobsAsync())

if (blob.Properties.CreatedOn <

DateTimeOffset.UtcNow.AddDays(-30))

await client.DeleteBlobAsync(blob.Name);

log.LogInformation($"Deleted old file: {blob.Name}");

🔹 Section 1: Azure for .NET Developers – General

More from Microsoft Azure Tutorial

All questions for this course