Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dapr azure hosting ext #371

Draft
wants to merge 21 commits into
base: main
Choose a base branch
from

Conversation

FullStackChef
Copy link

@FullStackChef FullStackChef commented Jan 6, 2025

Closes #349

  • Created CommunityToolkit.Aspire.Hosting.Dapr.AzureExtensions
    • Provides functionality for referencing azure resources for dapr components
  • Created CommunityToolkit.Aspire.Hosting.Dapr.AzureRedis
    • Provides extensions for referencing azure redis for dapr state

PR Checklist

  • Created a feature/dev branch in your fork (vs. submitting directly from a commit on main)
  • 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

Create Dapr Azure Redis project
Create Example AppHost + ApiService
Create Dapr resource for provisioning
Add AzureDaprComponentResource
Start of unit tests
Fixes based on unit tests
Comment on lines 17 to 21
2. **`ConfigureRedisStateComponent`**
Internal helper that creates and configures a “state.redis” Dapr component based on the `AzureRedisCacheResource`.
- Generates a valid hostname and port.
- Supports Azure Entra ID (AadEnabled) for secure access.
- Stores or references secrets in Azure Key Vault if password-based authentication is required.

Choose a reason for hiding this comment

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

Not sure internal details need to be in the readme

Copy link
Author

Choose a reason for hiding this comment

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

Have adjusted docs

Copy link
Member

@aaronpowell aaronpowell left a comment

Choose a reason for hiding this comment

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

As I was doing the review, it made me wonder if it wouldn't make more sense to create a single package, CommunityToolkit.Aspire.Hosting.Dapr.Azure.

My understanding is that the AzureExtensions package doesn't really do anything on its own, you'd need to bring in a package such as the Dapr.AzureRedis one or you'd create your own using some other Azure service to act as the caching layer in Azure.

Is the risk that if you aren't wanting to use Azure Redis as the caching layer you're going to end up bringing in some dependencies that are unneeded to the application (and thus "bloat")?

I guess I don't know enough about Dapr and what's needed/how you go about hosting it in Azure to truly understand what alternatives there might need to be in the future.

@@ -22,7 +22,6 @@

<Target Name="PublishRunMaven" AfterTargets="Build">
<!-- As part of publishing, ensure the Java app is freshly built -->
<Exec WorkingDirectory="$(JavaAppRoot)" Command="./mvnw --quiet clean package" />
Copy link
Member

Choose a reason for hiding this comment

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

Can you revert this change, as we have a PR to resolve it (and it'll cause builds to fail if it's not included at the moment)

Copy link
Author

Choose a reason for hiding this comment

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

Done - I'm pretty sure I didn't intentionally remove this.

public static IResourceBuilder<AzureDaprComponentResource> AddAzureDaprResource(
this IResourceBuilder<IDaprComponentResource> builder,
[ResourceName] string name,
Action<AzureResourceInfrastructure> configureInfrastructure)
Copy link
Member

Choose a reason for hiding this comment

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

This parameter is non-null and thus required, is that intended?

Copy link
Author

Choose a reason for hiding this comment

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

Yes it is intended and required because it is necessary

Copy link
Member

Choose a reason for hiding this comment

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

Is someone always going to need to provide their own configuration callback? Could it not be nullable and we have a default (even if it's just a noop)?

Or is it more that these are methods that you wouldn't realistically use in isolation, you'd only use them through wrappers like the Dapr Azure Redis package?

Copy link
Author

Choose a reason for hiding this comment

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

I mean you could no-op it, but I don't see a use case where you would use it without configuration.

It is primarily designed to be used by the wrappers - and I'm sitting here arguing with myself whether you would realistically use it in isolation.

On one hand if a wrapped integration exists for the component you're wanting to use - it makes sense to use that, however if not this integration avoids the pain I experienced trying to figure it out.

I think provided that I (or someone) can contribute wrapped version in a timely manner then this library could in fact be a supporting library that wasn't published separately?

Copy link
Author

Choose a reason for hiding this comment

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

The more I think about this the more I think that this shouldn't be published on it's own and should only serve as the base for more specific integrations.

@FullStackChef
Copy link
Author

As I was doing the review, it made me wonder if it wouldn't make more sense to create a single package, CommunityToolkit.Aspire.Hosting.Dapr.Azure.

My understanding is that the AzureExtensions package doesn't really do anything on its own, you'd need to bring in a package such as the Dapr.AzureRedis one or you'd create your own using some other Azure service to act as the caching layer in Azure.

Is the risk that if you aren't wanting to use Azure Redis as the caching layer you're going to end up bringing in some dependencies that are unneeded to the application (and thus "bloat")?

I guess I don't know enough about Dapr and what's needed/how you go about hosting it in Azure to truly understand what alternatives there might need to be in the future.

@aaronpowell yeah it would be a pretty bloated integration. Dapr has multiple "building blocks" - state is just one of these building blocks can be used with redis, cosmosdb, postgres, table / blob storage or sql server (to name the azure ones). so you would end up referencing a rather large number of the aspire hosting packages. which felt like it is contra to the design of aspire.

public static IResourceBuilder<AzureDaprComponentResource> AddAzureDaprResource(
this IResourceBuilder<IDaprComponentResource> builder,
[ResourceName] string name,
Action<AzureResourceInfrastructure> configureInfrastructure)
Copy link
Member

Choose a reason for hiding this comment

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

Is someone always going to need to provide their own configuration callback? Could it not be nullable and we have a default (even if it's just a noop)?

Or is it more that these are methods that you wouldn't realistically use in isolation, you'd only use them through wrappers like the Dapr Azure Redis package?

@aaronpowell
Copy link
Member

I'm wondering if the Azure Extensions package should ship as a source-only package (see https://andrewlock.net/creating-source-only-nuget-packages/) so that there's one less binary people would end up with, as they'd compile in the stuff they need (also means things could be marked as internal for library authors).

Copy link
Member

@aaronpowell aaronpowell left a comment

Choose a reason for hiding this comment

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

I think this looks good - anything else outstanding in your opinion @FullStackChef

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.

[Feature] Dapr - Azure extensions + Redis configuration
3 participants