bicep icon indicating copy to clipboard operation
bicep copied to clipboard

Build with no Resources declared creates bad output

Open glloyd2010f opened this issue 4 years ago • 1 comments

Bicep version Bicep CLI version 0.6.18 (46dd19e8eb)

Describe the bug

  1. When doing a build on a bicep file that does not have any resources declared it will create the resources block as "resources": {}.
  2. When attempting to deploy the same file to a Bicep Registry it will fail the upload with the following error message.
pathToFolder\bicep\modules\naming.bicep(115,1) : Error BCP018: Expected the "]" character at this location.
pathToFolder\bicep\modules\naming.bicep(115,1) : Error BCP019: Expected a new line character at this location.

To Reproduce Steps to reproduce the behavior:

  1. Build
    1. Open VSCode
    2. Locate File in Explorer Blade
    3. Right Click on File
    4. Select Build ARM Template
    5. Open the new .json file
    6. Scroll down to the "resources": section
      1. Find "resources": {},
  2. Registry Deploy
    1. Open PowerShell 7.2.6
    2. Create $bicepFile Variable
      1. $bicepFile = 'pathToFolder\bicep\modules\naming.bicep'
    3. Create $bicepTargetRoot Variable
      1. $bicepTargetRoot = 'br:registryname.azurecr.io'
    4. Run az bicep publish --file $bicepFile --target "$bicepTargetRoot/bicep/modules/naming:v1"

EDIT Added a scrubbed copy of the build output. The file name will need to be changed from naming.json.txt to naming.json due to GitHub upload conditions.

naming.json.txt

glloyd2010f avatar Sep 16 '22 20:09 glloyd2010f

Since the running the bicep installer does not upgrade the az bicep commands, I was leveraging Bicep CLI version 0.6.18 (46dd19e8eb) instead of Bicep CLI version 0.10.61 (8f44805506) for my test. After running az bicep upgrade I can confirm that this bug was fixed in the 0.10.61 release.

glloyd2010f avatar Sep 19 '22 17:09 glloyd2010f