Skip to content

[BUG]: AzureCLI incorrectly processes out from "az deployment group create" #19431

Closed
@jeanpaulsmit

Description

New issue checklist

Task name

AzureCLI

Task version

2

Issue Description

I use the AzureCLI task to deploy resources using bicep, but I also need the output to know what are the names of the created resources.
When I use output=$(az deployment group create --name myDeployment --resource-group myRG.... the output contains a bit of the Bicep installer:

Installing Bicep CLI v0.24.24...
Successfully installed Bicep CLI to "/azp/_work/_temp/.azclitask/bin/bicep".

I am expecting just the JSON output from the az deployment group create

The task definition is like this:

- task: AzureCLI@2
  displayName: Deploy Bicep file
  inputs: 
    azureSubscription: ${{ parameters.serviceConnectionName }}
    scriptType: bash
    scriptLocation: inlineScript
    workingDirectory: '$(System.ArtifactsDirectory)'
    inlineScript: |
      # Deploying Bicep file and convert output values to variables
      output=$(az deployment group create --name myDeployment  --resource-group myRG --template-file ./main.bicep --parameters ./param.bicepparam --query properties.outputs -o json)
      echo "this is the output: $output"

The provisioning with Bicep works fine, but the output is displayed as:

/usr/bin/bash /home/vsts/work/_temp/azureclitaskscript123456.sh
WARNING: The configuration value of bicep.use_binary_from_path has been set to 'false'.
this is the output: Installing Bicep CLI v0.24.24...
Successfully installed Bicep CLI to "/home/vsts/work/_temp/.azclitask/bin/bicep".
{
  "functionAppEndpoint": {
    "type": "String",
    "value": "myfa.azurewebsites.net"
  },
  "functionAppName": {
    "type": "String",
    "value": "myfa"
  }
}
/usr/bin/az account clear

Notice the 'this is the output:' part of the response, this shows the 'Installing Bicep...' is actually returned from the az deployment group create.

Environment type (Please select at least one enviroment where you face this issue)

  • Self-Hosted
  • Microsoft Hosted
  • VMSS Pool
  • Container

Azure DevOps Server type

dev.azure.com (formerly visualstudio.com)

Azure DevOps Server Version (if applicable)

No response

Operation system

ubuntu-latest

Relevant log output

/usr/bin/bash /home/vsts/work/_temp/azureclitaskscript123456.sh
WARNING: The configuration value of bicep.use_binary_from_path has been set to 'false'.
this is the output: Installing Bicep CLI v0.24.24...
Successfully installed Bicep CLI to "/home/vsts/work/_temp/.azclitask/bin/bicep".
{
  "functionAppEndpoint": {
    "type": "String",
    "value": "myfa.azurewebsites.net"
  },
  "functionAppName": {
    "type": "String",
    "value": "myfa"
  }
}
/usr/bin/az account clear

Full task logs with system.debug enabled

 [REPLACE THIS WITH YOUR INFORMATION] 

Repro steps

1) create a basic Bicep file which returns a value
2) use the AzureCLI@2 task with this definition
- task: AzureCLI@2
  displayName: Deploy Bicep file
  inputs: 
    azureSubscription: ${{ parameters.serviceConnectionName }}
    scriptType: bash
    scriptLocation: inlineScript
    workingDirectory: '$(System.ArtifactsDirectory)'
    inlineScript: |
      # Deploying Bicep file and convert output values to variables
      output=$(az deployment group create --name myDeployment  --resource-group myRG --template-file ./main.bicep --parameters ./param.bicepparam --query properties.outputs -o json)
      echo "this is the output: $output"

3) run the pipeline to see the issue.

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions