Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Azure Pipelines Azure CLI task - no colors when doing Bicep deployment #15473

Open
chudytom opened this issue Nov 3, 2021 · 24 comments
Open
Assignees

Comments

@chudytom
Copy link

chudytom commented Nov 3, 2021

Required Information

Entering this information will route you directly to the right team and expedite traction.

Question, Bug, or Feature?
Type: Bug

Enter Task Name: AzureCLI@2

Environment

  • Server - Azure Pipelines

    • If using Azure Pipelines, provide the account name, team project name, build definition name/build number:
      dongenergy-p/Power Hub/Pipelines/flexp-infra-bicep/20211103.7
  • Agent - Hosted or Private:

    • If using Hosted agent, provide agent queue name: MS Hosted agents - Ubuntu-20.04, from Azure Pipelines agent pool

Issue Description

I tried to deployed infrastructure using Azure Bicep. I did it using Azure CLI and specifically AzureCLI@2 task. It works, however when I use --what-if functionality the changes I see on the screen have no colors, which make the output much harder to read. When I run the same commands from my local CLI all the colors are visible.

Command used -
az deployment group create -f infrastructure/bicep/<project-name>.bicep --subscription=<project-name> -g <project-name> --parameters env=dev --mode=complete --name=<project-name>_20211103_1243 --what-if

Current behavior:
image

Expected behavior (from my local machine)
image

Task logs

Will provide it later if really needed

Troubleshooting

Checkout how to troubleshoot failures and collect debug logs: https://docs.microsoft.com/en-us/vsts/build-release/actions/troubleshooting

Done

Error logs

No errors even after enabling system diagnostics

@github-actions github-actions bot added Area: Release bug environment:need-to-triage Issues need to be triage by environment-deployment team labels Nov 3, 2021
@v-jkarri v-jkarri removed the environment:need-to-triage Issues need to be triage by environment-deployment team label Nov 10, 2021
@brettpostin
Copy link

This isn't specific to bicep templates either. I have a release stage to do a what-if analysis for approval on a compiled bicep template (so json).

The colour coding would be really helpful.

@github-actions
Copy link

github-actions bot commented Aug 7, 2022

This issue is stale because it has been open for 180 days with no activity. Remove the stale label or comment on the issue otherwise this will be closed in 5 days

@github-actions github-actions bot added the stale label Aug 7, 2022
@chudytom
Copy link
Author

chudytom commented Aug 7, 2022

@bishal-pdMSFT is there maybe any action planned on this issue?

@bishal-pdMSFT
Copy link
Contributor

@NAGA-BANDI can you please ask someone to look at thia

@github-actions github-actions bot removed the stale label Aug 7, 2022
@NAGA-BANDI
Copy link

NAGA-BANDI commented Aug 7, 2022 via email

@NAGA-BANDI
Copy link

NAGA-BANDI commented Aug 8, 2022 via email

@v-nagarajku
Copy link
Contributor

v-nagarajku commented Aug 8, 2022

Hi @chudytom

1.As per our understanding we believe from AzureCLI@2 task script type was selected as PowerShellCore which is responsible for the color coding. Is the agent machine(self-hosted) having PowerShell core installed explicitly or is it a MS Hosted agent?

2.Please share the complete logs for further investigation. Both successful logs and failure logs from the task.

@htuomola
Copy link

@v-nagarajku Colors are also not showing on hosted ubuntu-latest agent either, with task AzureCLI@2

- task: AzureCLI@2
  inputs:
    azureSubscription: <connection name>
    scriptType: bash
    scriptLocation: inlineScript
    inlineScript: |
      az --version
      az deployment sub create --what-if --location <....params>

image

also running on hosted windows-latest agent with scriptType: pscore makes no difference.

vs. in windows local terminal (ps core)
image

@ekersale
Copy link

ekersale commented Jan 31, 2023

@v-nagarajku Any update here ?

@NAGA-BANDI
Copy link

NAGA-BANDI commented Feb 1, 2023 via email

@rvairavelu
Copy link
Collaborator

@ekersale. This feature is not implemented. At present, we could not prioritize it, due to other critical issues in our queue.
cc @vijayma @NAGA-BANDI @v-nagarajku

@Kravca
Copy link

Kravca commented Mar 24, 2023

Anybody got some workaround for this?

@roofiq
Copy link

roofiq commented Apr 14, 2023

Up, it would be really handy

@Rod-Sychev
Copy link

Come on MSFT, this is basics!

@miniGweek
Copy link

MSFT Team, this is important!
While running the What-if step of bicep templates in our pipeline we need to see a colored output to make sense of what's getting modified, deleted or added! This is basics!
Please prioritize this!!

@arwinters
Copy link

Yes MSFT we are waiting on it.

@TiTi
Copy link

TiTi commented Feb 14, 2024

Any update on this topic ?

Azure declarative IaC language which is recommended is Bicep (see green box here: https://learn.microsoft.com/en-us/azure/templates/)
Unfortunately no color in Azure DevOps :-/
This is a real turn down for team work with centralized pipeline!

Can we please have a little bit of color for bicep in Azure DevOps ?

Note: color is working with terraform....

@anthony-c-martin
Copy link
Member

I did some digging on this, and chatted to @JamieMagee who gave me some great pointers.

Current theory:

  • The AzureCLI task (as well as other MS-published tasks) do use Node's child_process directly - instead they use a wrapper library to interact with the shell (see here)
  • The wrapper library is invoked here
  • Here's where the wrapper library uses child_process in the exec() method: see here
  • Theory is that the indirection or capturing of stdout/stderr here impacts Node's built-in mechanism to automatically detect shell color support.

We do not believe this was a deliberate decision - just an accidental result of the indirection.

An interesting test would be to try and set the env variable FORCE_COLOR to 1 to override Node's built-in color detection: https://nodejs.org/api/tty.html#writestreamgetcolordepthenv.

@TiTi
Copy link

TiTi commented Feb 15, 2024

Thanks for digging this @anthony-c-martin . Just tried it without success :/

@anthony-c-martin
Copy link
Member

Seems related to microsoft/azure-pipelines-agent#1569. AzureCLI uses 8bit color codes, which are unsupported by ADO.

@slavizh
Copy link

slavizh commented Feb 29, 2024

There is some not pretty workaround for PowerShell https://paul-mackinnon.medium.com/azure-devops-ansi-colour-coding-df8ef7406422
It is not pretty as not everything is 100% as would appear in regular PowerShell console. Overall the right way would be ADO to support 8bit color codes instead of Bicep team or we implement workarounds.

@TiTi
Copy link

TiTi commented Feb 29, 2024

Whatever I try, I can't output the escape sequence (ex: ``e[34m) even when trying to save az cli output in a file. (az deployment group what-if ...)
Thus the powershell workaround doesn't even work for az cli.
(i couldn't use New-Az[Subscription]Deployment because it didn't handle .bicepparam until recently ; and I just tried but got other issues preventing me to use it, it's a mess!)

It would be nice to have an option like PY_COLORS or ANSIBLE_FORCE_COLOR
"This option forces color mode even when running without a TTY"

@vuylstekeb
Copy link

+1 would be really useful to have

@Saulopv
Copy link

Saulopv commented Nov 11, 2024

+1 basic feature really..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests