Azure / login

Connect to Azure

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Not able to use azure/login@v2 and azure/CLI@v2 in one job

wenwenchenbosch opened this issue · comments

I am currently set up my github action to do azure deployment":

jobs:
    build:
        runs-on: [self-hosted] 
        #container:
        #    image: mcr.microsoft.com/azure-cli:latest
        steps:
        - name: Login to Azure
          uses: azure/login@v2
          with:
                creds: '{"clientId":"${{ secrets.AZURE_CLIENT_ID }}","clientSecret":"${{ secrets.AZURE_CLIENT_SECRET }}","subscriptionId":"${{ secrets.AZURE_SUBSCRIPTION_ID }}","tenantId":"${{ secrets.AZURE_TENANT_ID }}"}'
        - name: Deploy ARM Template
          uses: azure/CLI@v2
          with:
                azcliversion: latest
                inlineScript: |
                    az account show

but it does not work for me: The problem is, azure/login required 'az' as tool to be installed on the runner

this.azPath = await io.which("az", true);

but azure/Cli required 'docker', see
https://github.com/Azure/cli/blob/99c7fe7a21b1dbe885695e092bf8451d20bac9c0/src/main.ts#L123

If I use image: mcr.microsoft.com/azure-cli:latest to run the job, I get error: "Error: Unable to locate executable file: docker". If I let the job run directly on my runner, I get error: "Error: Unable to locate executable file: az".

The question is: Why both action work in different way?

Same Error

Hi @wenwenchenbosch and @RS185734,

Before running azure/login, please ensure that you have installed azure-cli on your self-hosted runner. You can find instructions on how to use azure/login on your self-hosted runner in https://github.com/Azure/login?tab=readme-ov-file#login-with-system-assigned-managed-identity.

Additionally, make sure you have installed docker before running azure/cli.

It appears that the original design of azure/login and azure/cli may have been primarily for GitHub-hosted runners. With self-hosted runners, you are responsible for installing the necessary software yourself. Check out the Requirements for self-hosted runner machines.

We've noticed that many of our customers are using self-hosted runners, so we are continuously working to improve the user experience for self-hosted runner users. We will consider this as an improvement of our products.

Hi, the difference is that azure cli is started in a container whereas azure login uses the default installation of azure on the runner.

Closing the issue for now. Feel free to reopen it if you have any further questions.