This is for Powershell Core, Windows Powershell works with Win32 version through emulation.
Another quick tip for those developers out there with their shiny new Surface Laptop 7 or similar with Windows on ARM on it. Tried installing Azure CLI already, and everything went fine, but trying to run it didn’t work? You are not alone, as the official support at the time of writing (July 2024) is still lacking.
I managed to get around this, and here are the steps for you not to waste time and pull hair out in frustration, when chatGPT or Claude AI won’t tell you how to fix this.
Notice that this is a bit of a hacky thing, we create a virtual environment where we run it, but hey, if it works… right?
Prereq is to install Build tools through Visual Studio 2022 Free https://visualstudio.microsoft.com/downloads/ and select Desktop development with C++ and install all ARM related things. You also need to install Rust from https://forge.rust-lang.org/infra/other-installation-methods.html and select aarch64-pc-windows-msvc version.Install the Cargo folder to your path, something like “C:\users\USER\.rustup\toolchains\stable-aarch64-pc-windows-msvc\bin\”.
winget install --id Microsoft.Powershell --source winget
set-executionpolicy remotesigned
curl https://www.python.org/ftp/python/3.12.0/python-3.12.0-arm64.exe -O python-3.12.0-arm64.exe
Now we have prerequisites in place, and it’s time for some Powershell magic:
# Create a virtual environment
python3 -m venv azure-cli-env
# Update pip
azure-cli-env/scripts/python -m pip install --upgrade pip
# Install azure-cli
azure-cli-env/scripts/python -m pip install azure-cli
azure-cli-env/scripts/python -m pip install setuptools
and after that, run this:
notepad $profile
Add to your profile file the following:
Set-Alias -Name az -Value "C:\azure-cli-env\Scripts\az.bat"
Restart your powershell, and running az should work now. Goes without saying, make sure the virtual environment path matches the location in the Set-Alias command.
Pingback: Dew Drop – July 15, 2024 (#4227) – Morning Dew by Alvin Ashcraft