dotnet / aspire

Tools, templates, and packages to accelerate building observable, production-ready apps
https://learn.microsoft.com/dotnet/aspire
MIT License
3.91k stars 476 forks source link

Add component for Azure Resource Manager #3877

Open mitchdenny opened 7 months ago

mitchdenny commented 7 months ago

I think we need to model an AppModel resource and component library around Azure Resource Manager. Some applications need to dynamically create resources in the cloud (this is especially true if you are building a hosting platform on Azure - such as internal Azure teams).

We would need an API that looks something like this:

var arm = builder.AddAzureResourceManager("arm", subscriptionParameter);
builder.AddProject<Projects.ResourceProvider>("rp")
       .WithReference(arm);

On the service side it might be something like this:

builder.AddAzureArmClient("arm");
var app = builder.Build();
app.MapGet("/", (ArmClient armClient) => {
 ... do stuff with ARM.
});

We might want to do this in conjunction with support for managed identities.

xinlifoobar commented 4 months ago

Hey @mitchdenny. I want this feature to be added to the Aspire. If you could help outline the requirement for the feature, I can add the code.

mitchdenny commented 4 months ago

Even though we don't have an Aspire.Azure.ResourceManager.* component library, and we don't have an Aspire.Hosting.Azure.ResourceManager hosting package, you can still use Azure.ResourceManager.*.

If you are deploying to Azure Container Apps via AZD, the container app has a managed identity which you can grant rights to.

Really this is about adding the niceties around things like DI and OTEL support to the component library (I'm not even certain if a hosting package is required).

mitchdenny commented 4 months ago

/cc @tg-msft as he might have some thoughts on this.