Search code examples
pythonazureazure-cliazure-bicep

WinError 193 %1 is not a valid Win32 application. az bicep


When I try to run az bicep version I'm getting this error

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 729, 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 698, 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 4601, in show_bicep_cli_version
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/command_modules/resource/_bicep.py", line 94, in run_bicep_command
  File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/command_modules/resource/_bicep.py", line 267, 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 305, 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

And the same error I have running all az bicep *** commands.

I tried to reinstall azure cli. Did not help. I deleted py related paths from PATH env variables. That was a suggestion from some github issue page.


Solution

  • The most likely cause of your error is that the bicep executable installed by Azure CLI is corrupted. See Issue #2364 on their repository.

    As described in this comment you can clean up the %USERPROFILE\.azure\bin directory and run az bicep install to get it working.