Home Azure Cloud Getting Started with Azure DevOps Service Connections Using Workload Identity Federation

Getting Started with Azure DevOps Service Connections Using Workload Identity Federation

246
0

When working in Azure DevOps, we often need to connect to external services like Azure, GitHub, Docker Hub, or even AWS.
That’s where Service Connections come in — they act like a bridge between your DevOps project and the outside world.


🚀 What is a Service Connection?

A Service Connection in Azure DevOps is a secure link that allows our pipelines to access external resources. Think of it like saving your login credentials in a safe, so that our CI/CD pipelines can automatically deploy, build, or test without asking for credentials each time.

For example:

  • When deploying code to Azure App Service, we need a Service Connection to authenticate with Azure.
  • When pulling a container from Docker Hub, a Service Connection stores our Docker credentials securely.

🔐 Why Do We Need It?

Without a service connection, our pipeline wouldn’t know how to connect to our cloud or external system securely.

Here’s why it’s essential:

  • Security: Credentials are stored securely in Azure DevOps, not in your pipeline code.
  • 🔁 Automation: Pipelines can deploy automatically without manual logins.
  • 👥 Access Control: You can control who can use or manage each connection.
  • 🧠 Consistency: Keeps configuration consistent across teams and environments.

🛠️ Common Types of Service Connections

Here are some popular ones you’ll use often:

TypeDescription
Azure Resource Manager (ARM)Connects to Azure subscriptions to deploy resources.
GitHub / BitbucketConnects to repositories for pulling code.
Docker RegistryConnects to Docker Hub or Azure Container Registry for container images.
Service Principal (Manual)Connects using a custom app registration in Azure AD.
Generic Service ConnectionConnects to APIs or services using a username and token.

⚙️ How to Create a Service Connection (Step-by-Step)

Let’s walk through creating a Service Connection in Azure DevOps to connect with Azure using a service connection with secret. Latest recomendation is to use

  1. Go to your Azure DevOps Project.
  2. Navigate to Project Settings → Service Connections.
  3. Click New Service Connection.
  4. For Service or Connection Type, choose Azure Resource Manager, then click Next.
  5. For Identity Type, select App registration (automatic)this is the currently recommended option.
  6. For Credential, select Secret. (The new recommended option is Workload Identity Federation, which offers more secure authentication.)
  7. Under Scope Level, choose Subscription — this is the most common option.
  8. Pick your Subscription, and optionally limit access by selecting a specific Resource Group.
  9. Enter a Service Connection Name — for example, Cocan-infra-serv-connection.
  10. Do not check Grant access permission to all pipelines if you don’t want all pipelines to automatically use this connection.
  11. Click Save.

We can verify the new service connection from the App registrations page in the connected Entra ID.

Note 1: When we create a Service Connection, Azure DevOps automatically creates a Service Principal in Entra ID (App Registration).
If yur Azure DevOps account has Owner or User Access Administrator permissions on the subscription, it will also assign the Contributor role automatically. Otherwise, ourself or an admin may need to manually assign a suitable role (like Contributor) under Azure Portal → Subscription → Access control (IAM).

Note 2: In this example, we used Azure Resource Manager, but Azure DevOps supports many other service or connection types, such as: Azure Repos / Team Foundation Server, Azure Resource Manager, Azure Service Bus, Bitbucket Cloud, Cargo, Chef, Docker Host, Docker Registry, Generic, GitHub, GitHub Enterprise Server, Incoming WebHook, Jenkins, Jira, Kubernetes, Maven, npm, NuGet, Other Git, Python package download, Python package upload, Service Fabric, SSH, Subversion, and Visual Studio App Center. Each connection type allows Azure DevOps to securely integrate with different tools and platforms — from code repositories and registries to automation, testing, and cloud services.


🧪 Using the Service Connection in Pipelines

Once created, you can reference it in your pipeline YAML file like this:

trigger:
- main

pool:
  vmImage: 'ubuntu-latest'

steps:
- task: AzureWebApp@1
  inputs:
    azureSubscription: 'Azure-Dev-Connection'
    appName: 'mywebapp'
    package: '$(System.DefaultWorkingDirectory)/drop/*.zip'

Here, azureSubscription refers to the Service Connection name we created earlier. We will see this hands on later when we explore terraform.


🧭 Tips and Best Practices

  • 🔑 Use service principals with minimal permissions.
  • 🚫 Don’t hardcode credentials in pipelines.
  • 🧩 Use different service connections for dev, test, and production.
  • 🕵️‍♂️ Regularly review and rotate credentials.
  • 👥 Limit who can edit service connections using Role-Based Access Control (RBAC).

🧠 In Summary

A Service Connection is like a passport that lets Azure DevOps securely interact with other platforms — without you needing to manually log in every time.
It’s one of the most important building blocks of a secure and automated DevOps workflow.

Previous articleGetting Started with Azure DevOps Organization
Next articleModernizing Azure DevOps Service Connections with Workload Identity Federation
Heartin Kanikathottu
As a seasoned Cloud and Security Architect, I’ve led transformative initiatives in key roles, including Vice President at Morgan Stanley, Principal Architect at Societe Generale, and Tech Lead & Cloud Security Architect at VMware, among others. I’m also an internationally published author with multiple books available on platforms like Amazon and O'Reilly. Notably, one of my books was recognized as the 8th best cloud computing book of all time in 2020, reflecting the impact of my contributions to the field. With over 15 professional certifications from providers such as Microsoft (Azure), Amazon (AWS), Oracle (Java), Pivotal (Spring), and IBM, I bring a wealth of expertise to my work. Academically, I hold dual Master’s degrees in Cloud Computing and Data Analytics. I’m passionate about sharing knowledge and mentoring others, which is why I actively speak at global technical forums such as Tech Opportunities Fest at Platform Calgary, Google's Kubernetes Meetup, Java User Group, Elasticsearch Meetup, and the Agile India Conference.

LEAVE A REPLY

Please enter your comment!
Please enter your name here