-
Notifications
You must be signed in to change notification settings - Fork 850
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refresh OIDC token in azadmin test resources scripts
- Loading branch information
Showing
4 changed files
with
102 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# Copyright (c) Microsoft Corporation. All rights reserved. | ||
# Licensed under the MIT License. | ||
|
||
# IMPORTANT: Do not invoke this file directly. Please instead run eng/New-TestResources.ps1 from the repository root. | ||
|
||
#Requires -Version 6.0 | ||
#Requires -PSEdition Core | ||
|
||
using namespace System.Security.Cryptography | ||
using namespace System.Security.Cryptography.X509Certificates | ||
|
||
# Use same parameter names as declared in eng/New-TestResources.ps1 (assume validation therein). | ||
[CmdletBinding(SupportsShouldProcess = $true, ConfirmImpact = 'Medium')] | ||
param ( | ||
[Parameter(Mandatory = $true)] | ||
[ValidateNotNullOrEmpty()] | ||
[string] $SubscriptionId, | ||
|
||
[Parameter(Mandatory = $true)] | ||
[ValidateNotNullOrEmpty()] | ||
[string] $TenantId, | ||
|
||
[Parameter(Mandatory = $true)] | ||
[ValidatePattern('^[0-9a-f]{8}(-[0-9a-f]{4}){3}-[0-9a-f]{12}$')] | ||
[string] $TestApplicationId, | ||
|
||
[Parameter(Mandatory = $true)] | ||
[ValidatePattern('^[0-9a-f]{8}(-[0-9a-f]{4}){3}-[0-9a-f]{12}$')] | ||
[string] $TestApplicationOid, | ||
|
||
[Parameter(Mandatory = $true)] | ||
[ValidateNotNullOrEmpty()] | ||
[string] $Environment, | ||
|
||
# Captures any arguments from eng/New-TestResources.ps1 not declared here (no parameter errors). | ||
[Parameter(ValueFromRemainingArguments = $true)] | ||
$RemainingArguments | ||
) | ||
|
||
# By default stop for any error. | ||
if (!$PSBoundParameters.ContainsKey('ErrorAction')) { | ||
$ErrorActionPreference = 'Stop' | ||
} | ||
|
||
function Log($Message) { | ||
Write-Host ('{0} - {1}' -f [DateTime]::Now.ToLongTimeString(), $Message) | ||
} | ||
|
||
Log "Refreshing OIDC token" | ||
az cloud set -n $Environment | ||
az login --federated-token $env:ARM_OIDC_TOKEN --service-principal -t $TenantId -u $TestApplicationId | ||
if ($LASTEXITCODE) { exit $LASTEXITCODE } | ||
az account set --subscription $SubscriptionId | ||
if ($LASTEXITCODE) { exit $LASTEXITCODE } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters