Skip to content

Commit 308678f

Browse files
author
Hovsep
committed
Merge pull request Azure#1704 from pomortaz/dev
Fixed removing key vault access policy when the service principal is removed
2 parents 4b9ba97 + 8e0711f commit 308678f

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/ResourceManager/KeyVault/Commands.KeyVault/Commands/RemoveAzureKeyVaultAccessPolicy.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -153,9 +153,11 @@ public override void ExecuteCmdlet()
153153
var updatedPolicies = existingVault.AccessPolicies;
154154
if (!string.IsNullOrEmpty(UserPrincipalName) || !string.IsNullOrEmpty(ServicePrincipalName) || (ObjectId != Guid.Empty))
155155
{
156-
Guid objId = GetObjectId(this.ObjectId, this.UserPrincipalName, this.ServicePrincipalName);
157-
158-
updatedPolicies = existingVault.AccessPolicies.Where(ap => !ShallBeRemoved(ap, objId, this.ApplicationId)).ToArray();
156+
if (ObjectId == Guid.Empty)
157+
{
158+
ObjectId = GetObjectId(this.ObjectId, this.UserPrincipalName, this.ServicePrincipalName);
159+
}
160+
updatedPolicies = existingVault.AccessPolicies.Where(ap => !ShallBeRemoved(ap, ObjectId, this.ApplicationId)).ToArray();
159161
}
160162

161163
// Update the vault

0 commit comments

Comments
 (0)