Azure Scheduler

Azure Service Bus includes native support for scheduled message delivery using the ScheduledEnqueueTimeUtc property. In V10, Brighter integrates with Azure Service Bus's built-in scheduling capabilities to provide cloud-native scheduling for Azure workloads.

When to Use Azure Service Bus Scheduler

Azure Service Bus Scheduler is recommended when:

  • Running on Azure: Your application is deployed on Azure (VMs, App Service, AKS, Functions, etc.)

  • Using Service Bus: Already using Azure Service Bus for messaging

  • Cloud-Native: Prefer Azure-managed services over self-hosted solutions

  • Simple Scheduling: Need basic scheduling without complex dependencies

  • Azure Ecosystem: Want to leverage Azure services directly

  • Cost-Effective: Want to avoid additional scheduler infrastructure

When NOT to use:

  • Multi-Cloud: Need scheduler to work across cloud providers

  • On-Premises: Application runs outside Azure

  • Reschedule Support: Need to modify scheduled time without cancel/recreate

  • Complex Scheduling: Need advanced features (recurring schedules, job chains, dependencies)

  • Dashboard: Need visual management interface

How Brighter Integrates with Azure Service Bus Scheduler

Brighter uses Azure Service Bus's native ScheduledEnqueueTimeUtc property through the FireAzureScheduler message approach:

Why FireAzureScheduler Approach?

Unlike AWS EventBridge Scheduler (which can directly target any SNS/SQS), Azure Service Bus requires a topic/queue to hold the scheduled message. Brighter uses a centralized scheduler topic to handle all scheduled messages, then dispatches them to the appropriate handlers.

Authentication and Credentials

Azure Service Bus Scheduler uses Azure Service Bus client providers for authentication. Brighter supports multiple authentication methods:

Visual Studio Credentials (Development)

Connection String (Simple, Less Secure)

Default Azure Credentials (Flexible)

Best Practice: Use Managed Identity in production, Visual Studio/Default credentials for development.

RBAC Permissions Required

When using Managed Identity or Azure AD authentication, the identity must have these Azure RBAC roles:

  • Azure Service Bus Data Sender: To send scheduled messages

  • Azure Service Bus Data Receiver: To receive FireAzureScheduler messages (Dispatcher)

NuGet Package

To use Azure Service Bus Scheduler, install:

Package: Paramore.Brighter.MessageScheduler.Azure

Dependencies:

  • Azure.Messaging.ServiceBus - Azure Service Bus SDK

  • Paramore.Brighter.MessagingGateway.AzureServiceBus - Brighter's Azure Service Bus transport

Configuration

Basic Configuration

Configure Azure Service Bus Scheduler with minimal settings:

Configuration with Dispatcher (FireAzureScheduler Handler)

Configure the Dispatcher to handle FireAzureScheduler messages:

Configuration with Custom Sender Options

Customize Azure Service Bus sender behavior:

Configuration with Custom TimeProvider

Use a custom time provider for testing:

Code Examples

Basic Scheduling with Delay

Schedule a command to execute after a delay:

Scheduling with Absolute Time

Schedule for a specific time:

Cancelling a Scheduled Job

Cancel a scheduled task before it executes:

Rescheduling (Cancel + Schedule)

Since Azure doesn't support rescheduling, cancel and create a new schedule:

Comparison with Other Schedulers

Feature
Azure Service Bus
AWS Scheduler
Quartz.NET
Hangfire
InMemory

Cloud Native

✅ Azure Only

✅ AWS Only

Managed Service

Persistence

Azure Managed

AWS Managed

Database

Database

None

Dashboard

Azure Portal

AWS Console

Limited

Yes

No

Cancellation

Reschedule

❌ (Cancel+Schedule)

Native Scheduling

✅ Built-in

❌ Separate Service

Cost Model

Service Bus Pricing

Pay-per-use

Infrastructure

Infrastructure

Free

Setup Complexity

Easy

Moderate (IAM)

Moderate

Easy

Minimal

Production Ready

Multi-Cloud

Strong Naming

When to use Azure Service Bus Scheduler:

  • Running on Azure infrastructure

  • Already using Azure Service Bus for messaging

  • Want simplicity (no separate scheduler service)

  • Don't need reschedule support (cancel+schedule is acceptable)

Best Practices

1. Use Managed Identity in Production

2. Use Separate Scheduler Topic

3. Handle Reschedule as Cancel + Schedule

4. Set Appropriate Message TTL

5. Monitor with Azure Monitor

6. Use Service Bus Premium for Production

7. Configure Dead-Letter Queue

8. Test Locally with Azurite

Troubleshooting

Scheduled Messages Not Executing

Symptom: Messages scheduled but never delivered

Possible Causes:

  1. FireAzureScheduler subscription not configured

  2. Incorrect topic name

  3. Message TTL expired before scheduled time

  4. Service Bus connection issues

  5. RBAC permissions missing

Solutions:

Authentication Failures

Symptom: UnauthorizedAccessException when scheduling

Cause: Missing RBAC permissions or invalid credentials

Solution:

Reschedule Not Working

Symptom: Attempting to reschedule fails or has no effect

Cause: Azure Service Bus doesn't support rescheduling

Solution:

Messages Going to Dead-Letter Queue

Symptom: Scheduled messages end up in dead-letter queue

Possible Causes:

  • Handler exceptions not properly handled

  • Message processing timeout exceeded

  • Maximum delivery count reached

  • Invalid message format

Solutions:

Migration from Other Schedulers

From InMemory Scheduler

Additional Setup Required:

  • Configure FireAzureScheduler subscription in Dispatcher

  • Create scheduler topic in Azure Service Bus

  • Configure RBAC permissions

From Quartz or Hangfire to Azure Service Bus

Benefits of moving to Azure Service Bus Scheduler:

  • Simpler (no separate scheduler infrastructure)

  • Native Azure integration

  • Reduced operational complexity

  • No database required

Considerations:

  • Must configure FireAzureScheduler subscription

  • No reschedule support (cancel + schedule instead)

  • Requires FireAzureScheduler topic in Service Bus

Summary

Azure Service Bus Scheduler leverages Azure Service Bus's native scheduling capabilities for cloud-native scheduling:

  • Native Integration - Uses Azure Service Bus ScheduledEnqueueTimeUtc

  • Managed Service - No separate scheduler infrastructure

  • Simple Setup - If already using Azure Service Bus

  • Azure Ecosystem - Integrates with Azure monitoring and security

Recommended for production when running on Azure and using Azure Service Bus. Consider Quartz.NET or Hangfire for multi-cloud or on-premises deployments.

Key Decision Factors:

  • ✅ Use Azure Service Bus Scheduler if: Running on Azure, using Service Bus, want simplicity

  • ✅ Use AWS Scheduler if: Running on AWS, need reschedule support

  • ✅ Use Quartz if: Multi-cloud, complex scheduling, need job clustering

  • ✅ Use Hangfire if: Need dashboard, simple setup, OK without strong naming

  • ✅ Use InMemory if: Testing only, not for production

Important Note: Azure Service Bus does NOT support rescheduling. Use cancel + schedule pattern when rescheduling is needed.

Last updated

Was this helpful?