@@ -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