Good morning Azure expert,
I configured a service connexion with Azure cloud environment in my Azure DevOps server like below
Then in my release I have a Powershell script which need to retrieve some information like TenantID/ SP id / SP secret / Subscription ID.
I do not want to create release variable to avoid duplication.
I'm pretty sure these variables could be retrieve with powershell but I have totally no idea on how to do it. Do you have any idea - suggestions - recommendation ?
Regards, Terry
CodePudding user response:
You can use the below script to get the service connection details which will use the RestAPI,
For example:
$token = "{pat}"
$token = [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes(":$($token)"))
$url="https://dev.azure.com/{organization}/{project}/_apis/serviceendpoint/endpoints?endpointNames={endpointNames}&api-version=6.0-preview.4"
$head = @{ Authorization =" Basic $token" }
Invoke-RestMethod -Uri $url -Method GET -Headers $head
- SOURCE| SO THREAD as suggested by @Jane Ma-MSFT.
For more information please refer the below links: