From ffd34e668aaea3576227f2336fd279e11f7fc556 Mon Sep 17 00:00:00 2001 From: Azure SDK Bot <53356347+azure-sdk@users.noreply.github.com> Date: Tue, 8 Oct 2024 11:59:24 -0700 Subject: [PATCH] Persist oidc env vars in deploy template (#1907) Co-authored-by: Ben Broderick Phillips --- .../TestResources/deploy-test-resources.yml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/eng/common/TestResources/deploy-test-resources.yml b/eng/common/TestResources/deploy-test-resources.yml index a0fcc2e31..6cd2a441e 100644 --- a/eng/common/TestResources/deploy-test-resources.yml +++ b/eng/common/TestResources/deploy-test-resources.yml @@ -8,6 +8,7 @@ parameters: ServiceConnection: not-specified ResourceType: test UseFederatedAuth: false + PersistOidcToken: false # SubscriptionConfiguration will be splatted into the parameters of the test # resources script. It should be JSON in the form: @@ -41,12 +42,27 @@ steps: - template: /eng/common/TestResources/setup-environments.yml + - ${{ if parameters.PersistOidcToken }}: + - task: AzureCLI@2 + displayName: Set OIDC token + env: + ARM_OIDC_TOKEN: $(ARM_OIDC_TOKEN) + inputs: + azureSubscription: ${{ parameters.ServiceConnection }} + addSpnToEnvironment: true + scriptLocation: inlineScript + scriptType: pscore + inlineScript: | + Write-Host "##vso[task.setvariable variable=ARM_OIDC_TOKEN;issecret=true]$($env:idToken)" + - ${{ if eq('true', parameters.UseFederatedAuth) }}: - task: AzurePowerShell@5 displayName: 🚀 Deploy test resources env: TEMP: $(Agent.TempDirectory) PoolSubnet: $(PoolSubnet) + ${{ if parameters.PersistOidcToken }}: + ARM_OIDC_TOKEN: $(ARM_OIDC_TOKEN) ${{ insert }}: ${{ parameters.EnvVars }} inputs: azureSubscription: ${{ parameters.ServiceConnection }}