azure-cli: Error with Azure CLI 2.46.0 and Bicep if no bicep configuration exists

This is autogenerated. Please review and update as needed.

Describe the bug

Command Name az bicep install

Errors:

Installing Bicep CLI v0.14.85...
The command failed with an unexpected error. Here is the traceback:
No section: 'bicep'
Traceback (most recent call last):
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\knack/cli.py", line 233, in invoke
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/__init__.py", line 663, in execute
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/__init__.py", line 726, in _run_jobs_serially
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/__init__.py", line 697, in _run_job
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/__init__.py", line 333, in __call__
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/command_operation.py", line 121, in handler
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/command_modules/resource/custom.py", line 3648, in install_bicep_cli
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/command_modules/resource/_bicep.py", line 141, in ensure_bicep_installation
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\knack/config.py", line 99, in get
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\knack/config.py", line 94, in get
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\knack/config.py", line 208, in get
  File "configparser.py", line 783, in get
  File "configparser.py", line 1154, in _unify_values
configparser.NoSectionError: No section: 'bicep'

To Reproduce:

Steps to reproduce the behavior. Note that argument values have been redacted, as they may contain sensitive information.

  • install Azure CLI 2.46.0
  • az bicep install --version {}

Expected Behavior

No error if configuration is not set.

Environment Summary

Windows-10-10.0.17763-SP0
Python 3.10.10
Installer: MSI

azure-cli 2.46.0

Additional Context

This error also happens when running an az deployment command passing a bicep file. It seems that the code is not resilient if no configuration for bicep is specified in the config file.

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Reactions: 21
  • Comments: 33 (1 by maintainers)

Commits related to this issue

Most upvoted comments

I have the same problem, the installation works when I set: az config set bicep.use_binary_from_path=False. The problem occurs since version 2.46.0.

@krizskp

@qetza @kurt-mueller-osumc @dawidholka Thanks for the feedback! We have worked up a PR to address this. Please do note that despite this error, the bicep CLI is installed and can be used as usual.

The error breaks automated deployment pipelines though. I use BitBucket Pipelines for deployment and face this same error message. The pipeline fails at this error message from az deployment ... command in the pipeline.

I also have this problem when running the pipeline and az deployment ... command. I solved this problem by adding at the beginning:

az config set bicep.use_binary_from_path=False
az bicep install

I haven’t tested yet how this would work with: az config set bicep.use_binary_from_path=if_found_in_ci

@qetza @kurt-mueller-osumc @dawidholka Thanks for the feedback! We have worked up a PR to address this.

Please do note that despite this error, the bicep CLI is installed and can be used as usual.

The error breaks automated deployment pipelines though. I use BitBucket Pipelines for deployment and face this same error message. The pipeline fails at this error message from az deployment ... command in the pipeline.

@krizskp

@qetza @kurt-mueller-osumc @dawidholka Thanks for the feedback! We have worked up a PR to address this. Please do note that despite this error, the bicep CLI is installed and can be used as usual.

The error breaks automated deployment pipelines though. I use BitBucket Pipelines for deployment and face this same error message. The pipeline fails at this error message from az deployment ... command in the pipeline.

I also have this problem when running the pipeline and az deployment ... command. I solved this problem by adding at the beginning:

az config set bicep.use_binary_from_path=False
az bicep install

I haven’t tested yet how this would work with: az config set bicep.use_binary_from_path=if_found_in_ci

Another workaround is to run the same az command twice, as the first time it will fail and the second time it succeeds.

Anyone facing this issue when trying to set to false, it causes any Azure Pipelines to fail.


az config set bicep.use_binary_from_path=false

az bicep install

image

I’m not seeing that issue but I put those two lines in their own PowerShell task and set standarderror to false and continueonerror to true because as long as they run (even failing) the next bicep command should work.

All deployments failing here as well, on an Agent in a deployment agent pool.

/usr/bin/bash /home/azuredevops/azdoAgent/_work/_temp/azureclitaskscript1678703942369.sh
ERROR: No section: 'bicep'
##[error]Script failed with exit code: 1

Temporary solution: Until fixed, downgrading version to az cli 2.45 seems to solve the issue. On agent VM run: sudo apt-get install azure-cli=2.45.0-1~focal

Mind: when fixed, upgrade az cli again!

@qetza @kurt-mueller-osumc @dawidholka Thanks for the feedback! We have worked up a PR to address this.

Please do note that despite this error, the bicep CLI is installed and can be used as usual.

I’ve tried the az config work around, and have now got our bit bucket pipelines working.

Thanks @dawidholka! 😄

@dawidholka Thanks, didn’t get a chance to test it out since my pipelines seem to be working today. Hopefully the issue has been fixed globally.

Is this the same issue that I’m facing when using the AzureResourceManagerTemplateDeployment@3 Azure Pipeline task? My error message for the past week is:

##[error]Check out the troubleshooting guide to see if your issue is addressed: https://docs.microsoft.com/en-us/azure/devops/pipelines/tasks/deploy/azure-resource-group-deployment?view=azure-devops#troubleshooting
##[error]Error: Command failed: az bicep build --file /agent/_work/1/s/ARMTemplates/goweb/prod/prod-goweb.bicep
ERROR: The command failed with an unexpected error. Here is the traceback:
ERROR: No section: 'bicep'

This is crippling for my ARM deployments! And the workaround by first running this script doesn’t do anything for me:

az config set bicep.use_binary_from_path=false
az bicep install

This workaround works for me with AzureCLI@2 task and setting input: useGlobalConfig: true.

I can confirm that I receive this same error when running inside an aarch64 devcontainer. I’ve been installing azure cli via python since apt apparently only supports the x86 architecture.

Here are my specs:

Version: 1.77.0-insider
Commit: bbc87d8ec2453f12c0066e1c30b41cd5bd2aa021
Date: 2023-03-07T05:36:47.728Z
Electron: 19.1.11
Chromium: 102.0.5005.196
Node.js: 16.14.2
V8: 10.2.154.26-electron.0
OS: Darwin arm64 22.3.0
Sandboxed: Yes