From b27dcc01d730f2bb364f9334f64d637052d212df Mon Sep 17 00:00:00 2001 From: Azure SDK Bot <53356347+azure-sdk@users.noreply.github.com> Date: Thu, 7 Oct 2021 10:06:14 -0700 Subject: [PATCH] Skip unnecessary and misleading role assignment warnings in local test resource deployment (#18066) Co-authored-by: Ben Broderick Phillips --- 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 3be542213361..189f5185c71e 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