Cómo instalar correctamente la CLI de Azure

Cómo instalar correctamente la CLI de Azure

Tengo problemas al instalar la CLI de Azure. Probé tres métodos pero todos fallaron.

Los dos primeros son deInstale la CLI de Azure en Windows, He intentado

  • instalar la CLI de Azure mediante PowerShell y
  • Descargue e instale yo mismo la última versión del archivo .msi de la CLI de Azure.
  • Intenté eliminarlo y también lo reinstalé usando el archivo .msi.

Pero en todos los casos, si escribo az, obtendré

az : The term 'az' is not recognized as the name of a cmdlet, function, script file, or operable program.

Entonces lo intentéInstale la CLI de Azure en Linuxcomo último recurso, pero también falló:

+ echo 'deb [arch=amd64] https://packages.microsoft.com/repos/azure-cli/ bullseye main'
+ apt-get update
Hit:1 http://security.debian.org/debian-security bullseye-security InRelease
Hit:2 http://deb.debian.org/debian bullseye InRelease                                                                
Hit:3 http://ftp.debian.org/debian bullseye-backports InRelease                                                      
Hit:4 http://deb.debian.org/debian bullseye-updates InRelease                                                        
Hit:5 http://ppa.launchpad.net/suntong001/ppa/ubuntu focal InRelease                               
Get:6 https://packages.microsoft.com/repos/azure-cli bullseye InRelease [10.4 kB]
Err:6 https://packages.microsoft.com/repos/azure-cli bullseye InRelease
  The following signatures couldn't be verified because the public key is not available: NO_PUBKEY EB3E94ADBE1229CF
Reading package lists... Done
W: http://security.debian.org/debian-security/dists/bullseye-security/InRelease: The key(s) in the keyring /etc/apt/trusted.gpg.d/microsoft.gpg are ignored as the file is not readable by user '_apt' executing apt-key.
W: http://deb.debian.org/debian/dists/bullseye/InRelease: The key(s) in the keyring /etc/apt/trusted.gpg.d/microsoft.gpg are ignored as the file is not readable by user '_apt' executing apt-key.
W: http://ftp.debian.org/debian/dists/bullseye-backports/InRelease: The key(s) in the keyring /etc/apt/trusted.gpg.d/microsoft.gpg are ignored as the file is not readable by user '_apt' executing apt-key.
W: http://deb.debian.org/debian/dists/bullseye-updates/InRelease: The key(s) in the keyring /etc/apt/trusted.gpg.d/microsoft.gpg are ignored as the file is not readable by user '_apt' executing apt-key.
W: http://ppa.launchpad.net/suntong001/ppa/ubuntu/dists/focal/InRelease: The key(s) in the keyring /etc/apt/trusted.gpg.d/microsoft.gpg are ignored as the file is not readable by user '_apt' executing apt-key.
W: https://packages.microsoft.com/repos/azure-cli/dists/bullseye/InRelease: The key(s) in the keyring /etc/apt/trusted.gpg.d/microsoft.gpg are ignored as the file is not readable by user '_apt' executing apt-key.
W: GPG error: https://packages.microsoft.com/repos/azure-cli bullseye InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY EB3E94ADBE1229CF
E: The repository 'https://packages.microsoft.com/repos/azure-cli bullseye InRelease' is not signed.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.

Respuesta1

En Windows, puede encontrar la CLI de Azureaz.cmdaquí:
C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\wbin

Y esta ruta se puede encontrar en la variable de entorno Path: ingrese la descripción de la imagen aquí

Potencia Shell: $Env:Path

C:\Archivos de programa (x86)\Microsoft SDK\Azure\CLI2\wbin;

Si instala la CLI de Azure con un archivo msi, instalará la aplicación y agregará la ubicación a la Pathvariable.

Si hay un PowerShell abierto, Pathno se actualiza automáticamente en segundo plano. Tienes que cerrar PowerShell y abrir una nueva sesión. Por lo general, Pathse carga la actualización . Este comportamiento también se aplica a muchas más aplicaciones.

Por lo tanto, podría tener sentido (o si quiere estar seguro) reiniciar su máquina.

Por cierto: también es posibleactualizar las variables de entorno en Windows 11 (sin reiniciar)con, por ejemplo, chocolate

información relacionada