azure-cli icon indicating copy to clipboard operation
azure-cli copied to clipboard

az bicep prints version information when check_version is false

Open waggonerh opened this issue 11 months ago • 8 comments

Describe the bug

When publishing bicep modules ("az publish") to our container registry, we receive the below output for each file:

Bicep CLI is already installed at '/agent/_work/_temp/.azclitask/bin/bicep'. Skipping installation as no specific version was requested.

We deploy around 100 files to the registry. This line is printed for every file, bloats the output and makes troubleshooting tedious.

We set the below flag, but it does not stop the output:

az config set bicep.check_version=false

Possible source: https://github.com/Azure/azure-cli/blob/2a6319e38494ba1a316b04391ad0d8a8cf86068b/src/azure-cli/azure/cli/command_modules/resource/_bicep.py#L137C13-L137C18

Related command

az config set bicep.check_version=false

az bicep publish --file $filePath --target "br:*****.azurecr.io/infrastructure/bicep/imports:$importName" --with-source --force

Errors

Bicep CLI is already installed at '/agent/_work/_temp/.azclitask/bin/bicep'. Skipping installation as no specific version was requested.

Issue script & Debug output

cli.knack.cli: Command arguments: ['bicep', 'publish', '--file', '.\Bicep\Imports\Functions.bicep', '--target', 'br:.azurecr.io/infrastructure/bicep/imports:functions', '--with-source', '--force', '--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 0x000001417BCD45E0>, <function OutputProducer.on_global_arguments at 0x000001417C261940>, <function CLIQuery.on_global_arguments at 0x000001417C2BB880>] 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 1.245 52 234 cli.azure.cli.core: Total (1) 1.245 52 234 cli.azure.cli.core: These extensions are not installed and will be skipped: ['azext_ai_examples', 'azext_next'] cli.azure.cli.core: Loading extensions: cli.azure.cli.core: Name Load Time Groups Commands Directory cli.azure.cli.core: Total (0) 0.000 0 0 cli.azure.cli.core: Loaded 52 groups, 234 commands. cli.azure.cli.core: Found a match in the command table. cli.azure.cli.core: Raw command : bicep publish cli.azure.cli.core: Command table: bicep publish cli.knack.cli: Event: CommandInvoker.OnPreCommandTableTruncate [<function AzCliLogging.init_command_file_logging at 0x000001417E9F11C0>] cli.azure.cli.core.azlogging: metadata file logging enabled - writing logs to '.azure\commands\2025-12-26.09-59-08.bicep_publish.25284.log'. az_command_data_logger: command args: bicep publish --file {} --target {} --with-source --force --debug cli.knack.cli: Event: CommandInvoker.OnPreArgumentLoad [<function register_global_subscription_argument..add_subscription_parameter at 0x000001417EA36700>] cli.knack.cli: Event: CommandInvoker.OnPostArgumentLoad [] cli.knack.cli: Event: CommandInvoker.OnPostCommandTableCreate [<function register_ids_argument..add_ids_arguments at 0x000001417EA5CA40>, <function register_cache_arguments..add_cache_arguments at 0x000001417EA5CC20>, <function register_upcoming_breaking_change_info..update_breaking_change_info at 0x000001417EA5CCC0>] cli.knack.cli: Event: CommandInvoker.OnCommandTableLoaded [] cli.knack.cli: Event: CommandInvoker.OnPreParseArgs [] cli.knack.cli: Event: CommandInvoker.OnPostParseArgs [<function OutputProducer.handle_output_argument at 0x000001417C2619E0>, <function CLIQuery.handle_query_parameter at 0x000001417C2BB920>, <function register_ids_argument..parse_ids_arguments at 0x000001417EA5CAE0>] cli.azure.cli.command_modules.resource._bicep: Current value of "use_binary_from_path": false. Bicep CLI is already installed at '*.azure\bin\bicep.exe'. Skipping installation as no specific version was requested. cli.azure.cli.command_modules.resource._bicep: Current value of "use_binary_from_path": false. cli.azure.cli.command_modules.resource._bicep: Current value of "use_binary_from_path": false. cli.azure.cli.command_modules.resource._bicep: Current value of "use_binary_from_path": false. cli.azure.cli.command_modules.resource._bicep: Current value of "use_binary_from_path": false. cli.azure.cli.command_modules.resource._bicep: Current value of "use_binary_from_path": false. cli.azure.cli.command_modules.resource._bicep: Bicep CLI installation path: ***.azure\bin\bicep.exe cli.azure.cli.command_modules.resource._bicep: Bicep CLI installed: True. cli.knack.cli: Event: CommandInvoker.OnTransformResult [<function _resource_group_transform at 0x000001417EA36020>, <function x509_from_base64_to_hex_transform at 0x000001417EA360C0>] 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 0x000001417E9F1440>] az_command_data_logger: exit code: 0 cli.main: Command ran in 12.232 seconds (init: 1.108, invoke: 11.124) telemetry.main: Begin splitting cli events and extra events, total events: 1 telemetry.client: Accumulated 0 events. Flush the clients. telemetry.main: Finish splitting cli events and extra events, cli events: 1 telemetry.save: Save telemetry record of length 3745 in cache file under ***.azure\telemetry\20251226095918373 telemetry.main: Begin creating telemetry upload process. telemetry.process: Creating upload process: "C:\Program Files\Microsoft SDKs\Azure\CLI2\python.exe C:\Program Files\Microsoft SDKs\Azure\CLI2\Lib\site-packages\azure\cli\telemetry_init.pyc ***.azure ***.azure\telemetry\20251226095918373" telemetry.process: Return from creating process 16848 telemetry.main: Finish creating telemetry upload process.

Expected behavior

Setting bicep check_version=false should disable version related outputs, or version related outputs should be behind --debug.

Environment Summary

az --version

azure-cli 2.81.0

core 2.81.0 telemetry 1.1.0

Extensions: account 0.2.5 application-insights 1.2.3 automation 1.0.0b1 azure-devops 1.0.2 azure-firewall 2.0.0 datafactory 1.0.4 dns-resolver 1.2.0 front-door 1.4.0 logic 1.1.0 maintenance 1.7.0b1 ml 2.40.1 monitor-control-service 1.2.0 notification-hub 2.0.0b1 portal 1.0.0b2 reservation 0.3.1 resource-graph 2.1.1 site-recovery 1.0.0 ssh 2.0.6

Dependencies: msal 1.34.0b1 azure-mgmt-resource 23.3.0

Python location 'C:\Program Files\Microsoft SDKs\Azure\CLI2\python.exe' Config directory 'C:\Users\HalWaggoner.azure' Extensions directory 'C:\Users\HalWaggoner.azure\cliextensions'

Python (Windows) 3.13.9 (tags/v3.13.9:8183fa5, Oct 14 2025, 14:09:13) [MSC v.1944 64 bit (AMD64)]

Legal docs and information: aka.ms/AzureCliLegal

Your CLI is up-to-date.

az bicep version

Bicep CLI version 0.39.26 (1e90b06e40)

Additional context

No response

waggonerh avatar Dec 26 '25 16:12 waggonerh

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

yonzhan avatar Dec 26 '25 16:12 yonzhan

This is also very annoying when you want handle the output of an deployment: e.g.

$output = az deployment group create | convertto-json

This causing an invalid json file

BasBerk avatar Jan 22 '26 08:01 BasBerk

Same here. I am unable to normally parse output as a valid json now, only by parsing json object manually.

sdzunenko avatar Jan 22 '26 12:01 sdzunenko

This is the same as https://github.com/Azure/azure-cli/issues/32549

mwillebrands-caesar avatar Feb 10 '26 08:02 mwillebrands-caesar

On Linux, you can retrieve JSON using the sed command as shown in the code snippet below:

DEPLOYMENT_OUTPUTS=$($AZ deployment group create \
	--resource-group $RESOURCE_GROUP_NAME \
	--only-show-errors \
	--template-file $TEMPLATE \
	--parameters $PARAMETERS \
	--parameters location=$LOCATION \
	--query 'properties.outputs' \
	--output json
DEPLOYMENT_JSON=$(echo "$DEPLOYMENT_OUTPUTS" | sed -n '/{/,$ p')
echo "$DEPLOYMENT_JSON" | jq .

paolosalvatori avatar Feb 12 '26 10:02 paolosalvatori

This issue is specific to output clutter in the pipeline logs, not readability of json and therefore not a duplicate of 32549.

@yonzhan, the PR that closed 32549 may fix json output, but does not appear to reduce output bloat. Any guidance or update?

waggonerh avatar Apr 07 '26 15:04 waggonerh

Thanks for the clear report, and @a0x1ab for the root-cause write-up.

I reproduced this on 2.85.0: even with az config set bicep.check_version=false, an az bicep command still prints

Bicep CLI is already installed at '...'. Skipping installation as no specific version was requested.

to stdout (stderr stays empty). As @a0x1ab identified, in resource/_bicep.py that line is emitted by ensure_bicep_installation(...) and is gated only by an internal stdout flag — not by bicep.check_version. So the config flag doesn't suppress it, and because it lands on stdout it can corrupt captured JSON (the point @BasBerk and @sdzunenko raised). And as you clarified on April 7, this log-bloat is distinct from the JSON-formatting issue in #32549.

So this is a confirmed bug. Will triage this with the team.

torreymicrosoft avatar Jun 09 '26 21:06 torreymicrosoft

Bug Analysis: az bicep publish prints version info when check_version=false

Issue: When az config set bicep.check_version=false is set, the message "Bicep CLI is already installed at '...'. Skipping installation as no specific version was requested." is still printed for each az bicep publish call, bloating output especially when publishing many files.

Root Cause: The message is printed unconditionally in src/azure-cli/azure/cli/command_modules/resource/_bicep.py around line 137, regardless of the bicep.check_version config setting. The check_version flag only controls whether version checking is performed, but the "already installed" message should also be suppressed when this flag is false.

Fix: In src/azure-cli/azure/cli/command_modules/resource/_bicep.py, guard the "already installed / skipping installation" log/print statement so it is only emitted when check_version=true (or equivalent config is enabled). The fix should ensure the message is not printed when bicep.check_version=false.

Steps to reproduce:

  1. az config set bicep.check_version=false
  2. Run az bicep publish --file <file> --target <target> multiple times
  3. Observe: "Bicep CLI is already installed..." message appears each time

Expected: No installation-related output when check_version=false.

PR title & description format (required)

This repo enforces a PR format (guide). Please author the PR exactly as follows or CI's Check the Format of Pull Request Title and Content will fail.

Title

  • Start with [Resource] — square brackets [] for a customer-facing change (added to HISTORY.rst), curly {} if not. A bug fix is customer-facing, so use [].
  • Then Fix #32578: to link the issue.
  • Then optionally the affected command az <command>:.
  • Then a present-tense, capitalized verb (Fix for bug fixes; Add/Change/Deprecate/Remove otherwise) and a concise summary.
  • Recommended title: [Resource] Fix #32578: az <command>: Fix <concise description of the fix>

Description — follow the PR template and fill in:

  • Link the issue — start the Description with a closing keyword so the PR auto-links and closes it: Fixes #32578.
  • Related command — the az ... command this affects.
  • Description (mandatory) — why the bug happens, what you changed, and the resulting behavior.
  • Testing Guide — example command(s) showing the fix works.
  • History Notes — leave the title to drive the history note, or add [Resource] az <command>: <note> lines for extra notes.
  • Keep the template checklist and tick the items you've satisfied.

Posted by agent-assist (autonomous bug-fix pipeline).

azclibot avatar Jun 22 '26 19:06 azclibot