0

I am building a report to summarize release definitions in Azure DevOps. This report will perform various checks to determine the health of the release definition. One of the checks I would like to implement is to determine if the Azure Service Connection the deployment phase is set to is still valid.

Currently I'm able to retrieve the YAML for the release definition, and the release instances however neither seem to indicate the specific service connection that's being used. The PowerShell commands I'm using are:

az pipelines release definition show
az pipelines release show

The YAML returned has several nodes such as deployPhases, deploySteps, releaseDeployPhases, deploymentJobs however for a release definition configured for a service connection I don't see any information in the release definition or the instance that indicates which service connection is being used.

The closest the YAML has to information about a service connection are references to variable such as $(ConnectedServiceName) and $(Parameters.ConnectedServiceName).

I'm also unable to find any information in either the Azure CLI or Rest API documentation on how to find the service connection for a release definition. The documentation I have checked is:

YAML Schema: https://learn.microsoft.com/en-us/azure/devops/pipelines/yaml-schema?view=azure-devops&tabs=schema

Azure-DevOps (Azure CLI): https://learn.microsoft.com/en-us/cli/azure/ext/azure-devops/?view=azure-cli-latest

Is it possible to query the CLI and retrieve Service Connection information based on the YAML returned for a release definition, or a release instance?

Stone
  • 1

1 Answers1

0

Service Connections are stored at Azure DevOps project level, so you can retrieve them from DevOps Rest API:

GET https://dev.azure.com/{organization}/{project}/_apis/serviceendpoint/endpoints?api-version=5.1-preview.2

More information at https://learn.microsoft.com/en-us/rest/api/azure/devops/serviceendpoint/endpoints/get%20service%20endpoints?view=azure-devops-rest-5.1

Sadiq Khoja
  • 522
  • 1
  • 5
  • 23
  • Thanks! That's for a Service Endpoint however I'm looking for information about retrieving Service Connections. I believe the endpoint is for networking related policies and the service connection is for integrating DevOps release pipelines. Here is the documentation for creating the type of service connection I want to retrieve programmatically: https://learn.microsoft.com/en-us/azure/devops/pipelines/library/service-endpoints?view=azure-devops&tabs=yaml – Stone Jan 08 '20 at 14:35
  • I think both are same, if you lookup the value of `$(ConnectedServiceName)` in the response of Service Endpoint API, you can check its state – Sadiq Khoja Jan 09 '20 at 03:42