Azure / azure-cli

Azure Command-Line Interface

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error with Azure CLI 2.46.0 and Bicep if no bicep configuration exists

qetza opened this issue · comments

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.

Thank you for your feedback. This has been routed to the support team for assistance.

route to CXP team

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

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.

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

@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

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

The same error breaks my Azure Pipelines when build agents upgraded to Azure CLI 2.46.0.

Breaking Azure Pipeline builds for me too. Tried workaround but still breaking. Currently can't deploy any of my infra from Pipelines. What's the timeframe for the fix?

We have the same issue on our agents. Workaround also don't seem to do the trick for use. Any news on the topic?

commented

Same error, resolved by using inline script in additional Task before running the main Task.
inlineScript: |
az config set bicep.use_binary_from_path=False
az bicep install

I am facing same issue bicep install fails. even after setting az config set bicep.use_binary_from_path=False , it produces warning on the console and build fails.

I am also facing the same issue in GitLab Pipelines
az deployment group create command is failing with error
ERROR: No section: 'bicep'
Retry worked for az deployment group validate command for the same parameters.

Update: az deployment group create command worked after 4 retries

This is also breaking my Azure Pipelines. Cannot deploy production changes!

Having same issue with our GitLab pipelines breaking. Any news?

Any news yet? All our deployments are failing now

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!

As a temporary solution, I also downgraded all agents to the previous version.

This issue seems related to a recent change
CLI 2.45.0 breaks Github Actions that tried to install a specific version of Bicep
Fix #25510: az bicep: Set bicep.use_binary_from_path to false when installed using Azure CLI

It also breaks pipelines using the latest image mcr.microsoft.com/azure-functions/dotnet:4-dotnet6-core-tools as Azure Cli 2.46.0 is internally referenced and installed.

As mentioned in the thread above, the az deploment command also fails.

For now, last week, we managed to fix this by including command
az config set bicep.use_binary_from_path=false

before az bicep install and az deployment commands. This work around is mentioned above in this thread and also on #25510

Can also confirm we are getting this error in Gitlad Pipeline deployments using the MS image
image: mcr.microsoft.com/azure-cli

can confirmed az config set bicep.use_binary_from_path=false got me around this also

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

breaking all pipelines on ubuntu , windows agents appear to be working for now

Still broken since last week. Workarounds aren't working for us.
If possible, a hotfix would be highly appreciated. Our workload is depending on bicep, which are all failing now.

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.

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

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

Thanks @dawidholka! 😄

Seeing this also on GitHub Actions deployments for my Azure Static Web App blog. Failing build: https://github.com/johnnyreilly/blog.johnnyreilly.com/actions/runs/4433656682/jobs/7810249789?pr=459

PR that triggered this: johnnyreilly/blog.johnnyreilly.com#459

We found that this issue may be related to the fact that Bicep is already installed on the agent running the build i.e. if running windows-latest in Azure DevOps. If we remove our "az bicep install" step, deployments run without any issues.

commented

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

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.

commented

Thanks adding those two lines in their own PowerShell task worked.

Example

- task: PowerShell@2
  displayName: "Install Bicep"
  inputs:
    targetType: 'inline'
    script: |         
          az config set bicep.use_binary_from_path=false
          az bicep install
    failOnStderr: false
    showWarnings: true
    pwsh: true

This is an extra burden for us when writing CI/CD pipelines, which is now broken due to this functionality. I have to add the flag use_binary_from_path=False and install Bicep CLI manually, which is really nasty.