[Feature Request] Replace entry script `az.cmd` with `az.exe` on Windows
- Dominant language
- Python
- Stars
- 4.6k
- Forks
- 3.5k
- Avg merge
- 3d 2h
- Merged PRs (30d)
- 60
Description
**Is your feature request related to a problem? Please describe.**
Currently on Windows, a cmd file is used as the entry point for Azure CLI: `C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\wbin\az.cmd`
This causes several problems:
1. https://github.com/Azure/azure-cli/issues/15529. There was an attempt https://github.com/Azure/azure-cli/pull/23514 to add `az.ps1` for PowerShell, but that caused more issues and got reverted by https://github.com/Azure/azure-cli/pull/24015
3. Pressing Ctrl+C can't terminate `az` commands immediately. Instead, `Terminate batch job (Y/N)?` is shown:

4. `az.cmd` can't be invoked by running `az` in WSL, Cygwin or Git Bash. The `az` Bash entry script introduced by https://github.com/Azure/azure-cli/pull/13197 caused more issues: https://github.com/Azure/azure-cli/issues/13573
**Describe the solution you'd like**
Replace entry script `az.cmd` with `az.exe` on Windows.
**Additional context**
- The current `az.cmd` implementation requires Azure CLI to bundle a Python executable `C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\python.exe`. This Python interpreter is considered not secure by some restrictions and organizations, because it allows using build-in modules such as [`ctypes`](https://docs.python.org/3/library/ctypes.html) to execute arbitrary native code, bypassing enforcements such as [Windows Defender Application Control (WDAC)](https://learn.microsoft.com/en-us/windows/security/threat-protection/windows-defender-application-control/wdac-and-applocker-overview).
- We investigated using PyInstaller years ago in https://github.com/Azure/azure-cli/pull/16115 but that PR didn't get merged.
- There is a similar feature request https://github.com/Azure/azure-cli/issues/23397 focusing on packaging the whole Azure CLI as a standalone binary on all platforms including Linux, while this feature request only focuses on `az.exe` entry point on Windows and we may still have py files in the MSI package.
Contributor guide
Assessment
This issue has not been assessed yet.