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

Support injecting ExtraInterfaces on generated project metadata during build #5683

Open
captainsafia opened this issue Sep 11, 2024 · 0 comments
Labels
area-integrations Issues pertaining to Aspire Integrations packages azure Issues associated specifically with scenarios tied to using Azure azure-functions Issues related to the Azure Functions integration
Milestone

Comments

@captainsafia
Copy link
Member

captainsafia commented Sep 11, 2024

For some scenarios, specifically Azure Functions, we want to implement Functions-specific behavior in Aspire APIs like Azure Functions. We currently achieve this by defining a custom AzureFunctionsResource resource type that is a wrapper around the default ProjectResource type. This pattern allows us to model specific behavior to target AzureFunctionsResource. However, it requires that users call the AddAzureFunctionsProject extension method in order to be able to invoke Functions-specific code.

An additional approach is to support attaching additional metadata into pre-existing ProjectResources and support targeting our Functions-specific methods onto that interface:

public class AzureFunctionsTest_Functions : global::Aspire.Hosting.IProjectMetadata, IFunctionsMetadata

In order to support this scenario, we need to be able to customize the interfaces that are applied to the AzureFunctionsTest_Functions type via MSBuild and the cogeneration step. To achieve this, we need to support an @(ExtraInterfaces) property that hosting packages can populate with additional interfaces that need to be applied on projects they target.

The flow of this would look as follows:

  • An Azure Functions project referencing the worker SDK would set an IsAzureFunctionsProject=true property
  • During build-time the Aspire app host will generate project metadata for all project references in a project, at this point in time we'll query the projects to see if they implement the Azure Functions interface
  • ExtraInterfaces will be populated with this metadta
// package: Aspire.Hosting

namespace Aspire.Hosting;

public interface IFunctionsProjectMetadata { }
@captainsafia captainsafia added area-app-model Issues pertaining to the APIs in Aspire.Hosting, e.g. DistributedApplication azure-functions Issues related to the Azure Functions integration labels Sep 11, 2024
@davidfowl davidfowl added area-integrations Issues pertaining to Aspire Integrations packages azure Issues associated specifically with scenarios tied to using Azure and removed area-app-model Issues pertaining to the APIs in Aspire.Hosting, e.g. DistributedApplication labels Sep 11, 2024
@davidfowl davidfowl added this to the 9.0 milestone Sep 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-integrations Issues pertaining to Aspire Integrations packages azure Issues associated specifically with scenarios tied to using Azure azure-functions Issues related to the Azure Functions integration
Projects
None yet
Development

No branches or pull requests

2 participants