Skip to content

Commit

Permalink
Sync eng/common directory with azure-sdk-tools for PR 9700 (#32763)
Browse files Browse the repository at this point in the history
Sync eng/common directory with azure-sdk-tools for PR
Azure/azure-sdk-tools#9700 See [eng/common
workflow](https://github.com/Azure/azure-sdk-tools/blob/main/eng/common/README.md#workflow)

Co-authored-by: Ben Broderick Phillips <[email protected]>
  • Loading branch information
azure-sdk and benbp authored Jan 28, 2025
1 parent 28c8313 commit 790fb7e
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions eng/common/TestResources/New-TestResources.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -320,8 +320,14 @@ try {
# Make sure the provisioner OID is set so we can pass it through to the deployment.
if (!$ProvisionerApplicationId -and !$ProvisionerApplicationOid) {
if ($context.Account.Type -eq 'User') {
# Use -Mail as the lookup works in both corp and TME tenants
# Support corp tenant and TME tenant user id lookups
$user = Get-AzADUser -Mail $context.Account.Id
if ($user -eq $null -or !$user.Id) {
$user = Get-AzADUser -UserPrincipalName $context.Account.Id
}
if ($user -eq $null -or !$user.Id) {
throw "Failed to find entra object ID for the current user"
}
$ProvisionerApplicationOid = $user.Id
} elseif ($context.Account.Type -eq 'ServicePrincipal') {
$sp = Get-AzADServicePrincipal -ApplicationId $context.Account.Id
Expand Down Expand Up @@ -391,8 +397,14 @@ try {
Write-Warning "The specified TestApplicationId '$TestApplicationId' will be ignored when -ServicePrincipalAutth is not set."
}

# Use -Mail as the lookup works in both corp and TME tenants
# Support corp tenant and TME tenant user id lookups
$userAccount = (Get-AzADUser -Mail (Get-AzContext).Account.Id)
if ($userAccount -eq $null -or !$userAccount.Id) {
$userAccount = (Get-AzADUser -UserPrincipalName (Get-AzContext).Account)
}
if ($userAccount -eq $null -or !$userAccount.Id) {
throw "Failed to find entra object ID for the current user"
}
$TestApplicationOid = $userAccount.Id
$TestApplicationId = $testApplicationOid
$userAccountName = $userAccount.UserPrincipalName
Expand Down

0 comments on commit 790fb7e

Please sign in to comment.