GitHub Actions Integration in Azure: An Automatic Delivery Line From Code to Cloud

GitHub Actions Integration in Azure: An Automatic Delivery Line From Code to Cloud

A beginner-friendly guide to connecting GitHub Actions with Azure. Learn how workflows build, test, and deploy your applications, how to sign in to Azure without storing passwords, and how to design pipelines that are fast, safe, and easy to maintain.

Imagine a factory where raw materials arrive at one end and finished, packaged products leave at the other, all without people carrying boxes between machines. Each machine does one job, checks its work, and passes the product to the next. If something is wrong, the line stops and rings a bell. Software teams want the same thing for their code. Every time a developer saves a change, an automatic line should build it, test it, check its quality, and deliver it to the cloud. GitHub Actions is that line, and Azure is the place where the finished product is delivered and runs.

1What Is GitHub Actions?

Start with a plain definition, then add the details one layer at a time.

GitHub is a popular website where developers store their code and work together on it. GitHub Actions is a feature built into GitHub that lets you automate tasks whenever something happens in your code repository. A repository is simply the folder of project files together with its full history of changes.

The automation is described in simple text files called workflows. A workflow says: “When this event happens, run these jobs, and in each job do these steps.” Events can be things like a developer pushing new code, someone opening a pull request, a release being published, a timer reaching a set time, or a person clicking a button.

Because the workflow files live inside the repository next to the code, they are version controlled, reviewed, and shared just like any other file. The automation is part of the project, not a separate tool that only one person understands.

Simple Analogy

A workflow is a recipe card pinned to the kitchen wall. It says when to start cooking (the event), which stations to use (the jobs), and what to do at each station (the steps). Anyone who joins the kitchen can read the card and know exactly how the meal is made.

Event
Something happens in the repository
Workflow
An automated recipe starts running
Result
Built, tested, and deployed to Azure

2Why Connect GitHub Actions to Azure?

Automation matters most at the moment code travels to the cloud.

Before automation, deploying an application often meant a person copying files by hand, running commands from memory, and hoping nothing was forgotten. That is slow, error-prone, and impossible to repeat exactly. Connecting GitHub Actions to Azure turns deployment into a repeatable, reviewed, and recorded process.

Benefit 1

Speed

Changes reach users in minutes instead of waiting for a manual release day.

Benefit 2

Consistency

The same steps run in the same order every time, removing the “it worked on my machine” problem.

Benefit 3

Quality gates

Tests, security scans, and approvals run automatically, so bad changes are caught before they reach customers.

Benefit 4

Traceability

Every deployment is linked to a specific code change, a person, and a log of what happened.

Benefit 5

Less stress

Releases become small, frequent, and boring, which is exactly what you want from a release.

Benefit 6

One home for code and automation

Teams that already host code on GitHub can build and deploy without adding another tool.

“If deploying is scary, do it more often, and let a machine do it the same way every time.”

3CI and CD in Simple Words

Two short abbreviations describe most of what GitHub Actions does for Azure.

CI stands for Continuous Integration. Every time a developer shares a change, the system automatically builds the application and runs tests. This catches mistakes within minutes, while the change is still fresh in the developer’s mind.

CD stands for Continuous Delivery or Continuous Deployment. After a change passes its checks, the system packages it and delivers it to an environment. In continuous delivery a person approves the final step. In continuous deployment, every change that passes all checks goes live automatically.

TermWhat it doesTypical trigger
Continuous IntegrationBuilds and tests every changeA push or a pull request
Continuous DeliveryPrepares a release and deploys with a human approval stepMerge into the main branch
Continuous DeploymentDeploys automatically after all checks passMerge into the main branch
flowchart LR
  DEV["Developer pushes code"] --> BUILD["Build"]
  BUILD --> TEST["Run tests and scans"]
  TEST --> PKG["Package the application"]
  PKG --> STG["Deploy to Staging in Azure"]
  STG --> APPR["Approval"]
  APPR --> PROD["Deploy to Production in Azure"]
        
FIG 1 — A typical CI and CD journey from a code change to production in Azure
Simple Analogy

Continuous Integration is a quality inspector at the start of the line who checks every part the moment it arrives. Continuous Delivery is the loading dock that prepares the finished product for shipping. Continuous Deployment is a dock that ships automatically once the inspector gives the green light.

4The Core Building Blocks of GitHub Actions

Eight simple words explain almost everything inside GitHub Actions.

Block 1

Workflow

An automated process described in a file stored in the repository. A repository can have many workflows.

Block 2

Event

The trigger that starts a workflow, such as a push, a pull request, a schedule, or a manual click.

Block 3

Job

A group of steps that run together on the same machine. Jobs can run side by side or one after another.

Block 4

Step

A single task inside a job, such as running a command or using a ready-made action.

Block 5

Action

A reusable building block that does a specific task, for example signing in to Azure or deploying to a web app.

Block 6

Runner

The machine that actually runs a job. It can be hosted by GitHub or run by you.

Block 7

Secret and variable

Stored values that workflows can use. Secrets are encrypted and hidden, while variables are plain configuration values.

Block 8

Environment

A named target such as staging or production, which can have its own secrets, approval rules, and protections.

flowchart TD
  EV["Event: push to main"] --> WF["Workflow"]
  WF --> J1["Job 1: Build and test"]
  WF --> J2["Job 2: Deploy"]
  J1 --> S1["Step: Get the code"]
  J1 --> S2["Step: Build"]
  J1 --> S3["Step: Run tests"]
  J2 --> S4["Step: Sign in to Azure"]
  J2 --> S5["Step: Deploy the app"]
  J1 -->|Must succeed first| J2
        
FIG 2 — How an event, workflow, jobs, and steps fit together
Simple Analogy

A workflow is a whole production plan. Jobs are the stations on the factory floor. Steps are the individual tasks at each station. Actions are ready-made tools hanging on the wall that you can pick up. A runner is the worker who stands at the station and carries out the tasks.

5Runners: The Machines That Do the Work

Every job needs a computer to run on. You can rent one or bring your own.

GitHub-hosted runners

Virtual machines provided and maintained by GitHub, available with common operating systems and pre-installed tools. A fresh machine is created for every job and thrown away afterwards. This is the easiest option and requires no setup, but the machines sit outside your private network.

Self-hosted runners

Machines you install the runner software on and manage yourself, such as virtual machines in Azure. You control the size, tools, and network location, which matters when a deployment must reach resources inside a private network. You are also responsible for updates and security.

Larger and private-network options

GitHub offers larger hosted runners for heavy builds, and options to run hosted runners inside your own Azure virtual network. Availability and plan requirements change, so check current documentation.

PointGitHub-hostedSelf-hosted
Setup effortNoneYou install and maintain them
Clean machine for each jobYesOnly if you design it that way
Reach private Azure resourcesNot by defaultYes, when placed in your network
Custom tools and hardwareLimited to offered sizes and imagesFully your choice
Cost modelIncluded minutes, then per-minute chargesYou pay for the machines you run
Security responsibilityMostly GitHubMostly you
Simple Analogy

A GitHub-hosted runner is a rented workshop that is cleaned and reset after every use. A self-hosted runner is a workshop you own inside your company’s fenced compound. The rented one is easy but outside the fence. The owned one can reach everything inside the fence, but you must keep it tidy and locked.

!
Security Warning

Never attach self-hosted runners to public repositories without strong controls. Anyone who can trigger a workflow could try to run code on your machine. Keep them for private repositories, and treat them as sensitive infrastructure.

A workflow must prove its identity to Azure before it is allowed to change anything.

When a workflow wants to deploy to Azure, Azure asks, “Who are you, and what are you allowed to do?” There are a few ways to answer. Some are safe and modern. Others are risky and old-fashioned.

Method 1

OpenID Connect (OIDC) with federated credentials

The recommended approach. No long-lived password is stored. GitHub issues a short-lived token for each run, and Azure trusts it because you set up a trust relationship in advance.

Method 2

Service principal with a client secret

An application identity with a stored password. It works but the secret can leak, expires, and must be rotated.

Method 3

Publish profile

A downloadable file with deployment credentials for a web app or function app. Easy to start, but it is a shared secret tied to one resource, and Azure now encourages moving away from it.

Method 4

Managed identity on a self-hosted runner

If the runner is an Azure machine, it can use its own managed identity to sign in, so no secret needs to be stored at all.

MethodStored password?Rotation needed?Recommended?
OIDC federated credentialNoNoYes, the preferred choice
Managed identity on a runnerNoNoYes, when you use self-hosted runners in Azure
Service principal secretYesYes, before it expiresOnly when nothing better is possible
Publish profileYesYes, when regenerated or exposedAvoid for new setups
Simple Analogy

A stored password is like giving a delivery driver a permanent copy of your house key. If the key is lost or copied, anyone can enter. OIDC is like a one-time visitor pass that the front desk prints for each delivery and that stops working an hour later.

7How OIDC Trust Works Step by Step

Understanding the trust relationship removes the mystery from passwordless sign-in.

With OpenID Connect, GitHub and Azure agree in advance on a set of rules. On the Azure side you create an application identity in Microsoft Entra ID, and you add a federated credential to it. That credential says, “I trust tokens from GitHub, but only when they claim to come from this specific repository, and this specific branch or environment.” During a run, GitHub generates a short-lived signed token containing these claims. The workflow presents it to Azure, Azure checks the signature and the claims, and then hands back a temporary access token for Azure.

1

Create an identity in Azure

Register an application in Microsoft Entra ID, or create a user-assigned managed identity, to represent your pipeline.

2

Add a federated credential

Define the trust: the issuer is GitHub, and the subject names the repository and the branch, environment, or pull request that is allowed.

3

Give the identity limited permissions

Assign an Azure role, such as Contributor, but only on the specific resource group or resource that the pipeline needs.

4

Store non-secret identifiers in GitHub

Save the client identifier, tenant identifier, and subscription identifier as variables or secrets. These identify the target but are not passwords.

5

Allow the workflow to request a token

The workflow must be granted permission to request the identity token, and then a sign-in action exchanges it for Azure access.

6

Deploy using the temporary access

Later steps act as the identity, and the access expires shortly after the job finishes.

sequenceDiagram
  participant WF as GitHub Workflow Run
  participant GH as GitHub Token Service
  participant AAD as Microsoft Entra ID
  participant AZ as Azure Resources
  WF->>GH: Request a short-lived identity token
  GH-->>WF: Signed token with repository and branch claims
  WF->>AAD: Present token and ask for Azure access
  AAD->>AAD: Check signature and match the federated credential
  AAD-->>WF: Temporary Azure access token
  WF->>AZ: Deploy using the temporary access
  AZ-->>WF: Deployment result
        
FIG 3 — Passwordless sign-in: a short-lived token is exchanged for temporary Azure access
i
Good to Know

The match on the subject claim is what protects you. If you trust only the main branch of one repository, a workflow in a different repository or on an untrusted branch cannot get Azure access, even if it copies your identifiers.

Simple Analogy

Think of an office building with a security desk. You tell the desk in advance, “Accept delivery drivers from this company, carrying this specific order slip.” On the day, the driver shows the slip, the desk checks it, and the driver receives a visitor badge that expires in an hour. No permanent key ever changes hands.

8Giving Permissions: Least Privilege in Azure

The pipeline identity should be able to do its job and nothing more.

Azure uses role-based access control, shortened to RBAC. A role is a set of allowed actions, and a role assignment applies a role to an identity at a certain scope. The scope can be a management group, a subscription, a resource group, or a single resource. The smaller the scope and the narrower the role, the safer you are.

Scope level

Single resource

The tightest scope. Use it when the pipeline deploys to just one web app or function app.

Scope level

Resource group

A common choice. The pipeline can manage everything inside one application’s resource group.

Scope level

Subscription

Broad. Needed only for pipelines that create resource groups or manage subscription-wide settings.

Pipeline jobSuitable role ideaSuggested scope
Deploy code to a web app or function appA role that can update that app, such as Website ContributorThat app or its resource group
Push container imagesA role that allows pushing to the registry, such as AcrPushThe container registry
Deploy infrastructure templatesContributor, sometimes with a role to assign access if templates create role assignmentsThe target resource group
Read secrets at deployment timeA read-only secrets role for Key VaultThe specific vault
Deploy to a Kubernetes clusterA cluster-specific user or deployer roleThe cluster, and the right namespace
ANTI-PATTERN-01 Avoid
Problem

Giving the pipeline identity Owner or Contributor on the entire subscription because it is quick and “just works”.

Why It’s Harmful

If the pipeline is ever compromised, an attacker can change or delete everything in the subscription, including unrelated applications and data.

Correct Approach

Assign the narrowest role on the smallest scope that still lets the pipeline do its job, and use separate identities for separate applications and environments.

Simple Analogy

A delivery driver needs the key to the loading dock, not the key to the vault and the manager’s office. Giving only the dock key limits the damage if the key is ever lost.

9Triggers: Deciding When Workflows Run

A workflow does nothing until an event starts it.

Push

Runs when code is pushed to chosen branches or paths. Often used to deploy when the main branch changes.

Pull request

Runs when a pull request is opened or updated. Ideal for building, testing, and scanning proposed changes before they are merged, without deploying to production.

Schedule

Runs on a timetable, such as every night. Useful for nightly builds, security scans, and cleaning up temporary environments.

Manual run

A person starts the workflow with a button and can provide inputs such as which environment to deploy to. Useful for controlled releases and rollbacks.

Release or tag

Runs when a release is published or a version tag is created, so the deployment matches an official version.

Workflow call

Lets one workflow be called by another, allowing shared, reusable pipelines.

TriggerStarts whenTypical Azure use
PushCode is pushed to a branchDeploy to a development or staging environment
Pull requestA pull request is opened or updatedBuild, test, and optionally preview the change
ScheduleA set time arrivesNightly scans or cleanup of temporary resources
ManualA person clicks runControlled production releases and rollbacks
Release or tagA version is publishedDeploy a specific tagged version to production
!
Common Mistake

Deploying to production straight from a pull request that comes from an untrusted fork. Pull requests from outside contributors do not get your secrets by default, and for good reason. Keep deployments tied to trusted branches and protected environments.

Simple Analogy

A push trigger is a doorbell that rings when a parcel arrives. A schedule trigger is an alarm clock. A manual trigger is a button that only a trusted person presses. Choosing the right trigger decides who and what can start the machine.

10Environments, Approvals, and Protection

Not every deployment should go straight to customers.

GitHub environments represent places your code is deployed, such as development, staging, and production. Each environment can have its own secrets and variables, and its own protection rules. Protection rules can require a named person to approve before the job runs, wait for a set time, or limit deployments to certain branches.

Rule 1

Required reviewers

The job pauses until one or more named people approve the deployment.

Rule 2

Wait timer

Adds a delay before deployment starts, giving time to cancel if something looks wrong.

Rule 3

Branch restrictions

Only chosen branches, such as main, may deploy to this environment.

Rule 4

Environment secrets

Secrets and variables that are available only to jobs deploying to that environment.

Rule 5

Separate Azure identities

Each environment can use its own federated credential tied to the environment name, so a staging job can never obtain production access.

flowchart LR
  B["Build and test"] --> DEV["Deploy to Dev: automatic"]
  DEV --> STG["Deploy to Staging: automatic after tests"]
  STG --> GATE["Approval by a required reviewer"]
  GATE --> PRD["Deploy to Production"]
  PRD --> SMK["Smoke checks"]
        
FIG 4 — Promotion through environments with an approval gate before production
Simple Analogy

Environments are like the stages of a theatre production: rehearsal room, dress rehearsal, and opening night. The final stage has a director who must say “go” before the curtain rises.

i
Good to Know

Availability of some protection rules, especially for private repositories, depends on your GitHub plan. Check the current plan details before relying on them.

11Where You Can Deploy in Azure

GitHub Actions works with most Azure hosting services.

Azure serviceWhat it hostsHow the pipeline typically deploys
Azure App ServiceWeb apps and APIsSends a built package or container image to the app, often to a staging slot first
Azure FunctionsEvent-driven functionsDeploys a packaged function app
Azure Static Web AppsStatic sites with serverless APIsA workflow is created and linked automatically when you connect the repository
Azure Container AppsContainerized apps without cluster managementBuilds an image, pushes it to a registry, and updates the app to the new image
Azure Kubernetes ServiceContainerized apps on KubernetesBuilds and pushes images, then applies deployment definitions to the cluster
Azure Container RegistryContainer image storageStores built images that other services pull
Virtual MachinesTraditional serversCopies packages or runs commands, or bakes images, using automation tools
Infrastructure templates (Bicep, ARM, Terraform)The Azure resources themselvesValidates and applies templates to create or update infrastructure
Ready-made

Official Azure actions

Microsoft and Azure publish actions for signing in, deploying web apps, functions, container apps, and Kubernetes, and running command-line tasks.

Ready-made

Portal integration

Some Azure services, such as App Service and Static Web Apps, can connect a GitHub repository from the Azure portal and create a starter workflow for you.

Ready-made

Starter workflows

GitHub offers template workflows for many languages and Azure targets that you can copy and adjust.

i
Good to Know

Action names, versions, and recommended settings change over time. Check the current official documentation and the action’s own page before copying a starter workflow, and review what the generated workflow does before trusting it.

12A Typical Web App Pipeline, Step by Step

See a complete journey from commit to running application.

1

A developer opens a pull request

The workflow builds the code, runs unit tests, and runs security and quality scans. Results appear right on the pull request.

2

Reviewers check and merge

Branch protection rules require passing checks and at least one review before the change can join the main branch.

3

The main branch triggers the release workflow

The workflow builds once and produces a package or container image, saving it as an artifact or in a registry.

4

Deploy to a staging slot or environment

The workflow signs in to Azure using OIDC and deploys the same package to a staging environment.

5

Run checks against staging

Automated smoke tests call the staging site to confirm it starts and answers correctly.

6

Approve and promote to production

A reviewer approves, and the workflow deploys the same tested package to production, for example by swapping the staging slot into place.

7

Verify and watch

Health checks and monitoring confirm that the release is healthy, with a fast path to roll back if not.

flowchart TD
  PR["Pull request: build, test, scan"] --> MERGE["Merge to main after review"]
  MERGE --> REL["Release workflow: build once, store artifact"]
  REL --> LOGIN["Sign in to Azure with OIDC"]
  LOGIN --> STG["Deploy to staging slot"]
  STG --> SMOKE["Smoke tests"]
  SMOKE --> APPROVE["Manual approval"]
  APPROVE --> SWAP["Swap staging into production"]
  SWAP --> MON["Monitor and keep rollback ready"]
        
FIG 5 — A full release path with staging, testing, approval, and a safe swap
i
Golden Rule

Build once and deploy the same package everywhere. If you rebuild for each environment, production may run something slightly different from what you tested.

Simple Analogy

It is like baking one cake, tasting a slice in the kitchen, and then serving that exact cake at the party. You would never bake a second, slightly different cake for the guests and hope it tastes the same.

13Safe Release Strategies on Azure

Even with tests, a release can surprise you. Good strategies limit the damage.

Deployment slots

Azure App Service and Azure Functions offer staging slots. You deploy to a hidden slot, warm it up, test it, and then swap it with production. The swap is quick, and swapping back is an instant rollback.

Blue-green deployment

Two identical environments exist. Users are on blue while you deploy to green. When green is verified, traffic is switched over, and blue stays ready as a fallback.

Canary or gradual rollout

Send a small share of traffic to the new version first, watch for errors, and increase the share step by step. Container Apps revisions and Kubernetes tools support this style.

Feature flags

Deploy code with new features turned off, then switch them on for chosen users. This separates deploying code from releasing a feature.

Automatic rollback

Health checks after deployment can trigger the workflow to restore the previous version if the new one is unhealthy.

StrategyRisk levelRollback speedExtra cost or effort
Direct replacementHighestSlow, redeploy the old versionNone
Slot swapLowVery fast, swap backA plan tier that supports slots
Blue-greenLowFast, switch traffic backDuplicate environments while both run
CanaryLowest for large systemsFast, shift traffic awayTraffic routing and good monitoring
Simple Analogy

A slot swap is like rehearsing a play on a hidden second stage and then rotating the stage so the audience instantly sees the finished set. If something looks wrong, you rotate it back in a moment.

14Infrastructure as Code in Your Pipeline

Pipelines can build the Azure resources themselves, not just deploy code onto them.

Infrastructure as code means describing your Azure resources, such as web apps, databases, and networks, in text files that tools can read and apply. The files are stored in the repository, reviewed like code, and applied by a workflow. This makes environments repeatable and removes manual clicking in the portal.

Tool

Bicep

Azure’s own friendly language for describing resources. It compiles to Azure Resource Manager templates and is designed specifically for Azure.

Tool

ARM templates

The underlying JSON format that Azure understands. Bicep is usually easier to read and write.

Tool

Terraform

A popular multi-cloud tool. It keeps a state record of what it built, which must be stored safely, for example in an Azure storage account.

1

Validate and lint

On every pull request, check the templates for errors and policy problems.

2

Preview the changes

Run a what-if or plan step that shows what would be created, changed, or deleted, and show it to reviewers.

3

Approve

For important environments, a person reviews the preview and approves.

4

Apply

The workflow deploys the templates with the pipeline identity, creating or updating the Azure resources.

!
Common Mistake

Letting people change resources by hand in the portal while a pipeline also manages them. The two drift apart, and the next pipeline run may undo or conflict with manual changes. Make the repository the single source of truth.

Simple Analogy

Infrastructure as code is an architect’s blueprint stored in a safe. Instead of building a house from memory each time, builders follow the same blueprint, and every house comes out the same.

15Containers, Registries, and Kubernetes

Many modern applications ship as container images.

A container image is a sealed package holding an application and everything it needs to run. Pipelines build the image, tag it with a version, and push it to a registry such as Azure Container Registry. Then a hosting service such as Azure Container Apps, Azure Kubernetes Service, or App Service pulls the image and runs it.

flowchart LR
  CODE["Source code"] --> IMG["Build container image"]
  IMG --> SCAN["Scan image for vulnerabilities"]
  SCAN --> ACR["Push to Azure Container Registry"]
  ACR --> CA["Azure Container Apps"]
  ACR --> AKS["Azure Kubernetes Service"]
  ACR --> APPSVC["App Service for Containers"]
        
FIG 6 — Build, scan, store, and run container images across Azure services
Practice

Tag images with the commit

Use a tag that ties each image to the exact code change, so you always know what is running.

Practice

Avoid the “latest” tag in production

The word “latest” moves over time and makes it hard to know or reproduce what is deployed.

Practice

Scan images

Check images for known vulnerabilities before they are allowed into production.

Practice

Use identity-based registry access

Let the hosting service pull images using a managed identity instead of a stored registry password.

Simple Analogy

A container image is a sealed lunchbox with a label showing exactly what is inside and when it was packed. The registry is the fridge that holds the lunchboxes. The hosting service picks up a specific lunchbox and serves it.

16Secrets, Variables, and Configuration

Pipelines need settings and sometimes secrets. Handle them with care.

Store 1

GitHub secrets

Encrypted values stored at repository, environment, or organization level. They are masked in logs, but a careless step can still expose them.

Store 2

GitHub variables

Plain configuration values, such as resource names and regions, that are not sensitive.

Store 3

Azure Key Vault

The central, audited home for application secrets. The pipeline identity reads only what it needs, and applications can read secrets directly at runtime.

Store 4

App configuration services

Azure App Configuration holds non-secret settings shared across applications and environments.

1

Prefer no secrets at all

Use OIDC for the pipeline and managed identities for applications, so there is nothing to store or leak.

2

Keep application secrets in Key Vault

Do not copy them into repository files. Reference them from the application settings instead.

3

Scope remaining secrets narrowly

Place them at the environment level so only approved jobs can read them.

4

Rotate and review

Change secrets on a schedule and remove any that are no longer used.

ANTI-PATTERN-02 Avoid
Problem

Committing passwords, keys, or connection strings into repository files, or printing them in workflow logs for debugging.

Why It’s Harmful

Repository history is permanent and widely copied. Logs can be read by many people. A leaked key gives direct access to your Azure resources.

Correct Approach

Use secret stores and identity-based access, turn on secret scanning and push protection, and never print sensitive values.

Simple Analogy

A secret in a repository file is like writing your safe’s combination on a sticky note and pinning it on the office wall. Even if you take the note down later, many people may already have photographed it.

17Securing the Pipeline Itself

A pipeline can change your production systems, so it is a valuable target for attackers.

Defense 1

Branch protection and reviews

Require pull requests, passing checks, and approvals so no one can push unreviewed code straight to production branches. Protect the workflow files too.

Defense 2

Minimal workflow permissions

Set the default token permissions to read-only, and grant extra permissions only to the jobs that need them.

Defense 3

Pin third-party actions

Reference actions by a fixed commit identifier rather than a movable tag, and review what they do, because they run with your pipeline’s access.

Defense 4

Dependency updates

Use automated tools such as Dependabot to propose updates to libraries and actions, so security fixes arrive quickly.

Defense 5

Code and secret scanning

Enable code scanning, dependency review, and secret scanning to catch vulnerabilities and leaked credentials early.

Defense 6

Careful handling of untrusted input

Titles, branch names, and pull request text can contain malicious content. Never place them directly into commands without safe handling.

Defense 7

Audit logs

Review who changed workflows, secrets, and environments, and watch Azure activity logs for deployments made by the pipeline identity.

flowchart TD
  C["Code change"] --> BP["Branch protection and review"]
  BP --> SCAN["Code, dependency, and secret scanning"]
  SCAN --> WP["Least-privilege workflow permissions"]
  WP --> ENV["Protected environment with approval"]
  ENV --> OIDC["OIDC with narrow Azure role"]
  OIDC --> AZ["Deployment to Azure"]
  AZ --> LOGS["Audit logs and monitoring"]
        
FIG 7 — Layers of protection between a code change and your Azure resources
ANTI-PATTERN-03 Avoid
Problem

Using many third-party actions by their floating version tags without ever reviewing them.

Why It’s Harmful

If an action’s repository is compromised or its tag is moved, malicious code can run inside your pipeline, with access to your secrets and Azure permissions.

Correct Approach

Prefer actions from trusted publishers, pin them to full commit identifiers, review changes when updating, and keep the number of third-party actions small.

Simple Analogy

A pipeline is like a key worker who has access to your warehouse. You check their references, limit which rooms they can enter, supervise important jobs, and keep a log of everything they did. The more powerful the access, the stronger the checks should be.

18Reusable Workflows and Clean Design

As teams grow, copying the same workflow into dozens of repositories becomes a burden.

Tool

Reusable workflows

One workflow can be called by many others, with inputs, so a company can keep one trusted deployment recipe in a central place.

Tool

Composite actions

Bundle several steps into one custom action that can be reused across jobs and repositories.

Tool

Matrix builds

Run the same job over several versions or systems at once, such as testing on multiple language versions.

Tool

Caching and artifacts

Cache downloaded dependencies to speed up builds, and pass build outputs between jobs as artifacts.

Tool

Concurrency controls

Make sure only one deployment to an environment runs at a time, so two releases do not collide.

Tool

Conditions and path filters

Run jobs only when relevant files change, saving time and cost.

i
Design Habit

Keep each job focused on one purpose, give steps clear names, and make failures easy to read. A pipeline is a program that your whole team must understand at two in the morning when something breaks.

Simple Analogy

Reusable workflows are like a franchise manual. Each restaurant follows the same trusted recipe, and when headquarters improves the recipe, every restaurant benefits without rewriting its own book.

19Monitoring, Troubleshooting, and Cost

Pipelines need watching too, and they are not free.

Seeing what happened

Tool

Workflow run logs

Every step’s output is recorded with timing, and failed steps are highlighted.

Tool

Deployment history

Environments show which commit is deployed where, who approved it, and when.

Tool

Azure Activity Log

Shows changes made to Azure resources by the pipeline identity, which helps with audits and investigations.

Tool

Application monitoring

Azure Monitor and Application Insights show whether the new release is healthy, so you can connect a deployment to a change in behavior.

Common failures and quick checks

SymptomUsual causeFirst thing to check
Azure sign-in fails with a trust errorThe federated credential’s subject does not match the repository, branch, or environmentCompare the credential’s subject with the run’s actual repository and environment
Sign-in works but deployment is deniedThe identity lacks a role at the right scopeCheck the role assignment on the target resource or resource group
Workflow cannot request an identity tokenThe workflow permissions do not allow itConfirm the workflow or job has permission to request the token
Deployment cannot reach a private resourceThe runner is outside the private networkUse a self-hosted or network-integrated runner
Builds are slowNo caching, large downloads, or everything runs in sequenceAdd caching and split independent jobs to run in parallel
Two releases collideNo concurrency controlLimit deployments to one at a time per environment

Controlling cost

GitHub-hosted runners include a number of free minutes depending on your plan, and extra usage is billed per minute, with different rates for different machine types. Self-hosted runners avoid these charges but you pay for the machines in Azure. Plans and prices change, so check the current billing pages.

1

Cache dependencies

Avoid downloading the same libraries every run.

2

Run only what changed

Use path filters so a documentation edit does not trigger a full production build.

3

Cancel outdated runs

When a new commit arrives, cancel the older pending run for the same branch.

4

Set artifact and log retention

Keep stored artifacts and logs only as long as you need them.

5

Clean up temporary Azure resources

If pipelines create preview environments, delete them automatically when the pull request closes.

Simple Analogy

Pipeline minutes are like taxi fares. A long, wasteful route costs more. Preparing your luggage in advance and not making unnecessary trips saves money without slowing you down.

20GitHub Actions Compared with Azure DevOps Pipelines and Others

Several tools can automate deployments to Azure. Knowing them helps you choose.

OptionWhat it isChoose it when
GitHub ActionsAutomation built into GitHub repositoriesYour code lives on GitHub and you want automation next to it
Azure Pipelines (Azure DevOps)Microsoft’s pipeline service inside Azure DevOpsYou already use Azure DevOps boards, repos, and release management
Azure Developer CLI templatesReady-made project templates that set up infrastructure and pipelinesYou want a fast, opinionated start for a new Azure application
Portal Deployment CenterA guided setup inside Azure services that links a repositoryYou want a quick starter workflow for a simple app
Other CI/CD toolsJenkins, GitLab CI, and othersYour organization already standardized on them
i
Quick Rule

The best pipeline tool is usually the one closest to where your code and your team already live. GitHub Actions and Azure Pipelines can both deploy well to Azure. Avoid running two systems for the same job unless there is a clear reason.

21Real-World Use Cases

See how different teams use GitHub Actions with Azure every day.

A startup shipping a web app several times a day

Every merge to main builds the app, deploys it to a staging slot, runs smoke tests, and swaps it into production automatically, giving customers new features within minutes.

A bank with strict approvals

The bank uses protected environments with required reviewers, separate identities per environment, and self-hosted runners inside a private network, giving speed with strong audit trails.

A platform team managing infrastructure

The team stores Bicep templates in a repository. Pull requests show a preview of changes, reviewers approve, and a workflow applies the templates to create consistent environments.

A microservices company on containers

Each service has its own workflow that builds a container image, scans it, pushes it to Azure Container Registry, and updates Azure Container Apps, while a shared reusable workflow keeps all services consistent.

A documentation or marketing site

Content writers edit pages in the repository. Each pull request produces a preview site on Azure Static Web Apps, and merging publishes it automatically.

A data team deploying pipelines and notebooks

Changes to data pipeline definitions are validated in test workspaces by a workflow, then promoted through environments with approvals.

22Advantages and Trade-offs

An honest look helps you decide with open eyes.

Advantages

  • Automation lives next to the code, reviewed and versioned like everything else
  • Passwordless sign-in to Azure through OIDC removes stored secrets
  • Large marketplace of reusable actions, plus official Azure actions
  • Environments, approvals, and branch protection give strong control
  • Easy to start, with templates and portal integration
  • Works with containers, serverless, web apps, and infrastructure as code

Disadvantages / Trade-offs

  • Third-party actions add supply chain risk if not reviewed and pinned
  • Hosted runners cannot reach private networks by default
  • Some protection and governance features depend on your GitHub plan
  • Complex workflows can become hard to read without good structure
  • Runner minutes cost money, and self-hosted runners need maintenance
  • Two systems, GitHub and Azure, must be configured and kept in sync
“The safest pipeline is the one that holds no passwords, has narrow permissions, and asks a human before touching production.”

23Best Practices and Mistakes to Avoid

Habits that keep your pipelines fast, safe, and easy to maintain.

1

Use OIDC instead of stored secrets

Set up federated credentials, and tie them to specific repositories and environments.

2

Apply least privilege everywhere

Use narrow Azure roles at small scopes, and read-only default workflow permissions.

3

Build once, deploy many times

Promote the same tested artifact or image through environments.

4

Protect production

Use protected environments, required reviewers, and branch rules, and make sure every production change goes through them.

5

Use safe release strategies

Prefer slot swaps, blue-green, or canary rollouts, with health checks and a quick rollback path.

6

Manage infrastructure as code

Keep templates in the repository, preview changes, and avoid manual portal edits.

7

Secure and update the supply chain

Pin and review actions, enable scanning, and keep dependencies updated.

8

Watch, measure, and improve

Track pipeline duration and failure rates, monitor releases, and fix slow or flaky steps.

ANTI-PATTERN-04 Avoid
Problem

Using one Azure identity with broad access for every repository, environment, and application.

Why It’s Harmful

A compromise of any one pipeline gives access to everything. A mistake in a test workflow could even change production.

Correct Approach

Create separate identities per application and environment, each trusted only by the matching repository and environment and limited to the resources it needs.

ANTI-PATTERN-05 Avoid
Problem

Rebuilding the application separately for each environment.

Why It’s Harmful

Each build can differ slightly because of changing dependencies, so what you tested in staging may not be what reaches production.

Correct Approach

Build once, store the artifact or image, and deploy that exact artifact to every environment, changing only configuration.

ANTI-PATTERN-06 Avoid
Problem

Pushing straight to production with no tests, no approvals, and no rollback plan, because “it is just a small change”.

Why It’s Harmful

Small changes cause big outages more often than people expect, and without a rollback plan recovery is slow and stressful.

Correct Approach

Keep automated tests and checks mandatory for every change, deploy through staging, and always have a tested way to go back.

24Frequently Asked Questions

Q1Do I need to store an Azure password in GitHub?

Not if you use OpenID Connect. You create a trust between GitHub and a Microsoft Entra identity, and each workflow run exchanges a short-lived token for temporary Azure access. Only non-secret identifiers, such as the client, tenant, and subscription identifiers, are stored.

Q2What is the difference between a workflow, a job, and a step?

A workflow is the whole automated process. It contains one or more jobs, each running on its own runner machine. A job contains steps, which are the individual tasks run in order, such as getting the code, building it, or deploying it.

Q3Can GitHub Actions deploy to a private Azure network?

Standard GitHub-hosted runners run outside your network. To reach private resources, use self-hosted runners placed in your Azure virtual network, or the options that run hosted runners inside your network, subject to your plan. You can also use Azure features that deploy through public management endpoints with proper authentication.

Q4How do I require approval before deploying to production?

Create a production environment in GitHub and add required reviewers, and let the deployment job refer to that environment. The job will pause until a reviewer approves. Combine this with branch restrictions so only trusted branches can deploy.

Q5How can I roll back a bad release?

Use a strategy that keeps the old version ready. With App Service slots, swap back. With container platforms, redeploy or shift traffic to the previous revision or image tag. You can also run a manual workflow that deploys a chosen earlier version.

Q6Should I use GitHub Actions or Azure Pipelines?

Both can deploy well to Azure. Choose GitHub Actions if your code and collaboration live on GitHub and you want automation next to it. Choose Azure Pipelines if you rely on Azure DevOps features such as boards and detailed release management. Avoid mixing them without a reason.

Q7Is it safe to use actions from the marketplace?

It can be, but each action runs with your pipeline’s access, so treat it like third-party software. Prefer trusted publishers, review the code or reputation, pin actions to a full commit identifier, and keep their number small.

Q8How much does it cost?

GitHub plans include some free runner minutes, with extra usage billed per minute, and rates differ by machine type. Self-hosted runners avoid those charges but cost whatever the machines cost in Azure. Azure resources you deploy are billed separately. Check current pricing pages, and use caching and path filters to reduce usage.

25Summary and Key Takeaways

GitHub Actions turns the journey from code to cloud into an automatic, repeatable, and reviewed process. Workflows react to events, jobs run on runners, and steps build, test, scan, and deploy. The most important integration point with Azure is identity: use OpenID Connect and Microsoft Entra federated credentials so pipelines sign in without stored passwords, and give each pipeline identity only the narrow roles it needs. Protected environments and approvals guard production, while staging slots, blue-green, and canary strategies make releases safe and reversible. Infrastructure as code keeps Azure resources consistent, containers and registries package modern applications, and secret stores and scanning keep credentials safe. Secure the pipeline itself, watch its performance and cost, and keep workflows clean and reusable. Done well, releases become small, frequent, and calm.

Key Takeaways

  • Automation next to your code — GitHub Actions workflows are stored in the repository and run when events such as pushes, pull requests, schedules, or manual clicks occur.
  • Know the building blocks — workflows contain jobs, jobs contain steps, steps use actions, and runners are the machines that do the work.
  • Sign in without passwords — use OIDC with Microsoft Entra federated credentials tied to a specific repository and environment, instead of long-lived secrets or publish profiles.
  • Apply least privilege — give each pipeline identity a narrow Azure role on the smallest scope, with separate identities for separate applications and environments.
  • Protect production — use GitHub environments with required reviewers, branch restrictions, and branch protection rules before deployments reach customers.
  • Release safely — build once, deploy the same artifact everywhere, and use slot swaps, blue-green, or canary rollouts with health checks and a quick rollback.
  • Secure and tune the pipeline itself — pin and review actions, enable scanning, use Key Vault and managed identities, cache dependencies, and monitor both pipeline cost and release health.