From 28fba9b96410ecc6370dca6cd85241c5e1789968 Mon Sep 17 00:00:00 2001 From: Ben Broderick Phillips Date: Tue, 5 Oct 2021 16:18:47 -0400 Subject: [PATCH] Skip unnecessary and misleading role assignment warnings in local test resource deployment --- eng/common/TestResources/New-TestResources.ps1 | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/eng/common/TestResources/New-TestResources.ps1 b/eng/common/TestResources/New-TestResources.ps1 index 3be54221336..189f5185c71 100644 --- a/eng/common/TestResources/New-TestResources.ps1 +++ b/eng/common/TestResources/New-TestResources.ps1 @@ -463,7 +463,10 @@ try { # service principal without permissions to grant RBAC roles to other service principals. That should not be # considered a critical failure, as the test application may have subscription-level permissions and not require # the explicit grant. - if (!$resourceGroupRoleAssigned) { + # + # Ignore this check if $AzureTestPrincipal is specified as role assignment will already have been attempted on a + # previous run, and these error messages can be misleading for local runs. + if (!$resourceGroupRoleAssigned -and !$AzureTestPrincipal) { Log "Attempting to assigning the 'Owner' role for '$ResourceGroupName' to the Test Application '$TestApplicationId'" $principalOwnerAssignment = New-AzRoleAssignment -RoleDefinitionName "Owner" -ApplicationId "$TestApplicationId" -ResourceGroupName "$ResourceGroupName" -ErrorAction SilentlyContinue