Azure / cli

Automate your GitHub workflows using Azure CLI scripts
MIT License
124 stars 52 forks source link

azure/cli@v1 not working with azure/login@v1 on self-hosted runner #71

Closed DeluxeOwl closed 1 year ago

DeluxeOwl commented 2 years ago

Hi,

I'm running self hosted runners on k8s using https://github.com/actions-runner-controller/actions-runner-controller, which doesn't have az cli installed by default.

So in my workflow, I'm installing it using curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash as per MS's documentation and signing in using azure/login@v1 and a service account which works fine, but when I'm running azure/cli@v1 right after, it gives the following errors:

ERROR: Please run 'az login' to setup account.
Error: Error: az cli script failed.

image

here is how the github job looks:

  preview:
    runs-on: self-hosted
    steps:
      - uses: actions/checkout@v2

      - name: Install az cli
        run: curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash

      - uses: azure/login@v1
        name: Sign in to Azure
        with:
          creds: ${{ secrets.AZURE_CREDENTIALS }}
          environment: azurecloud

      - uses: azure/cli@v1
        name: Run what-if
        with:
          inlineScript: |
            az deployment sub what-if --location ${{ env.RESOURCEGROUP_LOCATION }} \
              --template-file deploy/main.bicep

Any idea how to fix this?

t-dedah commented 2 years ago

Hi @DeluxeOwl, this generally means that .azure folder is missing in the docker. Is it possible for your to confirm content of the agent using ls before azure/cli action and again inside the action? We want to confirm whether .azure folder is being created and copied correctly.

DeluxeOwl commented 2 years ago

I've removed the deployment part and only did ls -la

  preview:
    runs-on: self-hosted
    steps:
      - uses: actions/checkout@v2

      - name: Install az cli
        run: curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash

      - uses: azure/login@v1
        name: Sign in to Azure
        with:
          creds: ${{ secrets.AZURE_CREDENTIALS }}
          environment: azurecloud

      - run: ls -la ~ && ls -la ~/.azure/

      - uses: azure/cli@v1
        name: Run what-if
        with:
          inlineScript: |
            ls -la ~ && ls -la ~/.azure/

image

It seems like the .azure directory is copied but the contents are not.

github-actions[bot] commented 2 years ago

This issue is stale because it has been open for 7 days with no activity.

github-actions[bot] commented 2 years ago

This issue is idle because it has been open for 14 days with no activity.

github-actions[bot] commented 2 years ago

This issue is stale because it has been open for 7 days with no activity.

github-actions[bot] commented 2 years ago

This issue is idle because it has been open for 14 days with no activity.

damian-archlet commented 1 year ago

Have the exact same issue. My workaround was to just use the azure/login@v1 action to login and then a bash step to run the rest of my pipeline. Would be nice to have it working though.

github-actions[bot] commented 1 year ago

This issue is idle because it has been open for 14 days with no activity.

github-actions[bot] commented 1 year ago

This issue is stale because it has been open for 7 days with no activity.

hansmbakker commented 1 year ago

We have this issue, too. Workaround is to install az cli in the runner image or in the runner at runtime and call it from bash, as @damian-archlet suggested.

Would like to have this fixed, though.

github-actions[bot] commented 1 year ago

This issue is idle because it has been open for 14 days with no activity.

github-actions[bot] commented 1 year ago

This issue is stale because it has been open for 7 days with no activity.

MoChilia commented 1 year ago

Hi @DeluxeOwl, @damian-archlet, @hansmbakker! Please let us know if you are still facing the issue. I cannot reproduce the error, since azure/cli@v1 works well with azure/login@v1 on my self-hosted runner with az cli installed manually.

DeluxeOwl commented 1 year ago

It's been one year and a few months since I opened this issue. I already switched jobs since then.

MoChilia commented 1 year ago

Ok, thanks for your feedback. Closing this issue for now. If there is any further question, please reopen it.