How to login to Azure with GitHub Actions

This post has been republished via RSS; it originally appeared at: New blog articles in Microsoft Tech Community.

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
with:
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:

 

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *

*

This site uses Akismet to reduce spam. Learn how your comment data is processed.