aspire icon indicating copy to clipboard operation
aspire copied to clipboard

Better Bicep integration/support

Open Hana-fubuki opened this issue 1 year ago • 9 comments

Is there an existing issue for this?

  • [X] I have searched the existing issues

Is your feature request related to a problem? Please describe the problem.

Currently you can create some resource via bicep when your project starts but I have yet to find a way to deploy resources outside of this process, for instance I create an endpoint and maybe it creates a handful of resources

Describe the solution you'd like

The ability to create resources outside of the app host that isn't a resources that the code is necessarily dependant on

Additional context

No response

Hana-fubuki avatar Oct 03 '24 16:10 Hana-fubuki

@Hana-fubuki You can add Bicep for "developer mode" with var foo= builder.AddBicepTemplate now. That will as you say compile and deploy when hitting F5.

If you want to deploy this you can use the Azure Developer CLI as a black box or use azd infra synth to generate Bicep. This will create Bicep that you can tweak as you like and will work deploy time.

By using the "hooks" feature of AZD you can add Bicep files, deployment stacks and all things IaC you like. But it will be entirely outside the Aspire flows.

Challenges:

  1. If you add services, variables, etc. to AppHost you might want/need to regenerate the Bicep by re-running azd infra synth. That is not a synced mechanism so depending on what you edited on your own your code might be overwritten. (You will be warned, but you don't get a diff view so your mileage may wary.)
  2. You can send in params and acquire outputs within Aspire using .AddBicepTemplate. However, if you want to combine what this does with the deploy time Bicep from azd it's hackish to send the params back and forth and into environment variables. It may not be intended to be used that way either, but I could see some use cases where you work on something locally and send it off to a shared dev environment. (Prod would be in a different scope anyways.)

So, it is workable, but slightly rough around the edges.

ahelland avatar Oct 03 '24 17:10 ahelland

I am really looking for a way to deploy custom bicep templates that isn't a hackish way.

Hana-fubuki avatar Oct 03 '24 17:10 Hana-fubuki

I agree with you - I don't want the hackish way either ;)

If you need to hack it or can get away fairly clean is dependent on the specifics of your use case I suppose.

ahelland avatar Oct 03 '24 17:10 ahelland

It would be good to add some more details here. What's are you trying to accomplish?

The ability to create resources outside of the app host that isn't a resources that the code is necessarily dependant on

I don't quite understand what this means.

davidfowl avatar Oct 03 '24 18:10 davidfowl

@davidfowl

Sure, so an example would be creating an endpoint that could be used to deploy a bicep template, from what I've seen so far in aspire you can only create initial infra for you project in the app host via bicep. I am looking to do so in say a web project handler.

Hana-fubuki avatar Oct 03 '24 19:10 Hana-fubuki

What's an endpoint? I still don't understand. Are you talking about writing application code that can deploy a bicep template?

davidfowl avatar Oct 03 '24 20:10 davidfowl

That is correct, I was hoping something like what can be done in app host would be possible or referencing custom template in my applications code

Hana-fubuki avatar Oct 04 '24 14:10 Hana-fubuki

Is there something stopping you from doing that manually? Do you have application code to submit bicep and do an ARM deployment?

davidfowl avatar Oct 04 '24 14:10 davidfowl

I don't believe there's anything currently available to do in a non hacky way as @ahelland pointed out

Hana-fubuki avatar Oct 04 '24 15:10 Hana-fubuki

.NET Aspire doesn't intrinsically support creating a .NET web app that deploys bicep, and it isn't on the roadmap to enable something like this out of the box. You can build a web service yourself that does this.

eerhardt avatar Jan 14 '25 22:01 eerhardt