From 87036bc05e6824c0fd2a75f6a843a832faa5bbea Mon Sep 17 00:00:00 2001 From: Azure SDK Bot <53356347+azure-sdk@users.noreply.github.com> Date: Wed, 6 Mar 2024 16:13:16 -0800 Subject: [PATCH] TestResources - Bubble up errors in Retry with pipe statements (#5413) Co-authored-by: Ben Broderick Phillips --- eng/common/TestResources/New-TestResources.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/eng/common/TestResources/New-TestResources.ps1 b/eng/common/TestResources/New-TestResources.ps1 index 29be770c5..ae38aefa3 100644 --- a/eng/common/TestResources/New-TestResources.ps1 +++ b/eng/common/TestResources/New-TestResources.ps1 @@ -196,14 +196,14 @@ function NewServicePrincipalWrapper([string]$subscription, [string]$resourceGrou # Submitting a password credential object without specifying a password will result in one being generated on the server side. $password = New-Object -TypeName "Microsoft.Azure.PowerShell.Cmdlets.Resources.MSGraph.Models.ApiV10.MicrosoftGraphPasswordCredential" $password.DisplayName = "Password for $displayName" - $credential = Retry { New-AzADSpCredential -PasswordCredentials $password -ServicePrincipalObject $servicePrincipal } + $credential = Retry { New-AzADSpCredential -PasswordCredentials $password -ServicePrincipalObject $servicePrincipal -ErrorAction 'Stop' } $spPassword = ConvertTo-SecureString $credential.SecretText -AsPlainText -Force $appId = $servicePrincipal.AppId } else { Write-Verbose "Creating service principal credential via MS Graph API" # In 5.2.0 the password credential issue was fixed (see https://github.com/Azure/azure-powershell/pull/16690) but the # parameter set was changed making the above call fail due to a missing ServicePrincipalId parameter. - $credential = Retry { $servicePrincipal | New-AzADSpCredential } + $credential = Retry { $servicePrincipal | New-AzADSpCredential -ErrorAction 'Stop' } $spPassword = ConvertTo-SecureString $credential.SecretText -AsPlainText -Force $appId = $servicePrincipal.AppId }