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

Auto-generate parameter files #512

Closed
pazdedav opened this issue Sep 17, 2020 · 21 comments · Fixed by #6601
Closed

Auto-generate parameter files #512

pazdedav opened this issue Sep 17, 2020 · 21 comments · Fixed by #6601
Assignees
Labels
devdiv Related to Bicep tooling efforts in DevDiv good first issue Good for newcomers revisit
Milestone

Comments

@pazdedav
Copy link

Is your feature request related to a problem? Please describe.
Bicep generates (builds) ARM JSON templates, but it does not generate parameter files.

Describe the solution you'd like
Use all declared parameters from a {filename}.bicep file and generate a {filename}.parameters.json file by using e.g. bicep build --generate-params-file switch.

@pazdedav pazdedav added the enhancement New feature or request label Sep 17, 2020
@ghost ghost added the Needs: Triage 🔍 label Sep 17, 2020
@alex-frankel alex-frankel added revisit and removed enhancement New feature or request labels Oct 14, 2020
@alex-frankel
Copy link
Collaborator

Revisit this when we have resolved #399

@majastrz
Copy link
Member

One interesting scenario to consider here is simplifying parameters for services with complex topologies. Can we do something to make it easier for users that own services that operate in multiple clouds and/or locations?

@alex-frankel
Copy link
Collaborator

Just a note on this one, @StefanIvemo created a powershell module to help with this problem that may be of use to you.

@lazarillo
Copy link

This is nice, but isn't the right solution to be able to create and use a <mymodule>.parameters.bicep files?

What I mean is, isn't there a process to make all JSON code redundant so that we can eventually move everything over to Bicep? I want to be able to create my modules and parameters via Bicep files.

Is this (full Bicep adoption) in the works?

@alex-frankel
Copy link
Collaborator

Is this (full Bicep adoption) in the works?

Tracked with #399.

The order in which we want to tackle "parameter improvements" is the following:

We suspect that 1278 will get you 80% of the way there in terms of pushing errors left to authoring-time. At that point, we will re-evaluate how important 399 is.

@lazarillo
Copy link

Super cool! Thanks, @alex-frankel . Apologies, I had done a search, but did not run across #399

@anthony-c-martin
Copy link
Member

Once this has been implemented, #3381 should be straightforward to add.

@ucheNkadiCode ucheNkadiCode added the devdiv Related to Bicep tooling efforts in DevDiv label Apr 13, 2022
@ucheNkadiCode
Copy link
Contributor

This is related to #1759 as a means of closing the gap between ARM and Bicep

@ucheNkadiCode
Copy link
Contributor

We've heard a few more customers would love this feature. @polatengin, what's your status on this?

@polatengin
Copy link
Member

polatengin commented Apr 20, 2022

We've heard a few more customers would love this feature. @polatengin, what's your status on this?

I had a sync call with Marcin last Friday, I know what I should do, I'm currently working on the feature. I'll update here in a week 👍 @ucheNkadiCode

@ucheNkadiCode
Copy link
Contributor

Awesome! Thank you @polatengin, we look forward to this PR. I'll check back a little later.

@polatengin
Copy link
Member

Awesome! Thank you @polatengin, we look forward to this PR. I'll check back a little later.

I created the PR #6601 couple of days ago, please let me know when you review it, @ucheNkadiCode 👍

@ucheNkadiCode
Copy link
Contributor

image

I think this customer excerpt is related

@ucheNkadiCode
Copy link
Contributor

ucheNkadiCode commented May 19, 2022

In our upcoming discussion of this feature, @polatengin presented multiple options.

  • if there is a file with the same name, overwrite (current behavior of PR)
  • if there is a file with the same name, generate a new name and continue (This is a good option)
  • if there is a file with the same name, find the diff, apply changes (another good option, best user experience, a bit more complex technically)
  • if there is a file with the same name, fail (I do not recommend this option)

@ucheNkadiCode
Copy link
Contributor

Discussion today:
What we will do is a simplified algorithm of the third optionn.

If a user selects "Generate params file". If there is a parameters.json file of the same name (e.g fun.parameters.json), we will gracefully add to the file and remove parameters that have been removed from the current file.

We must also handle the scenario where a user adds/removes a default value for any of the parameters during this command.

If they need to rename the file, they can use the VS Code capabilities to do so, we will not worry about it.

If the user accidentally removes a parameter and we remove it from their overwritten paramers.json file, that's okay and they can use git source control to figure out the old values.

Thanks again @polatengin

Repository owner moved this from Todo to Done in Bicep Jun 8, 2022
@flarsmar
Copy link

Hello,

Is this documented somewhere?

@benc-uk
Copy link

benc-uk commented Jun 15, 2022

I've tried running bicep generate-params myfile.bicep and all I get is an parameters.json file with an empty parameters section

@anthony-c-martin
Copy link
Member

@benc-uk looking at it now, I think it's only going to generate entries for parameters which haven't been defaulted in your Bicep file. Could that explain why the parameters file is empty?

What sort of behavior would you like to see here?

@benc-uk
Copy link

benc-uk commented Jun 15, 2022

Yes I validated this behaviour. I do have defaults for all my parameters. I suppose I expected the defaults to be mirrored into the new file as the defaults in there.

@anthony-c-martin
Copy link
Member

Yes I validated this behaviour. I do have defaults for all my parameters. I suppose I expected the defaults to be mirrored into the new file as the defaults in there.

That makes sense, I can definitely see the need to also include defaulted parameters. Would you mind raising an issue for that?

@ucheNkadiCode
Copy link
Contributor

ucheNkadiCode commented Jun 15, 2022

Thanks @benc-uk! We appreciate the feedback. So one of the reasons we decided to not transfer over param defaults into the autogenerate parameter files was because a parameter file cannot handle values like "resourceGroup().location". So we just thought it was safer to do so in all situations. I have two questions for you:

  1. Would you want/be okay with us continuing to not carry over parameter values if it is using expressions like resourceGroup().location?" What would you expect in that situation
  2. If you make changes to defaults in your Bicep file, if you click auto-generate params once again, would you personally want those values to be carried over and overwritten in the Parameters file?

Feel free to post a separate issue and we can continue the conversation there!

@ghost ghost locked as resolved and limited conversation to collaborators May 29, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
devdiv Related to Bicep tooling efforts in DevDiv good first issue Good for newcomers revisit
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

10 participants