4

I am struggling to install Azure CLI on a Ubuntu machine without root access.

The instructions here assume that we have root access (or reasonable sudo access).

I am trying to run this on a Ubuntu machine (provided by IBM DevOps toolchain - root access will never be granted) where executing the sudo command results in:

AZ_REPO=$(lsb_release -cs)
echo "deb [arch=amd64] https://packages.microsoft.com/repos/azure-cli/ $AZ_REPO main" | \
     sudo tee /etc/apt/sources.list.d/azure-cli.list

This results in sudo: no tty present and no askpass program specified

Why do I need a tty to run sudo? has some answers however I am not able to use them as I don't have control over the login to the shell via ssh.

I am using the IBM Cloud's DevOps toolchain to deploy applications to both IBM Cloud and Azure.

The DevOps toolchain provides me a shell for me to execute commands.

Are there other alternatives

Manglu
  • 10,744
  • 12
  • 44
  • 57

3 Answers3

2

Assuming that you have the required prerequisites installed, you can either use the script or plain 'ole pip to install the Azure CLI (pip install azure-cli). Personally, I often use the docker container as well.

1

Have you tried running the script as documented,

curl -L https://aka.ms/InstallAzureCli | bash

I do not see why sudo would be required to install az. The install script downloads a python script (this one) and runs it. This script basically

  1. Downloads virtualenv
  2. creates a virtual env at ~/lib/azure-cli
  3. calls pip install azure-cli on that virtual env
  4. writes a a shell script to ~/bin/az named az that runs python -m azure.cli and give it some permissions
  5. adds completion (tab) to az
Jorge Leitao
  • 19,085
  • 19
  • 85
  • 121
0

Based on my knowledge, this is possible. Root permission is required. You could check this answer to solve your issue, but I think you should have root permission to do this.

If possible, I suggest you could use Azure Cloud Shell to run cli command on Azure.

Shui shengbao
  • 18,746
  • 3
  • 27
  • 45