Azure / login

Connect to Azure
MIT License
312 stars 295 forks source link

azure/login pre step takes up to 1 minute to execute #456

Open olafurnielsen opened 5 months ago

olafurnielsen commented 5 months ago

Observed behavior: The pre step in azure/login takes up to 1 minute to execute. Very seldom does it take a few seconds to execute. In some of our builds this accounts for half the total build time.

Expected behavior: The step should consistently execute in a few seconds.

Information:

Used as:

- name: Login to Azure
  uses: azure/login@v2
  with:
    tenant-id: ${{ secrets.AZURE_TENANT_ID }}
    client-id: ${{ secrets.AZURE_CLIENT_ID }}
    subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}

Resulting in: Screenshot 2024-06-05 at 09 55 30 Screenshot 2024-06-05 at 09 55 14

What can be done to speed this up?

damianh commented 3 months ago

This step is consuming 10 to 15 percent of our GitHub Actions build minutes and is costing us money. This should be fixed as a high priority please.

image

YanaXu commented 2 months ago

Hi @olafurnielsen and @damianh, we've released a new version v2.2.0. In this version, we removed the pre step and add 2 env variables to enable/disable pre or post cleanup. v2 is aligned with v2.2.0 now. Please try the new version. You can also refer to Enable/Disable the cleanup steps.

Just FYI, the time cost is mainly for login context initialization. After we remove pre step, the main step may need more time.

GoncaloPT commented 1 month ago

Hi @YanaXu

I've been trying the mentioned version, with both AZURE_LOGIN_PRE_CLEANUP and AZURE_LOGIN_POST_CLEANUP set to false and i'm having an average of 1 minute for the login action.

EDIT: Can we use a composite action to cache the login so it doesn't have to be redone every time?

YanaXu commented 1 month ago

Hi @GoncaloPT , could you help me check these questions?

The login time cost depends on underlying Azure CLI and Azure PowerShell. They needs time to init the login context. However, our daily test on GitHub-hosted runners (utuntu & windows & MacOS) shows the time cost is less than yours (including both Azure CLI login and Azure PowerShell login). Take the time cost yesterday for example. There are 18 logins and the max one is 51 seconds, the min one is 10 seconds and the average is 23 seconds.

GoncaloPT commented 1 month ago

Hi @YanaXu, thanks for your reply.

Replying to your questions:

Regarding the time cost you present, I haven't been able to reproduce logins near those ones values.. The full roundtrip of login + fetch one secret from key vault took from 1m:13s up to 1:50s.