← Back to Article List         
Workload Identity Federation and Service Connection Security

Workload Identity Federation and Service Connection Security

Published on 08 Oct 2026     9 min read Azure DevOps
Service Connections

These two concepts are closely related and are very important for Azure DevOps interviews, especially when discussing secure CI/CD pipelines and production deployments.

1. What is Workload Identity Federation?

Workload Identity Federation (WIF) is a modern authentication mechanism that allows Azure DevOps Pipelines to securely authenticate to Microsoft Azure without storing client secrets, passwords, or certificates.

Instead of using a permanent credential, Azure DevOps uses a short-lived federated token that Microsoft Entra ID validates and exchanges for an Azure access token.

Why do we need Workload Identity Federation?

Traditionally, Azure DevOps authenticated to Azure using a Service Principal with a client secret.

For example:

Azure DevOps Pipeline
        |
        v
Service Connection
        |
        | Client ID
        | Tenant ID
        | Client Secret
        |
        v
Microsoft Entra ID
        |
        v
Azure Resources

This approach has several disadvantages:

  • Client secrets have expiration dates.

  • Secrets must be stored and protected.

  • Expired secrets can cause deployment failures.

  • Leaked secrets can allow unauthorized access.

  • Secret rotation requires additional maintenance.

Workload Identity Federation eliminates the need to store these long-lived client secrets.

2. How does Workload Identity Federation work?

Consider an ASP.NET Core Web API application deployed through Azure Pipelines.

Authentication flow

Developer
    |
    v
Azure Repos
    |
    v
Azure Pipeline
    |
    v
Azure Resource Manager
Service Connection
    |
    | 1. Request federated token
    v
Azure DevOps Token Issuer
    |
    | 2. Issue short-lived OIDC token
    v
Microsoft Entra ID
    |
    | 3. Validate issuer, subject,
    |    audience and token signature
    |
    | 4. Exchange for Azure access token
    v
Azure Resource Manager
    |
    | 5. Check Azure RBAC permissions
    v
Azure App Service
    |
    v
Application Deployed

Step-by-step explanation

Step 1 – Create a Service Connection

Create an Azure Resource Manager Service Connection using Workload Identity Federation.

Step 2 – Configure a trusted identity

Azure DevOps uses a Microsoft Entra application (Service Principal) or a supported user-assigned managed identity.

A federated identity credential establishes trust between the Azure DevOps token issuer and the Azure identity.

Step 3 – Pipeline requests a token

When the deployment task runs, Azure DevOps issues a short-lived OIDC token for the authorized Service Connection.

Step 4 – Microsoft Entra ID validates the token

Microsoft Entra ID checks the token's signature and configured trust details, including issuer, subject, and audience.

Step 5 – Azure access token is issued

If validation succeeds, Microsoft Entra ID issues an access token for the configured identity.

Step 6 – Azure verifies permissions

Azure Resource Manager checks the identity's Azure RBAC permissions before allowing deployment operations.

Important: Workload Identity Federation eliminates stored client secrets, but it does not eliminate the need for an identity or Azure RBAC permissions.

 

3. How do you configure Workload Identity Federation?

Navigate to:

Azure DevOps
    |
    v
Project Settings
    |
    v
Service Connections
    |
    v
New Service Connection
    |
    v
Azure Resource Manager
    |
    v
Workload Identity Federation
(Automatic)
    |
    v
Select Azure Subscription
    |
    v
Select Resource Group / Scope
    |
    v
Enter Service Connection Name
    |
    v
Save

Example configuration:

Property

Value

Authentication

Workload Identity Federation

Azure Subscription

ProductionSubscription

Resource Group

rg-jntech-prod

Service Connection

sc-azure-prod

Target App Service

jntech-api-prod

Automatic configuration requires appropriate Azure and Microsoft Entra permissions. Otherwise, manual federation setup may be necessary.

YAML example

- task: AzureWebApp@1
  displayName: 'Deploy ASP.NET Core API'
  inputs:
    azureSubscription: 'sc-azure-prod'
    appType: 'webApp'
    appName: 'jntech-api-prod'
    package: '$(Pipeline.Workspace)/drop/**/*.zip'

The task uses the Service Connection to obtain the required Azure access token.

You do not need to include a client secret in the YAML.

The deployment task must support the selected authentication mechanism.

 

4. Workload Identity Federation vs Client Secret Authentication

Feature

Client Secret

Workload Identity Federation

Authentication

Client ID and secret

Short-lived federated token

Stored client secret

Required

Not required

Secret expiration

Must be managed

No client-secret expiration

Secret rotation

Required

No client-secret rotation

Credential leakage risk

Higher

Lower

Microsoft recommendation

Legacy alternative

Preferred for supported scenarios

Azure RBAC required

Yes

Yes

Workload Identity Federation reduces credential-management risks, but federated tokens and Azure access tokens must still be protected from exposure.

 

5. How should Service Connection permissions be secured using least privilege?

The Principle of Least Privilege (PoLP) means giving an identity or pipeline only the minimum permissions required to perform its job.

For example, if an Azure Pipeline only deploys an ASP.NET Core application to an Azure App Service, it should not automatically receive permissions to manage the entire Azure subscription.

Example: Incorrect configuration

Azure Subscription
       |
       v
Service Connection
       |
       | Owner Role
       | Subscription Scope
       |
       v
Production Pipeline
       |
       v
Deploy One App Service

Here, the deployment identity has unnecessarily broad permissions.

Recommended configuration

Azure Subscription
       |
       v
Production Resource Group
       |
       v
Required Azure RBAC Role
       |
       v
Production Service Connection
       |
       v
Authorized Production Pipeline
       |
       v
Azure App Service

The Service Connection should have access only to the resources and operations required for deployment.

6. Important security practices

A. Restrict Azure RBAC permissions

Use the minimum Azure role required.

Role

Permission

Reader

View resources

Website Contributor

Manage App Service websites within assigned scope

Contributor

Manage most resources within assigned scope

Owner

Manage resources and role assignments

For an App Service deployment, a role such as Website Contributor may be appropriate depending on the deployment operation.

Avoid assigning Owner or subscription-wide Contributor by default.

B. Restrict pipeline access

When creating a Service Connection, you may see:

Grant access permission to all pipelines

For Production, leave this unchecked.

Instead, navigate to:

Project Settings
    |
    v
Service Connections
    |
    v
sc-azure-prod
    |
    v
More Options (...)
    |
    v
Security / Pipeline Permissions
    |
    v
Authorize Required Pipelines Only

This prevents unrelated pipelines from automatically using the production connection.

C. Use separate Service Connections for environments

Environment

Service Connection

Access

Dev

sc-azure-dev

Development resources

SIT

sc-azure-sit

SIT resources

UAT

sc-azure-uat

UAT resources

Production

sc-azure-prod

Production resources

Example:

Development Pipeline
       |
       v
sc-azure-dev
       |
       v
Development Resources


Production Pipeline
       |
       v
sc-azure-prod
       |
       v
Production Resources

Prefer separate identities and appropriately scoped RBAC assignments for sensitive environments.

This reduces the risk of development pipelines affecting production.

D. Configure approvals and checks

For production Service Connections, configure approval checks where supported.

Example:

Developer Pushes Code
        |
        v
CI Pipeline
        |
        v
Build Artifact
        |
        v
Production Deployment Stage
        |
        v
Service Connection Approval
        |
        +---- Rejected ---> Deployment Stopped
        |
        v
Approved
        |
        v
Production Deployment

Approvals and checks can be configured through the protected resource's Approvals and checks settings.

Important: Pipeline authorization and approval checks are different. Pipeline authorization controls whether a pipeline can use the connection; approval checks control whether a particular run can proceed.

E. Restrict Service Connection administration

Not every developer should be allowed to create, modify, or administer production Service Connections.

Use Azure DevOps Service Connection security roles:

Role

Responsibility

Reader

View connection details

User

Use the connection in authorized pipelines

Creator

Create Service Connections

Administrator

Manage connections and permissions

Grant administrative access only to trusted personnel.

Also protect the production branch and restrict who can modify deployment YAML files.

F. Use Workload Identity Federation

Prefer federated authentication rather than storing long-lived secrets.

Even with WIF, protect tokens, restrict identity permissions, and monitor deployment activity.

 

7. Real-world example: ASP.NET Core deployment across environments

Suppose you maintain an ASP.NET Core Web API deployed to Dev, SIT, UAT, and Production.

A secure configuration would be:

                  Azure DevOps
                       |
                       v
                   CI Pipeline
                       |
                       v
                 Build Artifact
                       |
          +------------+-------------+
          |            |             |
          v            v             v
     DEV Pipeline  SIT Pipeline  UAT Pipeline
          |            |             |
          v            v             v
      sc-dev        sc-sit        sc-uat
          |            |             |
          v            v             v
      Dev App       SIT App       UAT App


                 Production Stage
                       |
                       v
                Approval / Checks
                       |
                       v
                   sc-prod
                       |
                       v
             Production App Service

Each connection should have its own authorized pipeline set and appropriately scoped Azure permissions.

The same build artifact can be promoted through all environments without rebuilding the application.

 

8. Common interview questions and answers

Q1. Why is Workload Identity Federation more secure than client secret authentication?

It removes the need to store long-lived client secrets. Azure DevOps uses short-lived federated tokens to authenticate through Microsoft Entra ID.

Q2. Does Workload Identity Federation require a Service Principal?

It requires a trusted Azure identity. Azure Resource Manager Service Connections can use a Microsoft Entra application with a Service Principal or a supported user-assigned managed identity.

Q3. What happens if a federated token expires?

The token cannot be used after expiration. A supported pipeline task can request a fresh token through the Service Connection when required.

Q4. What is least privilege in Azure DevOps?

Least privilege means granting pipelines and deployment identities only the permissions necessary for their operations.

Q5. How do you prevent a development pipeline from deploying to Production?

Use a dedicated Production Service Connection, restrict its pipeline permissions, assign narrowly scoped Azure RBAC permissions, protect deployment YAML and branches, and configure production approval checks.

Q6. Is Workload Identity Federation enough to secure a production deployment?

No. It secures the authentication method. Production deployments also require authorization controls, RBAC, approvals, pipeline security, and auditing.

Q7. What is the difference between Azure RBAC and Service Connection pipeline permissions?

Azure RBAC determines which Azure resources and operations the identity can access.

Pipeline permissions determine which Azure Pipelines are allowed to use the Service Connection.

 

9. Interview-ready answer

Question 1: What is Workload Identity Federation?

Workload Identity Federation is a secure authentication mechanism that allows Azure DevOps Pipelines to access Azure resources without storing client secrets.

Azure DevOps obtains a short-lived federated token, which Microsoft Entra ID validates and exchanges for an Azure access token.

This reduces credential-management risks and eliminates client-secret rotation for the federated connection.

Question 2: How do you secure Service Connections using least privilege?

I secure Service Connections by assigning only the required Azure RBAC permissions at the narrowest practical scope.

I use separate Service Connections for Dev, SIT, UAT, and Production and restrict which pipelines can use each connection.

For Production, I configure approvals and checks, limit Service Connection administration, protect deployment branches, and prefer Workload Identity Federation instead of client secrets.

This ensures that pipelines have only the access required to perform their deployment tasks.

Key interview distinction:

Workload Identity Federation
    = HOW the pipeline authenticates

Azure RBAC
    = WHAT the identity can do in Azure

Service Connection Pipeline Permissions
    = WHICH pipelines can use the connection

Approvals and Checks
    = WHEN deployment can proceed

These four controls work together to secure Azure DevOps deployments.