skip to Main Content

Im trying to deploy from github actions using the following yml:

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
        - uses: actions/checkout@v2

        - name: "Login via Azure CLI"
          uses: azure/login@v1
          with:
            client-id: GUID
            tenant-id: GUID
            subscription-id: GUID

but im getting the error: Please check the credentials and make sure az is installed on the runner.

If i change to creds with the json, i get that the credentials are incorrect.

This is how i build the json:

az ad sp create-for-rbac -n "{ADD YOU NAMEW HERE}" --role Contributor --scopes /subscriptions/{subscriptionId} --sdk-auth

thanks

2

Answers


  1. One of the workaround you can follow to resolve the above issue;

    If your project is ready on the GitHub make sure to update the same in your local environment the example.yml file and push them. After creation of credentials using az ad sp create-for-rbac . Store those value into a secret file and pass this as variable in the example.yml file and try to execute as below.

     File: .github/workflows/workflow.yml
    
      on: [push]
    
    name: AzureLoginSample
    
    jobs:
    
      build-and-deploy:
        runs-on: ubuntu-latest
        steps:
        
        - uses: azure/login@v1
          with:
            creds: ${{ secrets.AZURE_CREDENTIALS }}
        
        - run: |
            az webapp list --query "[?state=='Running']"
    

    For more information Please refer this GitHub MarketPlace|GitHub Actions for deploying to Azure and this TechCommunity Blog|How to login to Azure with GitHub Actions by @Alfredo Deza.

    Login or Signup to reply.
  2. if you run this command it should work

    az ad sp create-for-rbac --name "app-test-1" --role contributor 
                            --scopes /subscriptions/your_subscription_id/resourceGroups/your_resource_group 
                            --sdk-auth
    

    it will output a json payload, put that json payload in the your repo’s secret and then call it in your yaml file

    - uses: azure/login@v1
          with:
            creds: ${{ secrets.AZURE_CREDENTIALS }}
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search