Better Bicep integration/support
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 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:
- 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.) - 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.
I am really looking for a way to deploy custom bicep templates that isn't a hackish way.
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.
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
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.
What's an endpoint? I still don't understand. Are you talking about writing application code that can deploy a bicep template?
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
Is there something stopping you from doing that manually? Do you have application code to submit bicep and do an ARM deployment?
I don't believe there's anything currently available to do in a non hacky way as @ahelland pointed out
.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.