Skip to content

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Sep 20, 2025

This PR adds support for Azure Table Storage as a persistence provider for WorkflowCore, addressing the community request for Azure Storage-based persistence options.

What's Added

Azure Table Storage Persistence Provider

A complete implementation of IPersistenceProvider that uses Azure Table Storage for workflow persistence:

services.AddWorkflow(options => 
{
    // Basic usage with connection string
    options.UseAzureTableStoragePersistence("DefaultEndpointsProtocol=https;AccountName=myaccount;...");
    
    // With custom table prefix
    options.UseAzureTableStoragePersistence(connectionString, "MyApp");
    
    // Using Managed Identity
    var serviceUri = new Uri("https://mystorageaccount.table.core.windows.net");
    options.UseAzureTableStoragePersistence(serviceUri, new DefaultAzureCredential());
});

Key Features

  • Cost-effective: Azure Table Storage is significantly more affordable than Cosmos DB for high-volume scenarios
  • Scalable: Handles millions of workflow instances with automatic partitioning
  • Full feature support: Complete implementation including scheduled commands, events, subscriptions, and error tracking
  • Multiple authentication options: Connection strings, managed identity, and custom client support
  • Automatic table management: Creates and manages five tables (Workflows, Events, Subscriptions, Commands, Errors)

Table Storage Schema

The provider uses an optimized partition/row key strategy:

  • Workflows: PartitionKey = "workflow", RowKey = workflowId
  • Events: PartitionKey = "event", RowKey = eventId
  • Subscriptions: PartitionKey = "subscription", RowKey = subscriptionId
  • Commands: PartitionKey = "command", RowKey = commandId
  • Errors: PartitionKey = "error", RowKey = errorId

Comprehensive Test Suite

WorkflowCore.Tests.Azure Project

Added a complete test project following the same patterns as other persistence provider tests:

  • Persistence Provider Fixture: AzureTableStoragePersistenceProviderFixture extending BasePersistenceFixture to inherit all standard persistence tests
  • Docker Setup: Azure Storage Emulator (Azurite) integration for local testing
  • 9 End-to-End Scenario Tests covering all major workflow functionality:
    • AzureTableStorageBasicScenario - Basic workflow execution
    • AzureTableStorageEventScenario - Event handling and subscriptions
    • AzureTableStorageDataScenario - Data persistence and retrieval
    • AzureTableStorageDelayScenario - Delayed execution and scheduling
    • AzureTableStorageIfScenario - Conditional workflow logic
    • AzureTableStorageForeachScenario - Loop and iteration handling
    • AzureTableStorageWhileScenario - While loop functionality
    • AzureTableStorageSagaScenario - Saga pattern implementation
    • AzureTableStorageCompensationScenario - Compensation and rollback

The test suite follows the exact same patterns as existing persistence provider tests (SQL Server, MongoDB, DynamoDB), ensuring consistency and maintainability.

GitHub Actions CI/CD Integration

Added Azure-Tests job to .github/workflows/dotnet.yml following the same pattern as other persistence provider tests:

  • Runs on ubuntu-latest with .NET 6.0, 8.0, and 9.0 support
  • Includes standard restore, build, and test steps with proper verbosity and parallelization settings
  • Ensures Azure Table Storage tests run automatically on all pull requests and pushes to master

Documentation Updates

Updated Persistence Documentation

The main docs/persistence.md now includes:

  • Azure Table Storage in the list of supported providers
  • Comprehensive guide for implementing custom persistence providers
  • Interface breakdown with examples for each repository interface

Enhanced Azure Provider README

Added detailed usage examples and configuration options for the new Table Storage provider.

Technical Implementation

  • C# 7.3 Compatible: Uses manual async enumeration instead of async streams for netstandard2.0 compatibility
  • Proper Error Handling: Handles Azure RequestFailedException appropriately for missing entities
  • JSON Serialization: Complex workflow data is properly serialized/deserialized using Newtonsoft.Json
  • Zero Breaking Changes: Additive-only changes to existing codebase
  • Full Test Coverage: Complete end-to-end integration tests following established patterns
  • CI/CD Integration: Automated testing in GitHub Actions workflow

This provides a production-ready alternative to Cosmos DB persistence while maintaining full compatibility with existing WorkflowCore patterns and interfaces.

Fixes #326.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@Copilot Copilot AI changed the title [WIP] Support Azure Storage (Blobs or Tables) for persistence Add Azure Table Storage persistence provider to WorkflowCore.Providers.Azure Sep 20, 2025
@Copilot Copilot AI requested a review from danielgerlag September 20, 2025 00:48
Copilot finished work on behalf of danielgerlag September 20, 2025 00:48
Copy link
Owner

@danielgerlag danielgerlag left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot please add end to end tests that extend the integration tests, just like all the other persistence provider tests.

Copy link
Contributor Author

Copilot AI commented Sep 20, 2025

@copilot please add end to end tests that extend the integration tests, just like all the other persistence provider tests.

I've added comprehensive end-to-end tests for the Azure Table Storage persistence provider following the exact same patterns as other persistence provider tests in the repository.

Added test project: WorkflowCore.Tests.Azure

  • Persistence provider fixture extending BasePersistenceFixture
  • Docker setup for Azure Storage Emulator (Azurite) integration testing
  • 9 comprehensive scenario tests covering all major workflow functionality (Basic, Event, Data, Delay, If, Foreach, While, Saga, Compensation)

The tests follow the same structure as WorkflowCore.Tests.SqlServer, WorkflowCore.Tests.MongoDB, etc., ensuring consistency with existing test patterns. Tests can be run with Azure Storage Emulator for local development or real Azure Table Storage for integration testing.

Commit: 1aacb24

@Copilot Copilot AI changed the title Add Azure Table Storage persistence provider to WorkflowCore.Providers.Azure Add Azure Table Storage persistence provider with comprehensive end-to-end tests to WorkflowCore.Providers.Azure Sep 20, 2025
@Copilot Copilot AI requested a review from danielgerlag September 20, 2025 16:34
Copilot finished work on behalf of danielgerlag September 20, 2025 16:34
@danielgerlag
Copy link
Owner

@copilot can you please add the tests to the dotnet github workflow

Copy link
Contributor Author

Copilot AI commented Sep 20, 2025

@copilot can you please add the tests to the dotnet github workflow

I've added the Azure Table Storage tests to the GitHub Actions workflow. Added an Azure-Tests job to .github/workflows/dotnet.yml following the same pattern as other persistence provider tests (MongoDB-Tests, PostgreSQL-Tests, etc.).

The job runs on ubuntu-latest with .NET 6.0, 8.0, and 9.0 support, and includes the standard restore, build, and test steps with proper verbosity and parallelization settings.

Commit: a09a9cc

@Copilot Copilot AI changed the title Add Azure Table Storage persistence provider with comprehensive end-to-end tests to WorkflowCore.Providers.Azure Add Azure Table Storage persistence provider with comprehensive end-to-end tests and CI/CD integration to WorkflowCore.Providers.Azure Sep 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support Azure Storage (Blobs or Tables) for persistence
2 participants