Skip to content

Commit 64a45ac

Browse files
committed
fix: workload identity client id and tenant id
1 parent 9a6ab97 commit 64a45ac

File tree

2 files changed

+7
-11
lines changed

2 files changed

+7
-11
lines changed

Tasks/Manage-AutomationAccount/Manage-AutomationAccount.ps1

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ $verboseLog = Get-VstsInput -Name 'verbose' -AsBool
1616
$helperHybridWorkerModuleManagement = Get-VstsInput -Name 'helperHybridWorkerModuleManagement' -AsBool
1717

1818
if ($verboseLog) {
19-
Write-host "Verose log will be enabled"
19+
Write-host "Verbose log will be enabled"
2020
$VerbosePreference = 'Continue'
2121
}
2222
Write-Host "Full sync set to $fullSync"
@@ -57,9 +57,8 @@ Write-Host "Import succeeded!"
5757
Write-Host "Starting process..."
5858
# retrieve service connection object
5959
$serviceConnection = Get-VstsEndpoint -Name $azureSubscription -Require
60-
$serviceConnectionSerialized = ConvertTo-Json $serviceConnection
6160

62-
# define type od service connection
61+
# we support service principal with client secret or certificate, MSI, and workload identity federation
6362
switch ($serviceConnection.auth.scheme) {
6463
'ServicePrincipal' {
6564
# get service connection object properties
@@ -113,10 +112,7 @@ switch ($serviceConnection.auth.scheme) {
113112

114113
Write-Verbose "Getting access token for service connection"
115114
$vstsEndpoint = Get-VstsEndpoint -Name SystemVssConnection -Require
116-
Write-Verbose "VSTS endpoint: `n$($vstsEndpoint | ConvertTo-Json -Depth 99 | Out-String)"
117115
$vstsAccessToken = $vstsEndpoint.auth.parameters.AccessToken
118-
$servicePrincipalId = $vstsEndpoint.auth.parameters.serviceprincipalid
119-
$tenantId = $vstsEndpoint.auth.parameters.tenantid
120116

121117
$url = "$uri/$projectId/_apis/distributedtask/hubs/$hub/plans/$planId/jobs/$jobId/oidctoken?serviceConnectionId=$serviceConnectionId`&api-version=7.2-preview.1"
122118

@@ -127,11 +123,11 @@ switch ($serviceConnection.auth.scheme) {
127123
Write-Verbose "Getting OIDC token from VSTS on uri: $url"
128124
$response = Invoke-RestMethod -Uri $url -Method Post -Headers @{ "Authorization" = ("Basic {0}" -f $base64AuthInfo) } -ContentType "application/json"
129125

130-
Write-Verbose ($response | ConvertTo-Json -Depth 99 | Out-String )
131-
$oidcToken = $response.oidcToken
132-
$assertion = $oidcToken
126+
$assertion = $response.oidcToken
133127

134-
Write-verbose "Initializing AAD factory with assertion $assertion for tenant $tenantId"
128+
$servicePrincipalId = $serviceConnection.auth.parameters.serviceprincipalid
129+
$tenantId = $serviceConnection.auth.parameters.tenantid
130+
Write-verbose "Initializing AAD factory with clientId $servicePrincipalId for tenant $tenantId"
135131
Initialize-AadAuthenticationFactory `
136132
-servicePrincipalId $servicePrincipalId `
137133
-assertion $assertion `

vss-extension.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"manifestVersion": 1,
33
"id": "Manage-AutomationAccount",
44
"name": "Manage-AutomationAccount",
5-
"version": "1.9.127",
5+
"version": "1.9.128",
66
"publisher": "GreyCorbelSolutions",
77
"targets": [
88
{

0 commit comments

Comments
 (0)