From f6c2148806cc1834d5c24e99b20811594d889c1a Mon Sep 17 00:00:00 2001 From: Beisi Zhou Date: Wed, 10 Apr 2024 16:02:00 +0800 Subject: [PATCH] replace managed user assigned identity instead of appending (#1329) --- powershell/cmdlets/class.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/powershell/cmdlets/class.ts b/powershell/cmdlets/class.ts index d3030ecec0..eb26823118 100644 --- a/powershell/cmdlets/class.ts +++ b/powershell/cmdlets/class.ts @@ -1159,7 +1159,9 @@ export class CmdletClass extends Class { return If('this.UserAssignedIdentity?.Length > 0', function* () { yield '// calculate UserAssignedIdentity'; - yield ForEach('id', 'this.UserAssignedIdentity', `${$this.bodyParameter?.value}.${$this.GetUserAssignedIdentityPropertyName()}.Add(id, new ${$this.GetUserAssignedIdentityParameterElementType()}());`); + const userAssignedIdentityPropertyName = $this.GetUserAssignedIdentityPropertyName(); + yield `${$this.bodyParameter?.value}.${userAssignedIdentityPropertyName}.Clear();`; + yield ForEach('id', 'this.UserAssignedIdentity', `${$this.bodyParameter?.value}.${userAssignedIdentityPropertyName}.Add(id, new ${$this.GetUserAssignedIdentityParameterElementType()}());`); yield ''; } );