azure-cli: WSL: Why Azure CLI is too slow at each command execution?

Describe the bug It’s not exactly a bug but every command at PowerShell or Bash in WSL is too slow, I know that every command is making a web-api request call but is really sad this api call is causing too much delay.

I don’t know if I am at Brazil and the all api calls is from US and those internet latence is the cause but is really bad.

To Reproduce Stay at Brazil and call a single command like az acr list.

Expected behavior I don’t know, but some loading indicator or proxy all api request call near Brazil…

Environment summary Windows 10 with PowerShell and WSL

λ  az --version
azure-cli (2.0.46)

acr (2.1.5)
acs (2.3.4)
advisor (0.6.0)
ams (0.2.3)
appservice (0.2.4)
backup (1.2.1)
batch (3.4.0)
batchai (0.4.3)
billing (0.2.0)
botservice (0.1.1)
cdn (0.1.1)
cloud (2.1.0)
cognitiveservices (0.2.3)
command-modules-nspkg (2.0.2)
configure (2.0.18)
consumption (0.4.0)
container (0.3.4)
core (2.0.46)
cosmosdb (0.2.1)
dla (0.2.3)
dls (0.1.3)
dms (0.1.1)
eventgrid (0.2.0)
eventhubs (0.2.4)
extension (0.2.1)
feedback (2.1.4)
find (0.2.12)
interactive (0.3.30)
iot (0.3.2)
iotcentral (0.1.2)
keyvault (2.2.3)
lab (0.1.1)
maps (0.3.2)
monitor (0.2.3)
network (2.2.5)
nspkg (3.0.3)
policyinsights (0.1.0)
profile (2.1.1)
rdbms (0.3.2)
redis (0.3.2)
relay (0.1.2)
reservations (0.4.0)
resource (2.1.4)
role (2.1.5)
search (0.1.1)
servicebus (0.2.3)
servicefabric (0.1.3)
signalr (1.0.0)
sql (2.1.4)
storage (2.2.2)
telemetry (1.0.0)
vm (2.2.3)

Python location 'C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\python.exe'
Extensions directory 'C:\Users\alexs\.azure\cliextensions'

Python (Windows) 3.6.5 (v3.6.5:f59c0932b4, Mar 28 2018, 16:07:46) [MSC v.1900 32 bit (Intel)]

Legal docs and information: aka.ms/AzureCliLegal

Additional context Every was slow here at Brazil, I don’t know if it is slow in another region, I’m posting it right now because I’m starting use Azure CLI constantly and I wish a better user experience.

Thank’s!

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 10
  • Comments: 51 (14 by maintainers)

Most upvoted comments

Why is this issue being closed?

With the introduction of Command Index (#13294) and migration to PEP 420 (#14372), the client-side execution speed of Azure CLI has been significantly improved. That’s why we closed this issue.

If the Azure CLI command involves Azure REST API invocation, Azure CLI will spend most of its time communicating with Azure REST API and do long-running operation query, which is out of our control. In such case, those changes won’t give you too much performance improvement.

Please share the command as @yonzhan asked. Thanks.

I’ve been digging into az-cli performance and submitted a few fixes here and there. You may find a few more hints by running --debug to see where time is spent.

Ideally az would do a much better job at optimizing its installation and extensions.

See:

the following pipeline task took 1 minute and 47 seconds!!!

- bash: echo "##vso[task.setvariable variable=pipelineId]$(az pipelines runs show --id ${{ parameters.buildId }} --query "definition.id" -o tsv)"

why on earth does that take so long to run???

I don’t think this is a WSL issue, I think this is an az CLI issue. I am observing differences in performance when comparing az CLI to PowerShell AZ. Why would az CLI commands run slower than PowerShell AZ?

My script and an example observation below. Note that I am in New Zealand connecting to Australia East. I expect some latency, but I don’t expect difference in performance between CLI and PowerShell. The interesting result for me is the difference between az group show (2,931 ms) and Get-AzResourceGroup (741 ms).

DanielLarsenNZ/examples/blob/master/Scripts/Utilities/az-cli-vs-ps.ps1

Tue, 17 Mar 2020 20:44:50 GMT
azure-cli                          2.2.0

command-modules-nspkg              2.0.3
core                               2.2.0
nspkg                              3.0.4
telemetry                          1.0.4

Extensions:
application-insights               0.1.1
front-door                         0.1.8
interactive                        0.4.3
storage-preview                    0.2.7

Python location 'C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\python.exe'
Extensions directory 'C:\Users\dalars\.azure\cliextensions'

Python (Windows) 3.6.6 (v3.6.6:4cf1f54eb7, Jun 27 2018, 02:47:15) [MSC v.1900 32 bit (Intel)]

Legal docs and information: aka.ms/AzureCliLegal



Your CLI is up-to-date.

Please let us know how we are doing: https://aka.ms/clihats

Name                           Value
----                           -----
PSVersion                      7.0.0
PSEdition                      Core
GitCommitId                    7.0.0
OS                             Microsoft Windows 10.0.18363
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

az group create

Ticks             : 82722758
Days              : 0
Hours             : 0
Milliseconds      : 272
Minutes           : 0
Seconds           : 8
TotalDays         : 9.57439328703704E-05
TotalHours        : 0.00229785438888889
TotalMilliseconds : 8272.2758
TotalMinutes      : 0.137871263333333
TotalSeconds      : 8.2722758

New-AzResourceGroup
VERBOSE: Performing the operation "Replacing resource group ..." on target "test2-rg".
VERBOSE: 9:45:05 am - Created resource group 'test2-rg' in location 'australiaeast'

Ticks             : 15474831
Days              : 0
Hours             : 0
Milliseconds      : 547
Minutes           : 0
Seconds           : 1
TotalDays         : 1.79106840277778E-05
TotalHours        : 0.000429856416666667
TotalMilliseconds : 1547.4831
TotalMinutes      : 0.025791385
TotalSeconds      : 1.5474831

az group show

Ticks             : 29305181
Days              : 0
Hours             : 0
Milliseconds      : 930
Minutes           : 0
Seconds           : 2
TotalDays         : 3.39180335648148E-05
TotalHours        : 0.000814032805555556
TotalMilliseconds : 2930.5181
TotalMinutes      : 0.0488419683333333
TotalSeconds      : 2.9305181

Get-AzResourceGroup

Ticks             : 7408608
Days              : 0
Hours             : 0
Milliseconds      : 740
Minutes           : 0
Seconds           : 0
TotalDays         : 8.57477777777778E-06
TotalHours        : 0.000205794666666667
TotalMilliseconds : 740.8608
TotalMinutes      : 0.01234768
TotalSeconds      : 0.7408608

az group delete

Ticks             : 495528816
Days              : 0
Hours             : 0
Milliseconds      : 552
Minutes           : 0
Seconds           : 49
TotalDays         : 0.000573528722222222
TotalHours        : 0.0137646893333333
TotalMilliseconds : 49552.8816
TotalMinutes      : 0.82588136
TotalSeconds      : 49.5528816

Remove-AzResourceGroup
VERBOSE: Performing the operation "Removing resource group ..." on target "test2-rg".

Ticks             : 475125652
Days              : 0
Hours             : 0
Milliseconds      : 512
Minutes           : 0
Seconds           : 47
TotalDays         : 0.000549913949074074
TotalHours        : 0.0131979347777778
TotalMilliseconds : 47512.5652
TotalMinutes      : 0.791876086666667
TotalSeconds      : 47.5125652

It does not seems to be a geographical issue, but rather Azure slow responding. Which does not really not surprise me as also from the portal I often experience very slow operations.

Any comments from MS Azure people?

If anything this is worse than ever with 2.45.0:

> measure-command { az version }

Days              : 0
Hours             : 0
Minutes           : 0
Seconds           : 3
Milliseconds      : 202
Ticks             : 32024121
TotalDays         : 3.70649548611111E-05
TotalHours        : 0.000889558916666667
TotalMinutes      : 0.053373535
TotalSeconds      : 3.2024121
TotalMilliseconds : 3202.4121

time az --version real 0m1.039s user 0m0.328s sys 0m0.060s

time kubect get nodes real 0m5.654s user 0m0.086s sys 0m0.026s

Asking what version of the az CLI already takes more than 2 seconds. Isn’t that quite long for showing a version number?

I installed the CLI via the .msi installer.

C:\Windows\system32> az --version
azure-cli                         2.0.80

command-modules-nspkg              2.0.3
core                              2.0.80
nspkg                              3.0.4
telemetry                          1.0.4

Extensions:
azure-devops                      0.17.0

Python location 'C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\python.exe'
Extensions directory 'C:\Users\Wout\.azure\cliextensions'

Python (Windows) 3.6.6 (v3.6.6:4cf1f54eb7, Jun 27 2018, 02:47:15) [MSC v.1900 32 bit (Intel)]

Legal docs and information: aka.ms/AzureCliLegal



Your CLI is up-to-date.

Please let us know how we are doing: https://aka.ms/clihats
C:\Windows\system32> Measure-Command { az --version }


Days              : 0
Hours             : 0
Minutes           : 0
Seconds           : 2
Milliseconds      : 400
Ticks             : 24004857
TotalDays         : 2,77833993055556E-05
TotalHours        : 0,000666801583333333
TotalMinutes      : 0,040008095
TotalSeconds      : 2,4004857
TotalMilliseconds : 2400,4857

@tjprescott Experiencing the same issue. A login request takes about 5 sec…

@tjprescott I am running Mac OSX and experiencing slowness as well.

@tjprescott It’s not only in WSL, PowerShell or CMD has same behavior.

There are performance issues native to WSL and Windows Defender that make things abnormally slow in this environment. Future versions of WSL aim to address this performance issue, but it is not something we control within the CLI.