Working with Service Connections in Azure DevOps

Introduction

Within Azure DevOps, service connections are pivotal for facilitating integration with external services and systems. Their primary purpose is to establish secure connections and authenticate Azure DevOps Services with various platforms, services, or repositories. Service connections streamline the configuration and management of connections, guaranteeing the secure storage of sensitive information like credentials or tokens. Service connections in Azure DevOps serve various use cases across different types of integrations. We will discuss a few use cases followed by a small demo.

Use Cases

  1. Deployment of Azure Resources: Azure service connections are used for the deployment of resources to the Azure platform. This facilitates a smooth integration between Azure DevOps and Azure services, enabling the automated deployment of both applications and infrastructure.
  2. Integration with GitHub: Leveraging GitHub service connections allows seamless integration with GitHub repositories. This proves advantageous in situations such as initiating builds upon code commits, automating release processes, or integrating pull requests into the overall build workflow.
  3. Power Platform ALM: We can achieve CI/CD of Power Platform solutions using Azure Pipelines. We can export/import solutions, and data and perform pre/post deployment steps. To perform all these activities we need a secure connection which is provided by Power Platform Service Connection.

There are several other use cases as well. Now let's discuss a small demo about how to set up a Power Platform service connection.

Steps to Set Power Platform Service Connection

Step 1. Log in to your Azure DevOps organization:  https://dev.azure.com/ {OrganizationName}/ -> Click on Organization Settings.

Azure DevOps

Step 2. Under General Section -> Click on Extensions. Verify under the installed tab if the 'Power Platform Build Tools' Extension is visible. If not click on Browse Marketplace as shown below.

Extension

Step 3. In Marketplace search for 'Power Platform Build Tools' and click on the highlighted option shown below.

Power Platform Build Tools

Step 4. A new pop-up will open, click on Get it free as shown below.

 Pop-up

Step 5. A new pop-up will appear, click on install. The extension will be now available in your organization.

Organization

Step 6. Now navigate to open your Project. Under Project Settings -> Click on Service Connections -> Create Service Connection

Service Connection

Step 7. A new pop-up will appear on the right-hand side. Search for 'Power Platform'. Select the 'Power Platform' service connection and click Next.

Power Platform

 

Step 8. Now configure the service connection. Please consider the following prerequisites: Dynamics CE Environment, Application Registration done with Dynamics CE API permissions, and Application user should be added with System Admin/Customizer security role in the respective environment.

  • In Server URL: Dynamics CE environment URL
  • TenantID: TenantID/ DirectoryID of Application User
  • ApplicationID: ApplicationID/ClientID of Application User
  • Client secret of Application ID: Client Secret of Application User
  • Service Connection Name: Name of the environment which is to be connected.
  • Security: Check the box to give access to all pipelines. (Will depend on CICD strategy followed in the specific project)

Click on Save as shown below.

Edit service connection

Step 9. Once the service connection is created, we can utilize the same in our pipelines. Now go to pipelines and create a new starter YAML pipeline. In this pipeline, we will use two tasks. 'Power Platform Tool Installer' to install all dependencies related to Power Platform and 'Power Platform WHO AM I' to ping the CE environment as shown below.

 Pipelines

Use the below code snippet: Here we have configured the 'WHOAMI' task to use Authentication Type: Service Principal and Service Connection created in Step 8.

trigger:
- main

pool:
  vmImage: windows-latest

steps:
- task: PowerPlatformToolInstaller@2
  inputs:
    DefaultVersion: true
- task: PowerPlatformWhoAmi@2
  inputs:
    authenticationType: 'PowerPlatformSPN'
    PowerPlatformSPN: 'DEV'

Step 10. Click on Save and Run. Below are run logs screenshots where we can see a successful connection was established with the CE environment.

CE environment

Conclusion

In this article, we discussed how we can work with Service Connections in Azure DevOps. This feature has various use cases and we illustrated the same using a demo. From secure deployment of Azure resources to Power Platform ALM deployment there are numerous service connections that can be utilized. We also discussed the setup of a Power Platform service connection and how a connection can be established using Azure pipelines.

Please feel free to reach out in case of any concerns or queries.


Similar Articles