How to find the auto-created service connection when deploying to AKS

99 Views Asked by At

During a pipeline run, under deployment job, providing a deployment environment eliminates the need of providing service connection manually. I'd guess, it's either creating a new SC at this time or it would have created SC at the time of environment creation and using the same. Either ways, is there a way to find out which Service connection is being used from the logs of pipeline run or from anywhere else? In our environment, I see a lot of service connection for one environment and a cleanup is necessary to get things in place.

I tried giving SC manually along with environment and it works as expected. So, going forward, I can use this method. But for cleanup, I'd still like to know which one gets used when not specified! (none of the auto-created SCs show any execution history, but I know the deployment has happened multiple times)

1

There are 1 best solutions below

0
On

As a Kubernetes resource in an environment is referencing Kubernetes service connection, you can use this API to list the serviceEndpointId of a Kubernetes resource, which is also the resourceId of the referenced service connection.

GET https://dev.azure.com/{organization}/{project}/_apis/distributedtask/environments/{environmentId}/providers/kubernetes/{resourceId}?api-version=7.0

Applied with the value of the serviceEndpointId from the response of the above API, we can proceed to use this API to get the referenced service connection details.

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