From 5049b8f61558a8c885501cc63a01eb46214834da Mon Sep 17 00:00:00 2001 From: Azure SDK Bot <53356347+azure-sdk@users.noreply.github.com> Date: Wed, 16 Feb 2022 13:01:40 -0800 Subject: [PATCH] Add warning/exit for Az.Resources 5.3.0 service principal provisioning error (#3343) Co-authored-by: Ben Broderick Phillips --- eng/common/TestResources/New-TestResources.ps1 | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/eng/common/TestResources/New-TestResources.ps1 b/eng/common/TestResources/New-TestResources.ps1 index 07ff0839b..fe01142b0 100644 --- a/eng/common/TestResources/New-TestResources.ps1 +++ b/eng/common/TestResources/New-TestResources.ps1 @@ -143,6 +143,14 @@ function Retry([scriptblock] $Action, [int] $Attempts = 5) # https://azure.microsoft.com/en-us/updates/update-your-apps-to-use-microsoft-graph-before-30-june-2022/ function NewServicePrincipalWrapper([string]$subscription, [string]$resourceGroup, [string]$displayName) { + if ((Get-Module Az.Resources).Version -eq "5.3.0") { + # https://github.com/Azure/azure-powershell/issues/17040 + # New-AzAdServicePrincipal calls will fail with: + # "You cannot call a method on a null-valued expression." + Write-Warning "Az.Resources version 5.3.0 is not supported. Please update to >= 5.3.1" + Write-Warning "Update-Module Az.Resources -RequiredVersion 5.3.1" + exit 1 + } $servicePrincipal = Retry { New-AzADServicePrincipal -Role "Owner" -Scope "/subscriptions/$SubscriptionId/resourceGroups/$ResourceGroupName" -DisplayName $displayName }