Skip to content

Conversation

FullStackChef
Copy link
Contributor

@FullStackChef FullStackChef commented Sep 18, 2025

Closes #574

Azure Dapr Redis Integration Enhancements:

  • Refactored WithReference and related methods in AzureRedisCacheDaprHostingExtensions to more cleanly support both access key and managed identity authentication for Dapr state and pubsub components, including dynamic metadata configuration and output provisioning. [1] [2]
  • Improved infrastructure extensibility by adding helper methods like TryAdd and updating how Dapr components and parameters are added to the infrastructure.
  • Added missing import for CommunityToolkit.Aspire.Hosting.Azure.Dapr to enable new extension functionality.

Example AppHost Improvements:

  • Updated Program.cs in the example project to use the new Dapr component reference patterns, including improved sidecar and metadata configuration for state store and pubsub, and to leverage the new AzureContainerAppEnvironment. [1] [2]

PR Checklist

  • Created a feature/dev branch in your fork (vs. submitting directly from a commit on main)
  • [x ] Based off latest main branch of toolkit
  • PR doesn't include merge commits (always rebase on top of our main, if needed)
  • New integration
    • Docs are written
    • Added description of major feature to project description for NuGet package (4000 total character limit, so don't push entire description over that)
  • Tests for the changes have been added (for bug fixes / features) (if applicable)
  • Contains NO breaking changes
  • Every new API (including internal ones) has full XML docs
  • Code follows all style conventions

Other information

FullStackChef and others added 16 commits August 7, 2025 13:29
- Added project reference to `CommunityToolkit.Aspire.Hosting.Dapr.csproj` in the Azure Dapr project file.
- Updated `IDistributedApplicationBuilderExtensions.cs` with documentation for Dapr-related extension methods.
- Introduced `CommandLineBuilder.cs` for building Dapr CLI command line arguments.
- Modified and added classes for Dapr components, improving configuration and management.
- Refactored `DaprDistributedApplicationLifecycleHook` to manage Dapr sidecar lifecycles and on-demand components.
- Introduced new annotations and options classes for better Dapr component configuration.
- Improved organization and clarity of Dapr-related classes with additional comments and documentation.
- Added project reference to `CommunityToolkit.Aspire.Hosting.Dapr.csproj` in the Azure Dapr project file.
- Updated `IDistributedApplicationBuilderExtensions.cs` with documentation for Dapr-related extension methods.
- Introduced `CommandLineBuilder.cs` for building Dapr CLI command line arguments.
- Modified and added classes for Dapr components, improving configuration and management.
- Refactored `DaprDistributedApplicationLifecycleHook` to manage Dapr sidecar lifecycles and on-demand components.
- Introduced new annotations and options classes for better Dapr component configuration.
- Improved organization and clarity of Dapr-related classes with additional comments and documentation.
This commit introduces Azure Dapr support within the CommunityToolkit.Aspire.Hosting framework. Key changes include:

- Added setup for Azure Container Apps and Redis state management in Program.cs, enhancing Dapr sidecar configuration.
- Modified AzureDaprPublishingHelper to implement specific Dapr publishing requirements.
- Updated IDistributedApplicationBuilderExtensions with lifecycle hooks and improved configuration options.
- Introduced azure.yaml for defining the Azure Container App environment and project structure.
- Added documentation in next-steps.md to guide users on post-initialization steps for Azure deployment.
- Created AzureContainerAppEnvironmentResourceBuilderExtensions for configuring Azure Container App resources for Dapr.
- Updated .gitignore to exclude Azure-related files for a cleaner repository.
Updated `Program.cs` to add Dapr components configuration through the new `WithDaprComponents()` method. Renamed `WithDapr()` to `WithDaprComponents()` in `AzureContainerAppEnvironmentResourceBuilderExtensions.cs`, and restructured the method to prepare for Dapr component handling, with the implementation currently commented out for future development.
- Added project reference to `CommunityToolkit.Aspire.Hosting.Dapr.csproj` in the Azure Dapr project file.
- Updated `IDistributedApplicationBuilderExtensions.cs` with documentation for Dapr-related extension methods.
- Introduced `CommandLineBuilder.cs` for building Dapr CLI command line arguments.
- Modified and added classes for Dapr components, improving configuration and management.
- Refactored `DaprDistributedApplicationLifecycleHook` to manage Dapr sidecar lifecycles and on-demand components.
- Introduced new annotations and options classes for better Dapr component configuration.
- Improved organization and clarity of Dapr-related classes with additional comments and documentation.
- Added project reference to `CommunityToolkit.Aspire.Hosting.Dapr.csproj` in the Azure Dapr project file.
- Updated `IDistributedApplicationBuilderExtensions.cs` with documentation for Dapr-related extension methods.
- Introduced `CommandLineBuilder.cs` for building Dapr CLI command line arguments.
- Modified and added classes for Dapr components, improving configuration and management.
- Refactored `DaprDistributedApplicationLifecycleHook` to manage Dapr sidecar lifecycles and on-demand components.
- Introduced new annotations and options classes for better Dapr component configuration.
- Improved organization and clarity of Dapr-related classes with additional comments and documentation.
This commit introduces Azure Dapr support within the CommunityToolkit.Aspire.Hosting framework. Key changes include:

- Added setup for Azure Container Apps and Redis state management in Program.cs, enhancing Dapr sidecar configuration.
- Modified AzureDaprPublishingHelper to implement specific Dapr publishing requirements.
- Updated IDistributedApplicationBuilderExtensions with lifecycle hooks and improved configuration options.
- Introduced azure.yaml for defining the Azure Container App environment and project structure.
- Added documentation in next-steps.md to guide users on post-initialization steps for Azure deployment.
- Created AzureContainerAppEnvironmentResourceBuilderExtensions for configuring Azure Container App resources for Dapr.
- Updated .gitignore to exclude Azure-related files for a cleaner repository.
Updated `Program.cs` to add Dapr components configuration through the new `WithDaprComponents()` method. Renamed `WithDapr()` to `WithDaprComponents()` in `AzureContainerAppEnvironmentResourceBuilderExtensions.cs`, and restructured the method to prepare for Dapr component handling, with the implementation currently commented out for future development.
This commit removes the entire `IDistributedApplicationBuilderExtensions` class, including methods for adding Dapr components, pub-sub components, and state store components. All associated lifecycle management and manifest writing functionality, along with related comments and documentation, have also been deleted.
Enhance Dapr component integration by improving method chaining in `Program.cs`, adding metadata handling for dynamic configuration, and introducing lifecycle management methods. Update unit tests for new functionalities, remove redundant code, and improve test structure. Support managed identity and access key authentication for Redis, and enhance the `WithMetadata` method to accept various metadata types.
@FullStackChef FullStackChef marked this pull request as ready for review September 20, 2025 09:28
@Copilot Copilot AI review requested due to automatic review settings September 20, 2025 09:28
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR refactors the Dapr integration to remove the IDaprPublishingHelper abstraction and simplify the sidecar reference pattern. The primary changes include moving shared Dapr functionality from the shared folder into the core Dapr package and updating the Azure Dapr Redis integration to use a more streamlined approach for component reference handling.

Key changes:

  • Removed the IDaprPublishingHelper interface and related implementations in favor of a direct configuration action approach
  • Updated sidecar reference pattern to use lambda configuration for better component attachment
  • Consolidated Azure Dapr Redis reference logic to support both access key and managed identity authentication through unified methods

Reviewed Changes

Copilot reviewed 28 out of 48 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/Shared/Dapr/Core/* Removed shared Dapr core files that were moved to the main Dapr package
src/CommunityToolkit.Aspire.Hosting.Dapr/* Added consolidated Dapr functionality and simplified publishing approach
src/CommunityToolkit.Aspire.Hosting.Azure.Dapr/* Removed publishing helper and updated to use direct configuration actions
src/CommunityToolkit.Aspire.Hosting.Azure.Dapr.Redis/* Refactored Redis component configuration to support both auth methods cleanly
tests/* Updated tests to use new sidecar lambda pattern and verify component references
examples/* Updated example applications to demonstrate new sidecar reference patterns
Comments suppressed due to low confidence (1)

src/CommunityToolkit.Aspire.Hosting.Dapr/IDistributedApplicationComponentBuilderExtensions.cs:1

  • The State = KnownResourceStates.NotStarted line was removed but this appears to be needed for proper resource lifecycle management. Consider whether this removal was intentional.
// Licensed to the .NET Foundation under one or more agreements.

@FullStackChef FullStackChef changed the title Task refactor Refactor dapr apis Sep 21, 2025
@aaronpowell aaronpowell merged commit 9709412 into CommunityToolkit:main Sep 23, 2025
104 checks passed
@FullStackChef FullStackChef deleted the task-refactor branch September 23, 2025 06:36
@aaronpowell aaronpowell added this to the 9.8 milestone Sep 24, 2025
FullStackChef added a commit to FullStackChef/CommunityToolkit-Aspire that referenced this pull request Sep 26, 2025
* Enhance Dapr support in Aspire framework

- Added project reference to `CommunityToolkit.Aspire.Hosting.Dapr.csproj` in the Azure Dapr project file.
- Updated `IDistributedApplicationBuilderExtensions.cs` with documentation for Dapr-related extension methods.
- Introduced `CommandLineBuilder.cs` for building Dapr CLI command line arguments.
- Modified and added classes for Dapr components, improving configuration and management.
- Refactored `DaprDistributedApplicationLifecycleHook` to manage Dapr sidecar lifecycles and on-demand components.
- Introduced new annotations and options classes for better Dapr component configuration.
- Improved organization and clarity of Dapr-related classes with additional comments and documentation.

* Enhance Dapr support in Aspire framework

- Added project reference to `CommunityToolkit.Aspire.Hosting.Dapr.csproj` in the Azure Dapr project file.
- Updated `IDistributedApplicationBuilderExtensions.cs` with documentation for Dapr-related extension methods.
- Introduced `CommandLineBuilder.cs` for building Dapr CLI command line arguments.
- Modified and added classes for Dapr components, improving configuration and management.
- Refactored `DaprDistributedApplicationLifecycleHook` to manage Dapr sidecar lifecycles and on-demand components.
- Introduced new annotations and options classes for better Dapr component configuration.
- Improved organization and clarity of Dapr-related classes with additional comments and documentation.

* Integrate Azure Dapr support into CommunityToolkit

This commit introduces Azure Dapr support within the CommunityToolkit.Aspire.Hosting framework. Key changes include:

- Added setup for Azure Container Apps and Redis state management in Program.cs, enhancing Dapr sidecar configuration.
- Modified AzureDaprPublishingHelper to implement specific Dapr publishing requirements.
- Updated IDistributedApplicationBuilderExtensions with lifecycle hooks and improved configuration options.
- Introduced azure.yaml for defining the Azure Container App environment and project structure.
- Added documentation in next-steps.md to guide users on post-initialization steps for Azure deployment.
- Created AzureContainerAppEnvironmentResourceBuilderExtensions for configuring Azure Container App resources for Dapr.
- Updated .gitignore to exclude Azure-related files for a cleaner repository.

* Enhance Azure Container App Dapr integration

Updated `Program.cs` to add Dapr components configuration through the new `WithDaprComponents()` method. Renamed `WithDapr()` to `WithDaprComponents()` in `AzureContainerAppEnvironmentResourceBuilderExtensions.cs`, and restructured the method to prepare for Dapr component handling, with the implementation currently commented out for future development.

* Enhance Dapr support in Aspire framework

- Added project reference to `CommunityToolkit.Aspire.Hosting.Dapr.csproj` in the Azure Dapr project file.
- Updated `IDistributedApplicationBuilderExtensions.cs` with documentation for Dapr-related extension methods.
- Introduced `CommandLineBuilder.cs` for building Dapr CLI command line arguments.
- Modified and added classes for Dapr components, improving configuration and management.
- Refactored `DaprDistributedApplicationLifecycleHook` to manage Dapr sidecar lifecycles and on-demand components.
- Introduced new annotations and options classes for better Dapr component configuration.
- Improved organization and clarity of Dapr-related classes with additional comments and documentation.

* Enhance Dapr support in Aspire framework

- Added project reference to `CommunityToolkit.Aspire.Hosting.Dapr.csproj` in the Azure Dapr project file.
- Updated `IDistributedApplicationBuilderExtensions.cs` with documentation for Dapr-related extension methods.
- Introduced `CommandLineBuilder.cs` for building Dapr CLI command line arguments.
- Modified and added classes for Dapr components, improving configuration and management.
- Refactored `DaprDistributedApplicationLifecycleHook` to manage Dapr sidecar lifecycles and on-demand components.
- Introduced new annotations and options classes for better Dapr component configuration.
- Improved organization and clarity of Dapr-related classes with additional comments and documentation.

* Integrate Azure Dapr support into CommunityToolkit

This commit introduces Azure Dapr support within the CommunityToolkit.Aspire.Hosting framework. Key changes include:

- Added setup for Azure Container Apps and Redis state management in Program.cs, enhancing Dapr sidecar configuration.
- Modified AzureDaprPublishingHelper to implement specific Dapr publishing requirements.
- Updated IDistributedApplicationBuilderExtensions with lifecycle hooks and improved configuration options.
- Introduced azure.yaml for defining the Azure Container App environment and project structure.
- Added documentation in next-steps.md to guide users on post-initialization steps for Azure deployment.
- Created AzureContainerAppEnvironmentResourceBuilderExtensions for configuring Azure Container App resources for Dapr.
- Updated .gitignore to exclude Azure-related files for a cleaner repository.

* Enhance Azure Container App Dapr integration

Updated `Program.cs` to add Dapr components configuration through the new `WithDaprComponents()` method. Renamed `WithDapr()` to `WithDaprComponents()` in `AzureContainerAppEnvironmentResourceBuilderExtensions.cs`, and restructured the method to prepare for Dapr component handling, with the implementation currently commented out for future development.

* Refactor Dapr integration for Azure Redis Cache

Enhance Dapr component integration by improving method chaining in `Program.cs`, adding metadata handling for dynamic configuration, and introducing lifecycle management methods. Update unit tests for new functionalities, remove redundant code, and improve test structure. Support managed identity and access key authentication for Redis, and enhance the `WithMetadata` method to accept various metadata types.

* Delete examples/dapr/CommunityToolkit.Aspire.Hosting.Azure.Dapr.AppHost/.gitignore

* Delete examples/dapr/CommunityToolkit.Aspire.Hosting.Azure.Dapr.AppHost/azure.yaml

* Delete examples/dapr/CommunityToolkit.Aspire.Hosting.Azure.Dapr.AppHost/next-steps.md

* Add tests for Dapr component references and sidecar functionality

* remove sln file

* Enhance Dapr sidecar configuration with default AppId and options handling

* Refactor Dapr sidecar configuration to simplify AppId handling and remove redundant checks
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.

Refine the Dapr Sidecar API
2 participants