Azure Setup: OIDC and Read-Only Roles

This guide sets up OIDC authentication between GitHub Actions and Azure. No client secrets are stored in your repository: GitHub Actions requests a short-lived token for each scan.

Prerequisites

  • An Azure subscription with resources to scan
  • Permission to create App Registrations in Microsoft Entra ID and to assign roles on the subscription
  • A GitHub repository with LeftSize installed

Step 1: Create an App Registration

  1. Go to the Azure Portal > Microsoft Entra ID > App registrations
  2. Click New registration
  3. Set the name to leftsize-scanner (or any name you prefer)
  4. Leave Supported account types as the default (single tenant)
  5. Click Register
  6. Note the Application (client) ID and Directory (tenant) ID

Step 2: Add federated credentials

  1. In the App Registration, go to Certificates & secrets > Federated credentials
  2. Click Add credential
  3. Select GitHub Actions deploying Azure resources
  4. Configure:
    • Organization: your GitHub organization or username
    • Repository: the repository where the LeftSize workflow runs
    • Entity type: Branch
    • Branch: your default branch, usually main
    • Name: leftsize-scan
  5. Click Add

Scheduled runs use the default branch. To start manual runs from other branches, add a federated credential for each branch.

Step 3: Assign roles

Assign these read-only roles to the App Registration on each subscription you want to scan:

  1. Go to Subscriptions > select your subscription > Access control (IAM)
  2. Click Add role assignment
  3. Assign:
Role Purpose
Reader Read resource configuration (types, sizes, settings)
Monitoring Reader Read metrics (CPU, connections, throughput)

Billing currency

The action also detects the subscription’s billing currency, from its price sheet or Cost Management (read-only queries that Reader allows on most subscription types). If that fails it records USD. Savings amounts in issues are always in US dollars either way; see Cost estimation.

Optional: Key Vault certificates

The expiring Key Vault certificates rule reads certificate metadata from inside each Key Vault, which Reader doesn’t cover. To use it, give the App Registration the Key Vault Certificate User role on the vaults (or a List certificate permission in vaults that use access policies). Without it, that rule finds nothing and the rest of the scan runs normally.

LeftSize never changes your infrastructure.

Step 4: Add secrets to GitHub

In your repository, go to Settings > Secrets and variables > Actions and add:

Secret Value
AZURE_CLIENT_ID_MAIN Application (client) ID from Step 1
AZURE_SUBSCRIPTION_ID_MAIN Subscription to scan
AZURE_TENANT_ID Directory (tenant) ID from Step 1
LEFTSIZE_INSTALLATION_ID Provided during LeftSize onboarding
LEFTSIZE_REPOSITORY_TOKEN Provided during LeftSize onboarding

Scanning multiple subscriptions

Each workflow job scans the subscription it signs in to. To scan several subscriptions, add them to the matrix in the workflow:

strategy:
  fail-fast: false
  matrix:
    environment: [MAIN, PROD, DEV]

For each environment, create matching secrets:

  • AZURE_CLIENT_ID_PROD, AZURE_SUBSCRIPTION_ID_PROD
  • AZURE_CLIENT_ID_DEV, AZURE_SUBSCRIPTION_ID_DEV

You can use one App Registration for all of them: assign its roles on every subscription and store the same client ID in each AZURE_CLIENT_ID_<ENV> secret. Or use a separate App Registration per environment. The generated workflow uses a single AZURE_TENANT_ID, so all subscriptions must be in the same tenant.

Findings are grouped per subscription and resource group, so issues from different subscriptions never mix.

Other ways to authenticate

OIDC is the recommended setup: nothing secret is stored, and every run gets a token that expires within the hour. The LeftSize action itself doesn’t care how you sign in. It uses whatever credentials the earlier login step in the job sets up, so these also work:

  • A service principal with a client secret: use azure/login with creds: ${{ secrets.AZURE_CREDENTIALS }} (the JSON with client ID, secret, tenant and subscription) instead of the federated credential.
  • A self-hosted runner with a managed identity, or any other setup where az login has already run on the runner.

The roles are the same: Reader and Monitoring Reader on the subscriptions you scan. With a client secret you have a long-lived credential in GitHub that you need to protect and rotate before it expires, which is why OIDC is recommended.

Verifying the setup

  1. Go to your repository’s Actions tab
  2. Select LeftSize Cost Optimization Scan
  3. Click Run workflow
  4. Check that the Azure Login (OIDC) step succeeds and the job summary lists the scan results

If authentication fails, check that:

  • The federated credential matches your repository name and branch exactly
  • The App Registration has Reader and Monitoring Reader on the subscription
  • The secret names match the matrix entry (for example AZURE_CLIENT_ID_MAIN for environment: MAIN)

What LeftSize reads

  • Resource configuration through Azure Resource Manager
  • Metrics through Azure Monitor
  • Never creates, changes or deletes resources
  • Never reads the data inside your resources (no blob contents, no database contents)

Was this article helpful?

© 2026 LeftSize. Cloud cost optimization for GitHub teams.