diff --git a/deployment/azure-service-connection-azdo-access.yml b/deployment/azure-service-connection-azdo-access.yml index 9c253560..ade232d4 100644 --- a/deployment/azure-service-connection-azdo-access.yml +++ b/deployment/azure-service-connection-azdo-access.yml @@ -1,4 +1,8 @@ parameters: +- name: azureDevOpsServiceConnection + displayName: Azure DevOps Service Connection + type: string + default: my-azdo-connection - name: serviceConnection displayName: Azure Service Connection Name type: string @@ -87,3 +91,23 @@ jobs: | Select-Object id, name failOnStandardError: true + - task: PowerShell@2 + displayName: 'Get-AzDoToken' + inputs: + azureDevOpsServiceConnection: '${{ parameters.azureDevOpsServiceConnection }}' + targetType: 'inline' + script: | + $token = Get-AzDoToken + + Write-Host "`nUse token with Azure DevOps REST API to list pools in the organization '$(System.CollectionUri)'..." + $apiVersion = "7.1-preview.1" + $apiUrl = "$(System.CollectionUri)_apis/distributedtask/pools?api-version=${apiVersion}" + Invoke-RestMethod -Uri $apiUrl ` + -Headers @{ + Accept = "application/json" + Authorization = "Bearer $token" + "Content-Type" = "application/json" + } ` + -Method Get ` + | Select-Object -ExpandProperty value ` + | Select-Object id, name \ No newline at end of file diff --git a/get-azdo-token.yml b/get-azdo-token.yml new file mode 100644 index 00000000..0061f922 --- /dev/null +++ b/get-azdo-token.yml @@ -0,0 +1,29 @@ +parameters: +- name: azureDevOpsServiceConnection + displayName: Azure DevOps Service Connection + type: string + default: my-azdo-connection + +pool: + vmImage: windows-latest + +steps: +- task: PowerShell@2 + inputs: + azureDevOpsServiceConnection: '${{ parameters.azureDevOpsServiceConnection }}' + targetType: 'inline' + script: | + $token = Get-AzDoToken + + Write-Host "`nUse token with Azure DevOps REST API to list pools in the organization '$(System.CollectionUri)'..." + $apiVersion = "7.1-preview.1" + $apiUrl = "$(System.CollectionUri)_apis/distributedtask/pools?api-version=${apiVersion}" + Invoke-RestMethod -Uri $apiUrl ` + -Headers @{ + Accept = "application/json" + Authorization = "Bearer $token" + "Content-Type" = "application/json" + } ` + -Method Get ` + | Select-Object -ExpandProperty value ` + | Select-Object id, name diff --git a/scripts/azure-devops b/scripts/azure-devops index 88259fa9..15c836a9 160000 --- a/scripts/azure-devops +++ b/scripts/azure-devops @@ -1 +1 @@ -Subproject commit 88259fa96296d41788cf35623d0e9916b5264b23 +Subproject commit 15c836a975013e63e28144c85e82fb84ea2c467f diff --git a/scripts/identity b/scripts/identity index ffcbd129..7fff30cd 160000 --- a/scripts/identity +++ b/scripts/identity @@ -1 +1 @@ -Subproject commit ffcbd129152037a7443f17a27962523561f5f5e3 +Subproject commit 7fff30cd994a7d7ce6edcd223acea53db4838c44