skip to Main Content

I’m trying to install az cli on windows using ado pipeline using powershell task

Still az cli is not installing ?

Any proper script that can install az cli ?

I tried invoke web request to install and set env path but path isn’t getting added

2

Answers


  1. Not a proper answer, as I just wanted to comment but don’t have enough reputation.

    So, you are trying to install AZ cli on a machine through your pipeline, are you talking about the agent? If that’s so shouldn’t you use AzucreCLI Task to do whatever you need with CLI? The agent probably already has it unless it’s an on-prem one or self-hosted with some things modified.

    If it’s self-hosted or on-prem, you’ll need to install it (if it isn’t already there) (maybe you need the extension) This msdocu reference maybe can give you a little bit of light into that.

    With the info you gave I’m not sure I can help more, sorry If I didn’t tackle your question correctly.

    Login or Signup to reply.
  2. If you’re using Microsoft hosted agents, Azure CLI is already installed.

    You can then use an Azure CLI task to run Azure CLI commands:

    - task: AzureCLI@2
      displayName: Azure CLI
      inputs:
        azureSubscription: <Name of the Azure Resource Manager service connection>
        scriptType: ps
        scriptLocation: inlineScript
        inlineScript: |
          az --version
          az account show
    

    In case you’re using self-hosted agents, I’d suggest to install Azure CLI on the computer(s) or container that run the build and release agent, as opposed to using a Powershell task to install it on-the-fly. This makes sense if you run Azure CLI scripts in your pipelines often.

    Please note that if an agent is already running on the machine on which the Azure CLI is installed, restart the agent to ensure all the relevant stage variables are updated.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search