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

Add --all parameter to bicep build #1285

Open
StefanIvemo opened this issue Jan 8, 2021 · 9 comments · May be fixed by #16456
Open

Add --all parameter to bicep build #1285

StefanIvemo opened this issue Jan 8, 2021 · 9 comments · May be fixed by #16456
Labels
cli Affects command line experience enhancement New feature or request

Comments

@StefanIvemo
Copy link
Collaborator

Is your feature request related to a problem? Please describe.
When authoring bicep modules I tend to end up with multiple .bicep files in the same folder. It would be nice if I could build all .bicep files in a folder at the same time.

Describe the solution you'd like
I would like to have a --all parameter to bicep build that compiles all .bicep files in the working directory.

bicep build --all - Compiles all .bicep files in the working directory.
bicep build --all --path /bicep/modules - Compiles all .bicep files in the /bicep/modules folder.

@StefanIvemo StefanIvemo added the enhancement New feature or request label Jan 8, 2021
@ghost ghost added the Needs: Triage 🔍 label Jan 8, 2021
@anthony-c-martin
Copy link
Member

anthony-c-martin commented Jan 8, 2021

Note that on OSX/Linux, you can currently achieve this with:

bicep build *.bicep

Or:

bicep build ./path/to/*.bicep

@StefanIvemo
Copy link
Collaborator Author

@anthony-c-martin ok, cool! I tried that on Windows but couldn't get it to work.

@anthony-c-martin
Copy link
Member

It's definitely more clunky on Windows - if using PowerShell you can do something like:

Get-ChildItem -Filter *.bicep | foreach { bicep build $_.FullName }

Or

Get-ChildItem -Path ./module/path -Filter *.bicep | foreach { bicep build $_.FullName }

@StefanIvemo
Copy link
Collaborator Author

StefanIvemo commented Jan 8, 2021

I personally like this workaround that I was taught today.

Just run this one liner first in my terminal: function bbuild {​bicep build (get-childitem *.bicep | % name)}​

Then I can just run bbuild in my terminal to execute the function every time I want to compile all my modules.

@anthony-c-martin
Copy link
Member

I personally like this workaround that I was thought today.

Very slick, thanks for sharing!

@StefanIvemo
Copy link
Collaborator Author

Took it one step further and created a Bicep PowerShell Module 😊

@alex-frankel
Copy link
Collaborator

Awesome! I'll leave this open in case anyone wants to add this to the CLI, but this is a great alternative.

@ugreg
Copy link
Member

ugreg commented Sep 26, 2022

Note that on OSX/Linux, you can currently achieve this with:

bicep build *.bicep

Or:

bicep build ./path/to/*.bicep

Tried this on Ubuntu @anthony-c-martin and got this error

I ran az bicep build *.bicep and got:

the following arguments are required: --file/-f

Examples from AI knowledge base:
az bicep build --file {bicep_file}
Build a Bicep file.

az bicep build --file {bicep_file} --stdout
Build a Bicep file and print all output to stdout.

az bicep build --file {bicep_file} --outdir {out_dir}
Build a Bicep file and save the result to the specified directory.

https://aka.ms/cli_ref
Read more about the command in reference docs

@anthony-c-martin
Copy link
Member

@ugreg my command was for the bicep CLI (not az CLI). Here's how I'd do it with az CLI:

  • OSX/Linux:
    for f in `find -name "*.bicep"`; do az bicep build -f $f; done
  • Windows:
    Get-ChildItem -Filter *.bicep | foreach { az bicep build -f $_.FullName }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cli Affects command line experience enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants