Skip to content

Commit 61e9c57

Browse files
azure-sdkbenbp
andauthored
TestResources - Bubble up errors in Retry with pipe statements (#34667)
Co-authored-by: Ben Broderick Phillips <[email protected]>
1 parent 45805b7 commit 61e9c57

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

eng/common/TestResources/New-TestResources.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,14 +196,14 @@ function NewServicePrincipalWrapper([string]$subscription, [string]$resourceGrou
196196
# Submitting a password credential object without specifying a password will result in one being generated on the server side.
197197
$password = New-Object -TypeName "Microsoft.Azure.PowerShell.Cmdlets.Resources.MSGraph.Models.ApiV10.MicrosoftGraphPasswordCredential"
198198
$password.DisplayName = "Password for $displayName"
199-
$credential = Retry { New-AzADSpCredential -PasswordCredentials $password -ServicePrincipalObject $servicePrincipal }
199+
$credential = Retry { New-AzADSpCredential -PasswordCredentials $password -ServicePrincipalObject $servicePrincipal -ErrorAction 'Stop' }
200200
$spPassword = ConvertTo-SecureString $credential.SecretText -AsPlainText -Force
201201
$appId = $servicePrincipal.AppId
202202
} else {
203203
Write-Verbose "Creating service principal credential via MS Graph API"
204204
# In 5.2.0 the password credential issue was fixed (see https://github.com/Azure/azure-powershell/pull/16690) but the
205205
# parameter set was changed making the above call fail due to a missing ServicePrincipalId parameter.
206-
$credential = Retry { $servicePrincipal | New-AzADSpCredential }
206+
$credential = Retry { $servicePrincipal | New-AzADSpCredential -ErrorAction 'Stop' }
207207
$spPassword = ConvertTo-SecureString $credential.SecretText -AsPlainText -Force
208208
$appId = $servicePrincipal.AppId
209209
}

0 commit comments

Comments
 (0)