Azure / azure-dev

A developer CLI that reduces the time it takes for you to get started on Azure. The Azure Developer CLI (azd) provides a set of developer-friendly commands that map to key stages in your workflow - code, build, deploy, monitor, repeat.
https://aka.ms/azd
MIT License
416 stars 204 forks source link

[Feature] Update azd templates to use bicepparam instead of parameters.json #2783

Open jongio opened 1 year ago

jongio commented 1 year ago

Bicep and azd now support bicepparam. Let's get the templates we own updated to use bicepparam.

https://learn.microsoft.com/en-us/azure/azure-resource-manager/bicep/parameter-files?tabs=Bicep

savannahostrowski commented 1 year ago

We should also do this for simplified init too - @rajeshkamal5050 @weikanglim @ellismg

vhvb1989 commented 1 year ago

There are some todo-templates which are not compatible with .bicepparams @jongio

For example, the SQL Server templates b/c the template uses azd to auto-generate a secrets like: https://github.com/Azure-Samples/todo-csharp-sql/blob/main/infra/main.parameters.json#L18

We don't have an alternative on bicepparam world for extending/controlling parameters the same way we do on parameters.json

v-xuto commented 1 year ago

@jongio Any ideas about Victor's comment?

jongio commented 1 year ago

Victor Is something stopping us from implementing that in bicepparam?

vhvb1989 commented 1 year ago

Victor Is something stopping us from implementing that in bicepparam?

I little bit @jongio. The bicep-compilation flow changes; for example, if there's a parameter foo (with no default value) defined in main.bicep and you don't set a mapping to assign a value for it in main.bicepparam, bicep would return an error while compiling, like:

image

Before bicepparam flow, bicep would only care about compiling a template (ignoring the inputs for the parameter definitions). That allows azd to take control after bicep compilation to inspect the parameter definitions and ensure getting a value for each of them.

With bicepparam, we need to think and define some strategy for azd to help getting the input values... Some alternatives are:

@ellismg , what do you think,... do you like any of these proposals? or do you have some other idea?

jongio commented 1 year ago

We could also work with bicep team to update bicep to allow us to do what we need to do.

v-xuto commented 1 year ago

@rajeshkamal5050 Can you help contact the Bicep team to develop function auto-generate secrets (like function in json)?

rajeshkamal5050 commented 8 months ago

@rajeshkamal5050 Can you help contact the Bicep team to develop function auto-generate secrets (like function in json)?

@vhvb1989 can you take a look and file specific asks on Bicep team w.r.t secretOrRandomPassword or such similar functions POV. Moving it to Backlog.

Note:

heaths commented 2 weeks ago

Rather than add any azd-specific functionality that would require more implementation from both teams, why not a flag you can pass bicep that just translate what they already support to something you already support:

Adding a flag to bicep that would do this is probably more palatable than adding azd-specific functionality and its certainly more portable. Then all azd has to do is pass this new flag and you get back a JSON stream that you already support.

heaths commented 2 weeks ago

BTW: no need to save this to a file on disk - nor the main.bicep file. Maybe it was added later, but bicep build and bicep build-params has a --stdout flag so you can just unmarshal from os.Stdout and not have to worry about cleaning up temp file copies. /cc @ellismg @vhvb1989