Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 26 additions & 12 deletions src/ServiceBus/ServiceBus/Utilities/ServiceBusClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ public PSNamespaceAttributes BeginCreateNamespace(string resourceGroupName, stri
if (identityType != null)
{
parameter.Identity = new Identity();
parameter.Identity = FindIdentity(identityType);
parameter.Identity.Type = FindIdentity(identityType);
}

if (identityIds != null)
Expand All @@ -132,6 +132,11 @@ public PSNamespaceAttributes BeginCreateNamespace(string resourceGroupName, stri
{
parameter.Identity.UserAssignedIdentities = UserAssignedIdentities;
}

if (parameter.Identity.Type == ManagedServiceIdentityType.None || parameter.Identity.Type == ManagedServiceIdentityType.SystemAssigned)
{
throw new Exception("Please change -IdentityType to 'UserAssigned' or 'SystemAssigned, UserAssigned' if you want to add User Assigned Identities");
}
}

if (encryptionconfigs != null)
Expand Down Expand Up @@ -204,9 +209,14 @@ public PSNamespaceAttributes UpdateNamespace(string resourceGroupName, string na

if (identityType != null)
{
parameter.Identity = new Identity();
parameter.Identity = FindIdentity(identityType);
if (parameter.Identity.Type == ManagedServiceIdentityType.None)
if (parameter.Identity == null)
{
parameter.Identity = new Identity();
}

parameter.Identity.Type = FindIdentity(identityType);

if (parameter.Identity.Type == ManagedServiceIdentityType.None || parameter.Identity.Type == ManagedServiceIdentityType.SystemAssigned)
{
parameter.Identity.UserAssignedIdentities = null;
}
Expand All @@ -226,6 +236,10 @@ public PSNamespaceAttributes UpdateNamespace(string resourceGroupName, string na
{
parameter.Identity.UserAssignedIdentities = UserAssignedIdentities;
}
if (parameter.Identity.Type == ManagedServiceIdentityType.None || parameter.Identity.Type == ManagedServiceIdentityType.SystemAssigned)
{
throw new Exception("Please change -IdentityType to 'UserAssigned' or 'SystemAssigned, UserAssigned' if you want to add User Assigned Identities");
}
}

if (encryptionconfigs != null)
Expand Down Expand Up @@ -264,26 +278,26 @@ public PSNamespaceAttributes UpdateNamespace(string resourceGroupName, string na
return new PSNamespaceAttributes(response);
}

public Identity FindIdentity(string identityType)
public ManagedServiceIdentityType FindIdentity(string identityType)
{
Identity identity = new Identity();

ManagedServiceIdentityType Type = ManagedServiceIdentityType.None;
if (identityType == SystemAssigned)
identity.Type = ManagedServiceIdentityType.SystemAssigned;
Type = ManagedServiceIdentityType.SystemAssigned;

else if (identityType == UserAssigned)
identity.Type = ManagedServiceIdentityType.UserAssigned;
Type = ManagedServiceIdentityType.UserAssigned;

else if (identityType == SystemAssignedUserAssigned)
identity.Type = ManagedServiceIdentityType.SystemAssignedUserAssigned;
Type = ManagedServiceIdentityType.SystemAssignedUserAssigned;

else if (identityType == None)
identity.Type = ManagedServiceIdentityType.None;
Type = ManagedServiceIdentityType.None;

return identity;
return Type;
}



public bool BeginDeleteNamespace(string resourceGroupName, string namespaceName)
{
Client.Namespaces.DeleteWithHttpMessagesAsync(resourceGroupName, namespaceName, null, new CancellationToken()).ConfigureAwait(false);
Expand Down