GitHub Workflow Failing at Azure Login

AJ 20 Reputation points
2024-05-24T01:48:56.3+00:00

Hello,

I'm following this MS Learn Exercise and running into a login issue.

Error: Login failed with Error: Using auth-type: SERVICE_PRINCIPAL. Not all values are present. Ensure 'client-id' and 'tenant-id' are supplied.. Double check if the 'auth-type' is correct. Refer to https://github.com/Azure/login#readme for more information.

I'm unsure why I'm running into this issue. I confirmed the client-id and tenant-id are stored in Github Secrets. Any help or guidance would greatly be appreciated.

Here is the workflow file.

name: Deploy ARM Template
on:
  push:
    branches:
      - main
env:
  AZURE_SUBSCRIPTION_ID: '[REDACTED]'  # set this to your Azure Subscription Id
  AZURE_RESOURCE_GROUP: GitHubActionExercise-rg   # set this to your target resource group
jobs:
  deploy-virtual-network-template:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout source code
        uses: actions/checkout@main
      - name: Login to Azure
        uses: azure/login@v1
        with:
          creds: ${{ secrets.AZURE_CREDENTIALS }}
      - name: Deploy ARM Template
        uses: azure/arm-deploy@v1
        with:
          scope: resourcegroup
          subscriptionId: ${{ env.AZURE_SUBSCRIPTION_ID }}
          resourceGroupName: ${{ env.AZURE_RESOURCE_GROUP }}
          template: ./azuredeploy.json

GitHub Secrets AZURE_CREDENTIALS Contents

{
  "clientId": "[REDACTED]",
  "clientSecret": "[REDACTED]",
  "subscriptionId": "[REDACTED]",
  "tenantId": "[REDACTED]",
  "activeDirectoryEndpointUrl": "https://login.microsoftonline.com",
  "resourceManagerEndpointUrl": "https://management.azure.com/",
  "activeDirectoryGraphResourceId": "https://graph.windows.net/",
  "sqlManagementEndpointUrl": "https://management.core.windows.net:8443/",
  "galleryEndpointUrl": "https://gallery.azure.com/",
  "managementEndpointUrl": "https://management.core.windows.net/"
}

This question is related to the following Learning Module

Azure Training
Azure Training
Azure: A cloud computing platform and infrastructure for building, deploying and managing applications and services through a worldwide network of Microsoft-managed datacenters.Training: Instruction to develop new skills.
1,147 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. AJ 20 Reputation points
    2024-05-27T00:35:03.76+00:00

    I was able to resolve the issue.

    The MS Learn instructions stated to save the secrets as Codespaces.

    codespacesHowever, after further reading and testing, I found that the Secrets should have been saved under Actions.

    actions Once I made this update and re-ran the GitHub workflow, I successfully deployed the Azure resource via template. I hope this helps anyone who is learning or encountering this issue.

    Hopefully, Microsoft Learn sees this ticket and updates their documentation.

    0 comments No comments

  2. Rakesh Gurram 4,560 Reputation points Microsoft Vendor
    2024-05-27T04:54:44.0066667+00:00

    Hi AJ,

    Thank you for your patience.

    We have successfully replicated the steps within the module. Please ensure that your assigned role is 'Contributor.' If it is not, assign yourself the 'Contributor' role and avoid using restricted Azure directories. Additionally, verify that the client secrets in both the CLI and GitHub secrets are correct and save them under Action secrets.

    User's image

    p5

    This has been created resource within the given resource group. Resource Group>>Settings>>Deployments>>Created Resource (VNet) as shown:

    User's image

    Please don't hesitate to reach out to us if you have any other queries with screenshots of the error (after concealing your PII).

    If the information is helpful, please Accept Answer & Upvote so that it would be helpful to other community members.

    Thank you.