Azure · Cloud Computing

Integrate GitHub Actions with Azure Blob Storage (OIDC, No Secrets)

Upload files from a GitHub repo to Azure Blob Storage on every push, using OpenID Connect and a narrow role instead of stored keys.

·4 min read
On this page

The goal here is simple: every time someone pushes to main, a GitHub Actions workflow copies a folder from the repo into an Azure Blob Storage container. Think static site assets, generated reports, or config files another service picks up.

The original version of this post stored a service principal secret and the storage account key as GitHub secrets. That pattern still shows up in a lot of tutorials, and we’d steer you away from it. Both secrets are long-lived, the key gives full access to the whole account, and rotating them is the job nobody does. Today the better setup is OpenID Connect (OIDC): GitHub issues a short-lived token for each workflow run, Microsoft Entra ID trusts it for one specific repo and branch, and there’s no Azure secret in GitHub at all.

How the pieces fit

If you’re new to Actions: a workflow is a YAML file in .github/workflows/. An event such as a push triggers it, it runs one or more jobs on a runner, and each job is a list of steps that either run a shell command or call a reusable action. GitHub’s overview covers the rest.

GitHub Actions workflow: an event triggers jobs that run steps on runners

You’ll need an Azure subscription, a storage account with a container (our post on managing Blob Storage containers with the CLI shows how), the Azure CLI, and a GitHub repo you can change settings on.

1. Create an identity for the workflow

Create a Microsoft Entra app registration and its service principal:

APP_ID=$(az ad app create --display-name gh-blob-upload --query appId -o tsv)
az ad sp create --id "$APP_ID"

(A user-assigned managed identity works too, and some teams prefer it because it lives in a resource group alongside everything else. The steps are almost the same.)

2. Give it only the access it needs

The old post assigned Contributor on the resource group. That’s both too much and not enough: Contributor can delete the storage account, but it doesn’t grant data access through Entra ID, which is why the old workflow needed the account key as well. What the job actually needs is permission to write blobs to one account:

STORAGE_ID=$(az storage account show \
  --name stdemo0123 --resource-group rg-storage-demo --query id -o tsv)
SP_OBJECT_ID=$(az ad sp show --id "$APP_ID" --query id -o tsv)

az role assignment create \
  --assignee-object-id "$SP_OBJECT_ID" \
  --assignee-principal-type ServicePrincipal \
  --role "Storage Blob Data Contributor" \
  --scope "$STORAGE_ID"

If you want it even tighter, scope the assignment to a single container by adding /blobServices/default/containers/<name> to the scope.

3. Trust GitHub’s tokens for this repo and branch

Save this as credential.json, replacing the org and repo:

{
  "name": "github-main",
  "issuer": "https://token.actions.githubusercontent.com",
  "subject": "repo:your-org/your-repo:ref:refs/heads/main",
  "audiences": ["api://AzureADTokenExchange"]
}
az ad app federated-credential create --id "$APP_ID" --parameters credential.json

The subject has to match exactly; wildcards aren’t supported. If the job uses a GitHub environment, the subject is repo:your-org/your-repo:environment:production instead.

One gotcha that’s new in 2026: GitHub now supports immutable subject claims, where the subject includes the numeric owner and repo IDs (for example repo:your-org@123456/your-repo@456789:ref:refs/heads/main). Repositories created, renamed or transferred after July 15, 2026 use that format automatically, and older ones can opt in. If login fails with an AADSTS700213-style “no matching federated identity record” error, compare the subject GitHub sends with the one you registered. The azure/login README explains the migration.

4. Add the IDs to GitHub

In the repo, go to Settings > Secrets and variables > Actions and add AZURE_CLIENT_ID (the app ID), AZURE_TENANT_ID and AZURE_SUBSCRIPTION_ID. None of these is a password, but keeping them as secrets stops them showing up in logs and forks. Add the storage account name as a variable, STORAGE_ACCOUNT.

5. The workflow

Create .github/workflows/upload-to-blob.yml:

name: Upload to Blob Storage

on:
  push:
    branches: [main]

permissions:
  id-token: write   # lets the job request an OIDC token
  contents: read

jobs:
  upload:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v7

      - name: Azure login (OIDC)
        uses: azure/login@v3
        with:
          client-id: ${{ secrets.AZURE_CLIENT_ID }}
          tenant-id: ${{ secrets.AZURE_TENANT_ID }}
          subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}

      - name: Upload files
        run: |
          az storage blob upload-batch \
            --account-name "${{ vars.STORAGE_ACCOUNT }}" \
            --destination uploads \
            --source ./public \
            --overwrite \
            --auth-mode login

The Azure CLI is already installed on GitHub’s Ubuntu runners, so a plain run step is enough. The important parts are id-token: write (without it the login step can’t get a token) and --auth-mode login (without it the CLI goes looking for an account key, which the identity can’t read).

Commit, push to main, and watch the run under the repo’s Actions tab. Then list the container to confirm the files arrived:

az storage blob list --account-name stdemo0123 --container-name uploads \
  --auth-mode login --output table

A few things we’d add for real use

  • Pin actions to a full commit SHA instead of a tag if your security team asks for it. Both azure/login and actions/checkout publish immutable release tags you can map to SHAs.
  • Use a GitHub environment with required reviewers for anything that writes to production, and register the environment subject in the federated credential.
  • If the container serves a website, upload-batch doesn’t delete files you removed from the repo. az storage blob sync or AzCopy’s sync will, so test it on a copy first.

Once this is in place, there’s nothing to rotate. The only long-lived thing is the trust relationship, and it only works for the repo and branch you named.

We’re GDS, a consulting team that builds AI automations and runs them in our clients’ own cloud. If that’s on your plan, here’s what we do.

Carlos Noguera

AI solutions architect, GDS. CISSP-certified architect for AI, cloud and DevOps. Leads GDS engagements from the first call through support.

What should your team stop doing by hand?

A free 20-minute AI Fit Call shows where AI helps first and what it would take.

Book a free AI Fit CallNot ready for a call? Email us