How to login to Azure with GitHub Actions
Published Jul 14 2022 08:59 AM 9,530 Views

The first step is to create an Azure Service Principal account. You'll need the following:


  1. An Azure subscription ID (find it here) or follow this guide.
  2. A Service Principal with the following details the AppID, password, and tenant information. Create one with:
     az ad sp create-for-rbac --name "CICD" --role contributor --scopes /subscriptions/$AZURE_SUBSCRIPTION_ID --sdk-auth
    Replace "$AZURE_SUBSCRIPTION_ID" with the id from step 1.

Next, in your GitHub repository, add the output from the Service Principal (should be a JSON blob) as an Action Secret. You do this in your repository Settings.


Finally, create a GitHub workflow file by going to the "Actions" tab. Make sure you use the Azure login action:

 - uses: azure/login@v1
creds: ${{ secrets.AZURE_CREDENTIALS }}


The full running example is in the sample GitHub repository which you can use to get started, or use the YouTube video for a detailed walk-through!

Useful resources:



All of the steps are also covered in this short video:




Version history
Last update:
‎Jul 14 2022 08:59 AM
Updated by: