Skip to content

Bicep auto install results in invalid json output from deployment #17379

@felipebbc

Description

@felipebbc

az feedback auto-generates most of the information requested below, as of CLI version 2.0.62

Describe the bug

When deploying a bicep file using az cli without having the bicep executable installed, the bicep auto install feature sends installation result messages to stdout. This breaks the ability to read and parse the expected json output from the deployment.

To Reproduce

  $output = az deployment sub create -f ./main.bicep -l centralus --subscription mysub --output json | Out-String | ConvertFrom-JSON

Error:

ConvertFrom-JSON : Invalid JSON primitive: Installing.
At line:1 char:128
+ ... tion mysub --output json | Out-String | ConvertFrom-JSON
+                                                          ~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [ConvertFrom-Json], ArgumentException
    + FullyQualifiedErrorId : System.ArgumentException,Microsoft.PowerShell.Commands.ConvertFromJsonCommand

Expected behavior

When bicep installation occurs in the background through the auto install, send installation messages to the az cli logger facility instead of stdout.

Environment summary

azure-cli 2.20.0

Additional context

Workaround:
To avoid this issue, run the 'az bicep install' command before 'az deployment' to avoid the auto install messages being sent to stdout.

  az bicep install
  $output = az deployment sub create -f ./main.bicep -l centralus --subscription mysub --output json | Out-String | ConvertFrom-JSON

Metadata

Metadata

Assignees

No one assigned

    Labels

    ARMaz resource/group/lock/tag/deployment/policy/managementapp/account management-groupService AttentionThis issue is responsible by Azure service team.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions