bicep icon indicating copy to clipboard operation
bicep copied to clipboard

Add --all parameter to bicep build

Open StefanIvemo opened this issue 4 years ago • 8 comments

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 avatar Jan 08 '21 13:01 StefanIvemo

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

bicep build *.bicep

Or:

bicep build ./path/to/*.bicep

anthony-c-martin avatar Jan 08 '21 18:01 anthony-c-martin

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

StefanIvemo avatar Jan 08 '21 18:01 StefanIvemo

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 }

anthony-c-martin avatar Jan 08 '21 19:01 anthony-c-martin

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.

StefanIvemo avatar Jan 08 '21 19:01 StefanIvemo

I personally like this workaround that I was thought today.

Very slick, thanks for sharing!

anthony-c-martin avatar Jan 08 '21 21:01 anthony-c-martin

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

StefanIvemo avatar Jan 13 '21 20:01 StefanIvemo

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

alex-frankel avatar Jan 13 '21 22:01 alex-frankel

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

ugreg avatar Sep 26 '22 18:09 ugreg

@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 }
    

anthony-c-martin avatar Oct 29 '22 18:10 anthony-c-martin