Azure / azure-cli

Azure Command-Line Interface
MIT License
3.96k stars 2.94k forks source link

bicep install/upgrade on aarch64 using wrong binary (linux-x64 instead of linux-arm64) #29435

Open ulfandersson opened 1 month ago

ulfandersson commented 1 month ago

Describe the bug

Host machine: Apple silicon (ARM, M1-M3) Mac

Inside debian based dev container (mcr.microsoft.com/devcontainers/javascript-node:0-20-bullseye):

$ az bicep install --debug
...
cli.azure.cli.command_modules.resource._bicep: Generated download URL https://downloads.bicep.azure.com/v0.29.45/bicep-linux-x64. from system Linux, machine aarch64, release tag v0.29.45 and target platform None.

Actual result: linux-x64 is used

Expected result: linux-arm64 should be used.

Proposed fix, add or machine == "aarch64" to the if statement here: https://github.com/Azure/azure-cli/blob/7df71d657c85c62b9d969df491faf5b5134fbdb3/src/azure-cli/azure/cli/command_modules/resource/_bicep.py#L290

Workaround $ az bicep uninstall $ az bicep install --target-platform linux-arm64

partly related issue: https://github.com/Azure/azure-cli/issues/28756 (however, once installed with correct target-platform I have no issue running bicep)

Related command

az bicep install

Errors

cli.azure.cli.command_modules.resource._bicep: Generated download URL https://downloads.bicep.azure.com/v0.29.45/bicep-linux-x64. from system Linux, machine aarch64, release tag v0.29.45 and target platform None.

Issue script & Debug output

$ az bicep install --debug cli.knack.cli: Command arguments: ['bicep', 'install', '--debug'] cli.knack.cli: init debug log: Enable color in terminal. cli.knack.cli: Event: Cli.PreExecute [] cli.knack.cli: Event: CommandParser.OnGlobalArgumentsCreate [<function CLILogging.on_global_arguments at 0xffffae72c0e0>, <function OutputProducer.on_global_arguments at 0xffffae6c62a0>, <function CLIQuery.on_global_arguments at 0xffffae49bd80>] cli.knack.cli: Event: CommandInvoker.OnPreCommandTableCreate [] cli.azure.cli.core: Modules found from index for 'bicep': ['azure.cli.command_modules.resource'] cli.azure.cli.core: Loading command modules: cli.azure.cli.core: Name Load Time Groups Commands cli.azure.cli.core: resource 0.043 51 231 cli.azure.cli.core: Total (1) 0.043 51 231 cli.azure.cli.core: Loaded 51 groups, 231 commands. cli.azure.cli.core: Found a match in the command table. cli.azure.cli.core: Raw command : bicep install cli.azure.cli.core: Command table: bicep install cli.knack.cli: Event: CommandInvoker.OnPreCommandTableTruncate [<function AzCliLogging.init_command_file_logging at 0xffffad69aa20>] cli.azure.cli.core.azlogging: metadata file logging enabled - writing logs to '/home/node/.azure/commands/2024-07-22.08-55-44.bicep_install.7090.log'. az_command_data_logger: command args: bicep install --debug cli.knack.cli: Event: CommandInvoker.OnPreArgumentLoad [<function register_global_subscription_argument..add_subscription_parameter at 0xffffad6d3a60>] cli.knack.cli: Event: CommandInvoker.OnPostArgumentLoad [] cli.knack.cli: Event: CommandInvoker.OnPostCommandTableCreate [<function register_ids_argument..add_ids_arguments at 0xffffad6eeca0>, <function register_cache_arguments..add_cache_arguments at 0xffffad6eede0>] cli.knack.cli: Event: CommandInvoker.OnCommandTableLoaded [] cli.knack.cli: Event: CommandInvoker.OnPreParseArgs [] cli.knack.cli: Event: CommandInvoker.OnPostParseArgs [<function OutputProducer.handle_output_argument at 0xffffae6c6340>, <function CLIQuery.handle_query_parameter at 0xffffae49be20>, <function register_ids_argument..parse_ids_arguments at 0xffffad6eed40>] urllib3.connectionpool: Starting new HTTPS connection (1): aka.ms:443 urllib3.connectionpool: https://aka.ms:443 "GET /BicepLatestRelease HTTP/1.1" 301 0 urllib3.connectionpool: Starting new HTTPS connection (1): downloads.bicep.azure.com:443 urllib3.connectionpool: https://downloads.bicep.azure.com:443 "GET /releases/latest HTTP/1.1" 200 39506 Installing Bicep CLI v0.29.45... cli.azure.cli.command_modules.resource._bicep: Generated download URL https://downloads.bicep.azure.com/v0.29.45/bicep-linux-x64. from system Linux, machine aarch64, release tag v0.29.45 and target platform None. cli.azure.cli.command_modules.resource._bicep: The configuration value of bicep.use_binary_from_path has been set to 'false'. Successfully installed Bicep CLI to "/home/node/.azure/bin/bicep". cli.knack.cli: Event: CommandInvoker.OnTransformResult [<function _resource_group_transform at 0xffffad6d3ec0>, <function _x509_from_base64_to_hex_transform at 0xffffad6d3f60>] cli.knack.cli: Event: CommandInvoker.OnFilterResult [] cli.knack.cli: Event: Cli.SuccessfulExecute [] cli.knack.cli: Event: Cli.PostExecute [<function AzCliLogging.deinit_cmd_metadata_logging at 0xffffad69aca0>] az_command_data_logger: exit code: 0

Expected behavior

bicep linux-arm64 binary should be used

Environment Summary

azure-cli 2.62.0

core 2.62.0 telemetry 1.1.0

Dependencies: msal 1.28.1 azure-mgmt-resource 23.1.1

Python location '/opt/az/bin/python3' Extensions directory '/home/node/.azure/cliextensions'

Python (Linux) 3.11.8 (main, Jul 4 2024, 02:26:33) [GCC 10.2.1 20210110]

Legal docs and information: aka.ms/AzureCliLegal

Your CLI is up-to-date.

Additional context

No response

yonzhan commented 1 month ago

Thank you for opening this issue, we will look into it.