Skip to content

Commit 896afed

Browse files
azure-sdkbenbp
andauthored
Sync eng/common directory with azure-sdk-tools for PR 9529 (Azure#47555)
* Use -Mail for test resources local user lookup to support TME * Auto-select TME subscription based on user context --------- Co-authored-by: Ben Broderick Phillips <[email protected]>
1 parent 14cbb4a commit 896afed

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

eng/common/TestResources/New-TestResources.ps1

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -244,10 +244,16 @@ try {
244244
$context = Get-AzContext
245245
}
246246
} else {
247-
if ($currentSubcriptionId -ne 'faa080af-c1d8-40ad-9cce-e1a450ca5b57') {
247+
if ($context.Tenant.Name -like '*TME*') {
248+
if ($currentSubscriptionId -ne '4d042dc6-fe17-4698-a23f-ec6a8d1e98f4') {
249+
Log "Attempting to select subscription 'Azure SDK Test Resources - TME (4d042dc6-fe17-4698-a23f-ec6a8d1e98f4)'"
250+
$null = Select-AzSubscription -Subscription '4d042dc6-fe17-4698-a23f-ec6a8d1e98f4' -ErrorAction Ignore
251+
# Update the context.
252+
$context = Get-AzContext
253+
}
254+
} elseif ($currentSubcriptionId -ne 'faa080af-c1d8-40ad-9cce-e1a450ca5b57') {
248255
Log "Attempting to select subscription 'Azure SDK Developer Playground (faa080af-c1d8-40ad-9cce-e1a450ca5b57)'"
249256
$null = Select-AzSubscription -Subscription 'faa080af-c1d8-40ad-9cce-e1a450ca5b57' -ErrorAction Ignore
250-
251257
# Update the context.
252258
$context = Get-AzContext
253259
}
@@ -261,6 +267,7 @@ try {
261267
'faa080af-c1d8-40ad-9cce-e1a450ca5b57' = 'Azure SDK Developer Playground'
262268
'a18897a6-7e44-457d-9260-f2854c0aca42' = 'Azure SDK Engineering System'
263269
'2cd617ea-1866-46b1-90e3-fffb087ebf9b' = 'Azure SDK Test Resources'
270+
'4d042dc6-fe17-4698-a23f-ec6a8d1e98f4' = 'Azure SDK Test Resources - TME '
264271
}
265272

266273
# Print which subscription is currently selected.
@@ -313,7 +320,8 @@ try {
313320
# Make sure the provisioner OID is set so we can pass it through to the deployment.
314321
if (!$ProvisionerApplicationId -and !$ProvisionerApplicationOid) {
315322
if ($context.Account.Type -eq 'User') {
316-
$user = Get-AzADUser -UserPrincipalName $context.Account.Id
323+
# Use -Mail as the lookup works in both corp and TME tenants
324+
$user = Get-AzADUser -Mail $context.Account.Id
317325
$ProvisionerApplicationOid = $user.Id
318326
} elseif ($context.Account.Type -eq 'ServicePrincipal') {
319327
$sp = Get-AzADServicePrincipal -ApplicationId $context.Account.Id
@@ -383,7 +391,8 @@ try {
383391
Write-Warning "The specified TestApplicationId '$TestApplicationId' will be ignored when -ServicePrincipalAutth is not set."
384392
}
385393

386-
$userAccount = (Get-AzADUser -UserPrincipalName (Get-AzContext).Account)
394+
# Use -Mail as the lookup works in both corp and TME tenants
395+
$userAccount = (Get-AzADUser -Mail (Get-AzContext).Account.Id)
387396
$TestApplicationOid = $userAccount.Id
388397
$TestApplicationId = $testApplicationOid
389398
$userAccountName = $userAccount.UserPrincipalName

0 commit comments

Comments
 (0)