@@ -124,7 +124,7 @@ public PSNamespaceAttributes BeginCreateNamespace(string resourceGroupName, stri
124
124
if ( identityType != null )
125
125
{
126
126
parameter . Identity = new Identity ( ) ;
127
- parameter . Identity = FindIdentity ( identityType ) ;
127
+ parameter . Identity . Type = FindIdentity ( identityType ) ;
128
128
}
129
129
130
130
if ( identityId != null )
@@ -142,6 +142,10 @@ public PSNamespaceAttributes BeginCreateNamespace(string resourceGroupName, stri
142
142
{
143
143
parameter . Identity . UserAssignedIdentities = UserAssignedIdentities ;
144
144
}
145
+ if ( parameter . Identity . Type == ManagedServiceIdentityType . None || parameter . Identity . Type == ManagedServiceIdentityType . SystemAssigned )
146
+ {
147
+ throw new Exception ( "Please change -IdentityType to 'UserAssigned' or 'SystemAssigned, UserAssigned' if you want to add User Assigned Identities" ) ;
148
+ }
145
149
}
146
150
147
151
if ( encryptionConfigs != null )
@@ -233,8 +237,23 @@ public PSNamespaceAttributes BeginUpdateNamespace(string resourceGroupName,
233
237
if ( isKafkaEnabled )
234
238
parameter . KafkaEnabled = isKafkaEnabled ;
235
239
236
- if ( isIdentity )
237
- parameter . Identity = new Identity ( ) { Type = ManagedServiceIdentityType . SystemAssigned } ;
240
+ if ( isIdentity ) {
241
+ if ( parameter . Identity == null )
242
+ {
243
+ parameter . Identity = new Identity ( ) { Type = ManagedServiceIdentityType . SystemAssigned } ;
244
+ }
245
+ else
246
+ {
247
+ if ( parameter . Identity . Type == ManagedServiceIdentityType . None )
248
+ {
249
+ parameter . Identity = new Identity ( ) { Type = ManagedServiceIdentityType . SystemAssigned } ;
250
+ }
251
+ if ( parameter . Identity . Type == ManagedServiceIdentityType . UserAssigned )
252
+ {
253
+ parameter . Identity = new Identity ( ) { Type = ManagedServiceIdentityType . SystemAssignedUserAssigned } ;
254
+ }
255
+ }
256
+ }
238
257
239
258
if ( isDisableLocalAuth )
240
259
parameter . DisableLocalAuth = isDisableLocalAuth ;
@@ -318,9 +337,14 @@ public PSNamespaceAttributes BeginUpdateNamespace(string resourceGroupName,
318
337
}
319
338
if ( identityType != null )
320
339
{
321
- parameter . Identity = new Identity ( ) ;
322
- parameter . Identity = FindIdentity ( identityType ) ;
323
- if ( parameter . Identity . Type == ManagedServiceIdentityType . None )
340
+ if ( parameter . Identity == null )
341
+ {
342
+ parameter . Identity = new Identity ( ) ;
343
+ }
344
+
345
+ parameter . Identity . Type = FindIdentity ( identityType ) ;
346
+
347
+ if ( parameter . Identity . Type == ManagedServiceIdentityType . None || parameter . Identity . Type == ManagedServiceIdentityType . SystemAssigned )
324
348
{
325
349
parameter . Identity . UserAssignedIdentities = null ;
326
350
}
@@ -340,6 +364,10 @@ public PSNamespaceAttributes BeginUpdateNamespace(string resourceGroupName,
340
364
{
341
365
parameter . Identity . UserAssignedIdentities = UserAssignedIdentities ;
342
366
}
367
+ if ( parameter . Identity . Type == ManagedServiceIdentityType . None || parameter . Identity . Type == ManagedServiceIdentityType . SystemAssigned )
368
+ {
369
+ throw new Exception ( "Please change -IdentityType to UserAssigned or 'SystemAssigned, UserAssigned' if you want to add User Assigned Identities" ) ;
370
+ }
343
371
}
344
372
345
373
if ( encryptionConfigs != null )
@@ -377,25 +405,25 @@ public PSNamespaceAttributes BeginUpdateNamespace(string resourceGroupName,
377
405
return new PSNamespaceAttributes ( response ) ;
378
406
}
379
407
380
- public Identity FindIdentity ( string identityType )
408
+ public ManagedServiceIdentityType FindIdentity ( string identityType )
381
409
{
382
- Identity identity = new Identity ( ) ;
383
-
410
+ ManagedServiceIdentityType Type = ManagedServiceIdentityType . None ;
384
411
if ( identityType == SystemAssigned )
385
- identity . Type = ManagedServiceIdentityType . SystemAssigned ;
412
+ Type = ManagedServiceIdentityType . SystemAssigned ;
386
413
387
414
else if ( identityType == UserAssigned )
388
- identity . Type = ManagedServiceIdentityType . UserAssigned ;
415
+ Type = ManagedServiceIdentityType . UserAssigned ;
389
416
390
417
else if ( identityType == SystemAssignedUserAssigned )
391
- identity . Type = ManagedServiceIdentityType . SystemAssignedUserAssigned ;
418
+ Type = ManagedServiceIdentityType . SystemAssignedUserAssigned ;
392
419
393
420
else if ( identityType == None )
394
- identity . Type = ManagedServiceIdentityType . None ;
421
+ Type = ManagedServiceIdentityType . None ;
395
422
396
- return identity ;
423
+ return Type ;
397
424
}
398
425
426
+
399
427
public void BeginDeleteNamespace ( string resourceGroupName , string namespaceName )
400
428
{
401
429
Client . Namespaces . DeleteAsync ( resourceGroupName , namespaceName ) ;
0 commit comments