Skip unnecessary and misleading role assignment warnings in local test resource deployment (#2954)

Co-authored-by: Ben Broderick Phillips <bebroder@microsoft.com>
This commit is contained in:
Azure SDK Bot 2021-10-07 10:06:09 -07:00 committed by GitHub
parent bcfbe44a73
commit e7747b4af9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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