Skip to content

Commit ff14494

Browse files
azure-sdkbenbp
andauthored
Add warning/exit for Az.Resources 5.3.0 service principal provisioning error (Azure#23037)
Co-authored-by: Ben Broderick Phillips <[email protected]>
1 parent 739f042 commit ff14494

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

eng/common/TestResources/New-TestResources.ps1

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,14 @@ function Retry([scriptblock] $Action, [int] $Attempts = 5)
143143
# https://azure.microsoft.com/en-us/updates/update-your-apps-to-use-microsoft-graph-before-30-june-2022/
144144
function NewServicePrincipalWrapper([string]$subscription, [string]$resourceGroup, [string]$displayName)
145145
{
146+
if ((Get-Module Az.Resources).Version -eq "5.3.0") {
147+
# https://github.com/Azure/azure-powershell/issues/17040
148+
# New-AzAdServicePrincipal calls will fail with:
149+
# "You cannot call a method on a null-valued expression."
150+
Write-Warning "Az.Resources version 5.3.0 is not supported. Please update to >= 5.3.1"
151+
Write-Warning "Update-Module Az.Resources -RequiredVersion 5.3.1"
152+
exit 1
153+
}
146154
$servicePrincipal = Retry {
147155
New-AzADServicePrincipal -Role "Owner" -Scope "/subscriptions/$SubscriptionId/resourceGroups/$ResourceGroupName" -DisplayName $displayName
148156
}

0 commit comments

Comments
 (0)