Search code examples
azureazure-cliazure-bicep

az bicep upgrade command giving me a different error wherever the terminal I execute


az bicep upgrade
The command failed with an unexpected error. Here is the traceback:
[WinError 193] %1 is not a valid Win32 application
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 664, in execute
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/__init__.py", line 731, 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 701, in _run_job
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/__init__.py", line 334, 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 4655, in upgrade_bicep_cli
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/command_modules/resource/_bicep.py", line 119, in ensure_bicep_installation
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/command_modules/resource/_bicep.py", line 275, in _get_bicep_installed_version
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/command_modules/resource/_bicep.py", line 327, in _run_command
  File "subprocess.py", line 548, in run
  File "subprocess.py", line 1026, in __init__
  File "subprocess.py", line 1538, in _execute_child
OSError: [WinError 193] %1 is not a valid Win32 application

We are deploying the Azure Infra using bicep templates and azure cli commands from a long time. Never experienced this error but when I tried to do upgrade of bicep using the command az bicep upgrade, I got this error.

Even the command az bicep version giving the same error suddenly in my system.

what is the root cause of this error and how to resolve it?


Solution

  • When we do run the command in any terminal az bicep upgrade and terminate the operation without completing the upgrade fully, then we will be getting this error.

    With reference to this MS Doc of Azure Bicep, if you get the issues like above on az bicep commands, do uninstall and install it clearly.

    1. Uninstall the bicep modules with the command az bicep uninstall.

    2. Close the terminal or command prompt and reopen the terminal or command prompt or vs code as administrator and then run the command az bicep install to reinstall the bicep fully.

    C:\Users\kamali>az bicep install
    Installing Bicep CLI v0.29.47...
    Successfully installed Bicep CLI to "C:\Users\kamali\.azure\bin\bicep.exe".
    

    enter image description here

    You will wait for the full operation completion and then check the installed version using the command az bicep version.

    C:\Users\kamali>az bicep version
    Bicep CLI version 0.29.47 (132ade51bc)
    

    enter image description here