Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
062146a
fixing compliationerror
zesluo1 Feb 10, 2021
97f37c4
getroleassignment
zesluo1 Feb 19, 2021
d2fa903
refine parametersetname
zesluo1 Mar 12, 2021
b1cd8b5
Merge branch 'master' into zeshi/accesscontrolnewsdk
zesluo1 Mar 12, 2021
7197b83
add scope to newroleassignment
zesluo1 Mar 15, 2021
5487fc7
add list scope command
zesluo1 Mar 15, 2021
0d10f47
refine new-azuresynapseroleassignment
zesluo1 Mar 16, 2021
f412876
add Itemtype and Item
zesluo1 Mar 16, 2021
e787196
refine newAzureSynapseRoleAssignment
zesluo1 Mar 19, 2021
df14f92
remove unnecessary feeds
zesluo1 Mar 19, 2021
2a509b7
refine deleteroleassignmentid
zesluo1 Mar 23, 2021
84236ef
refine resourceid name
zesluo1 Mar 23, 2021
6a3ca26
improve remove and getroleassignments
zesluo1 Mar 31, 2021
585d3f7
itemtype and item improvement
zesluo1 Apr 1, 2021
7284040
Fix a few issues
Apr 2, 2021
2583a84
Correct exception types
Apr 2, 2021
91e1e29
add principle type
zesluo1 Apr 5, 2021
c8555d3
add principaltype
zesluo1 Apr 6, 2021
ee1ba9a
Merge branch 'master' of https://github.com/Azure/azure-powershell in…
zesluo1 Apr 6, 2021
ab1f2e7
caseinsent
zesluo1 Apr 6, 2021
12ea62c
update changelog
zesluo1 Apr 6, 2021
850226c
add doc for get-azsyanpserolescope
zesluo1 Apr 6, 2021
c8184ca
remove powershlles
zesluo1 Apr 6, 2021
24232cb
update help doc
zesluo1 Apr 6, 2021
351318e
add objectid back
zesluo1 Apr 6, 2021
eba1c34
update Az.Synapse.md
zesluo1 Apr 6, 2021
4f35647
update auto generated mdfiles
zesluo1 Apr 6, 2021
43c8e1d
update changelog
zesluo1 Apr 7, 2021
d6f8a4c
update changelog2
zesluo1 Apr 7, 2021
bc5873e
update changelog3
zesluo1 Apr 7, 2021
99336aa
update changelog4
zesluo1 Apr 7, 2021
11576cd
update changelog5
zesluo1 Apr 8, 2021
ce1fb1f
update changelog6
zesluo1 Apr 8, 2021
05c3fc1
update changelog7
zesluo1 Apr 8, 2021
4e6c2fa
Update src/Synapse/Synapse/ChangeLog.md
zesluo1 Apr 8, 2021
474ae0d
Merge branch 'release-2021-04-13' into zeshi/accesscontrolnewsdk
BethanyZhou Apr 8, 2021
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
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,7 @@ public override void ExecuteCmdlet()
}
else
{
var roleAssignment = SynapseAnalyticsClient.ListRoleAssignments(this.RoleDefinitionId, this.ObjectId)
.Select(element => new PSRoleAssignmentDetails(element));
var roleAssignment = SynapseAnalyticsClient.ListRoleAssignments(this.RoleDefinitionId, this.ObjectId).Value.Select(element => new PSRoleAssignmentDetails(element));

// TODO: Currently, when only `ObjectId` is specified, the cmdlet returns incorrect result. Filter from client side as a workaround
if (!string.IsNullOrEmpty(this.ObjectId))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,16 @@ public class NewAzureSynapseRoleAssignment : SynapseRoleCmdletBase
private const string NewByWorkspaceNameAndIdParameterSet = "NewByWorkspaceNameAndIdParameterSet";
private const string NewByWorkspaceObjectAndNameParameterSet = "NewByWorkspaceObjectAndNameParameterSet";
private const string NewByWorkspaceObjectAndIdParameterSet = "NewByWorkspaceObjectAndIdParameterSet";
private const string NewByWorkspaceNameAndRoleDefinitionIdAndObjectIdParameterSet = "NewByWorkspaceNameAndRoleDefinitionIdAndObjectIdParameterSet";
private const string NewByWorkspaceObjectAndRoleDefinitionIdAndObjectIdParameterSet = "NewByWorkspaceObjectAndRoleDefinitionIdAndObjectIdParameterSet";
private const string NewByWorkspaceNameAndRoleAssignmentIdAndObjectIdParameterSet = "NewByWorkspaceNameAndRoleAssignmentIdAndObjectIdParameterSet";
private const string NewByWorkspaceObjectAndRoleAssignmentIdAndObjectIdParameterSet = "NewByWorkspaceObjectAndRoleAssignmentIdAndObjectIdParameterSet";
private const string NewByWorkspaceNameAndServicePrincipalNameParameterSet = "NewByWorkspaceNameAndServicePrincipalNameParameterSet";
private const string NewByWorkspaceObjectAndServicePrincipalNameParameterSet = "NewByWorkspaceObjectAndServicePrincipalNameParameterSet";
Comment thread
zesluo marked this conversation as resolved.

[Parameter(ValueFromPipelineByPropertyName = false, ParameterSetName = NewByWorkspaceNameAndNameParameterSet,
Mandatory = true, HelpMessage = HelpMessages.WorkspaceName)]
[Parameter(ValueFromPipelineByPropertyName = false, ParameterSetName = NewByWorkspaceNameAndIdParameterSet,
Mandatory = true, HelpMessage = HelpMessages.WorkspaceName)]
[Parameter(ValueFromPipelineByPropertyName = false, ParameterSetName = NewByWorkspaceNameAndRoleDefinitionIdAndObjectIdParameterSet,
[Parameter(ValueFromPipelineByPropertyName = false, ParameterSetName = NewByWorkspaceNameAndRoleAssignmentIdAndObjectIdParameterSet,
Mandatory = true, HelpMessage = HelpMessages.WorkspaceName)]
[Parameter(ValueFromPipelineByPropertyName = false, ParameterSetName = NewByWorkspaceNameAndServicePrincipalNameParameterSet,
Mandatory = true, HelpMessage = HelpMessages.WorkspaceName)]
Expand All @@ -41,7 +41,7 @@ public class NewAzureSynapseRoleAssignment : SynapseRoleCmdletBase
Mandatory = true, HelpMessage = HelpMessages.WorkspaceObject)]
[Parameter(ValueFromPipeline = true, ParameterSetName = NewByWorkspaceObjectAndIdParameterSet,
Mandatory = true, HelpMessage = HelpMessages.WorkspaceObject)]
[Parameter(ValueFromPipeline = true, ParameterSetName = NewByWorkspaceObjectAndRoleDefinitionIdAndObjectIdParameterSet,
[Parameter(ValueFromPipeline = true, ParameterSetName = NewByWorkspaceObjectAndRoleAssignmentIdAndObjectIdParameterSet,
Mandatory = true, HelpMessage = HelpMessages.WorkspaceObject)]
[Parameter(ValueFromPipeline = true, ParameterSetName = NewByWorkspaceObjectAndServicePrincipalNameParameterSet,
Mandatory = true, HelpMessage = HelpMessages.WorkspaceObject)]
Expand All @@ -63,9 +63,9 @@ public class NewAzureSynapseRoleAssignment : SynapseRoleCmdletBase
[ValidateNotNullOrEmpty]
public string RoleDefinitionName { get; set; }

[Parameter(ValueFromPipelineByPropertyName = false, ParameterSetName = NewByWorkspaceNameAndRoleDefinitionIdAndObjectIdParameterSet,
[Parameter(ValueFromPipelineByPropertyName = false, ParameterSetName = NewByWorkspaceNameAndRoleAssignmentIdAndObjectIdParameterSet,
Mandatory = true, HelpMessage = HelpMessages.RoleDefinitionId)]
[Parameter(ValueFromPipelineByPropertyName = false, ParameterSetName = NewByWorkspaceObjectAndRoleDefinitionIdAndObjectIdParameterSet,
[Parameter(ValueFromPipelineByPropertyName = false, ParameterSetName = NewByWorkspaceObjectAndRoleAssignmentIdAndObjectIdParameterSet,
Mandatory = true, HelpMessage = HelpMessages.RoleDefinitionId)]
[ValidateNotNullOrEmpty]
public string RoleDefinitionId { get; set; }
Expand All @@ -89,14 +89,21 @@ public class NewAzureSynapseRoleAssignment : SynapseRoleCmdletBase
Mandatory = true, HelpMessage = HelpMessages.PrincipalId)]
[Parameter(ValueFromPipelineByPropertyName = false, ParameterSetName = NewByWorkspaceObjectAndIdParameterSet,
Mandatory = true, HelpMessage = HelpMessages.PrincipalId)]
[Parameter(ValueFromPipelineByPropertyName = false, ParameterSetName = NewByWorkspaceNameAndRoleDefinitionIdAndObjectIdParameterSet,
[Parameter(ValueFromPipelineByPropertyName = false, ParameterSetName = NewByWorkspaceNameAndRoleAssignmentIdAndObjectIdParameterSet,
Mandatory = true, HelpMessage = HelpMessages.PrincipalId)]
[Parameter(ValueFromPipelineByPropertyName = false, ParameterSetName = NewByWorkspaceObjectAndRoleDefinitionIdAndObjectIdParameterSet,
[Parameter(ValueFromPipelineByPropertyName = false, ParameterSetName = NewByWorkspaceObjectAndRoleAssignmentIdAndObjectIdParameterSet,
Mandatory = true, HelpMessage = HelpMessages.PrincipalId)]
[Alias("Id", "PrincipalId")]
[ValidateNotNullOrEmpty]
public string ObjectId { get; set; }

[Parameter(ValueFromPipelineByPropertyName = false, ParameterSetName = NewByWorkspaceNameAndIdParameterSet,
Mandatory = true, HelpMessage = HelpMessages.Scope)]
[Parameter(ValueFromPipelineByPropertyName = false, ParameterSetName = NewByWorkspaceObjectAndIdParameterSet,
Mandatory = true, HelpMessage = HelpMessages.Scope)]
[ValidateNotNullOrEmpty]
public string Scope { get; set; }

[Parameter(Mandatory = false, HelpMessage = HelpMessages.AsJob)]
public SwitchParameter AsJob { get; set; }

Expand Down Expand Up @@ -124,7 +131,8 @@ public override void ExecuteCmdlet()

if (this.ShouldProcess(this.WorkspaceName, String.Format(Resources.CreatingSynapseRoleAssignment, this.WorkspaceName, this.RoleDefinitionId, this.ObjectId)))
{
PSRoleAssignmentDetails roleAssignmentDetails = new PSRoleAssignmentDetails(SynapseAnalyticsClient.CreateRoleAssignment(this.RoleDefinitionId, this.ObjectId));
string RoleAssignmentId = this.RoleDefinitionId + "-" + this.ObjectId;
Comment thread
zesluo marked this conversation as resolved.
Outdated
PSRoleAssignmentDetails roleAssignmentDetails = new PSRoleAssignmentDetails(SynapseAnalyticsClient.CreateRoleAssignment(RoleAssignmentId, this.RoleDefinitionId, this.ObjectId, this.Scope));
Comment thread
zesluo marked this conversation as resolved.
Outdated
WriteObject(roleAssignmentDetails);
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/Synapse/Synapse/Common/HelpMessages.cs
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,8 @@ SELECT on dbo.myTable by public

public const string PrincipalId = "The Azure AD ObjectId of the User, Group or Service Principal.";

public const string Scope = "The Scope of the user.";
Comment thread
zesluo marked this conversation as resolved.
Outdated

public const string SignInName = "The email address or the user principal name of the user.";

public const string ServicePrincipalName = "The ServicePrincipalName of the service principal.";
Expand Down
4 changes: 2 additions & 2 deletions src/Synapse/Synapse/Models/PSRoleAssignmentDetails.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ public class PSRoleAssignmentDetails
public PSRoleAssignmentDetails(RoleAssignmentDetails roleAssignmentDetails)
{
this.RoleAssignmentId = roleAssignmentDetails.Id;
this.RoleDefinitionId = roleAssignmentDetails.RoleId;
this.ObjectId = roleAssignmentDetails.PrincipalId;
this.RoleDefinitionId = roleAssignmentDetails.RoleDefinitionId.ToString();
this.ObjectId = roleAssignmentDetails.PrincipalId.ToString();
}
Comment thread
zesluo marked this conversation as resolved.

public string RoleAssignmentId { get; set; }
Expand Down
6 changes: 3 additions & 3 deletions src/Synapse/Synapse/Models/PSSynapseRole.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ namespace Microsoft.Azure.Commands.Synapse.Models
{
public class PSSynapseRole
{
public PSSynapseRole(SynapseRole synapseRole)
public PSSynapseRole(SynapseRoleDefinition synapseRole)
{
this.Id = synapseRole.Id;
this.Id = synapseRole.Id.ToString();
Comment thread
zesluo marked this conversation as resolved.
Outdated
this.Name = synapseRole.Name;
this.IsBuiltIn = synapseRole.IsBuiltIn;
}
Comment thread
zesluo marked this conversation as resolved.
Expand All @@ -18,6 +18,6 @@ public PSSynapseRole(SynapseRole synapseRole)

public string Name { get; set; }

public bool IsBuiltIn { get; set; }
public bool? IsBuiltIn { get; set; }
}
}
34 changes: 18 additions & 16 deletions src/Synapse/Synapse/Models/SynapseAnalyticsRoleClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ namespace Microsoft.Azure.Commands.Synapse.Models
{
public class SynapseAnalyticsRoleClient
{
private readonly AccessControlClient _accessControlClient;
private readonly RoleAssignmentsClient _roleAssignmentsClient;
private readonly RoleDefinitionsClient _roleDefinitionsClient;
private readonly ActiveDirectoryClient _activeDirectoryClient;

public SynapseAnalyticsRoleClient(string workspaceName, IAzureContext context)
Expand All @@ -29,45 +30,46 @@ public SynapseAnalyticsRoleClient(string workspaceName, IAzureContext context)

string suffix = context.Environment.GetEndpoint(AzureEnvironment.ExtendedEndpoint.AzureSynapseAnalyticsEndpointSuffix);
Uri uri = new Uri("https://" + workspaceName + "." + suffix);
_accessControlClient = new AccessControlClient(uri, new AzureSessionCredential(context));
_roleAssignmentsClient = new RoleAssignmentsClient(uri, new AzureSessionCredential(context));
_roleDefinitionsClient = new RoleDefinitionsClient(uri, new AzureSessionCredential(context));
_activeDirectoryClient = new ActiveDirectoryClient(context);
}

public IReadOnlyList<RoleAssignmentDetails> ListRoleAssignments(string roleDefinitionId = null, string objectId = null, string continuationToken = null)
public RoleAssignmentDetailsList ListRoleAssignments(string roleDefinitionId = null, string objectId = null, string continuationToken = null)
{
return _accessControlClient.GetRoleAssignments(roleDefinitionId, objectId, continuationToken).Value;
return _roleAssignmentsClient.ListRoleAssignments(roleDefinitionId, objectId, continuationToken).Value;
Comment thread
zesluo marked this conversation as resolved.
Outdated
}

public RoleAssignmentDetails GetRoleAssignmentById(string roleAssignmentId)
{
return _accessControlClient.GetRoleAssignmentById(roleAssignmentId);
return _roleAssignmentsClient.GetRoleAssignmentById(roleAssignmentId);
}

public RoleAssignmentDetails CreateRoleAssignment(string roleDefinitionId, string objectId)
public RoleAssignmentDetails CreateRoleAssignment(string roleAssignmentId, string RoleDefinitionId, string objectId, string scope)
{
RoleAssignmentOptions roleAssignmentOptions = new RoleAssignmentOptions(roleDefinitionId, objectId);
return _accessControlClient.CreateRoleAssignment(roleAssignmentOptions).Value;
//RoleAssignmentOptions roleAssignmentOptions = new RoleAssignmentOptions(roleAssignmentId, objectId);
Comment thread
zesluo marked this conversation as resolved.
Outdated
return _roleAssignmentsClient.CreateRoleAssignment(roleAssignmentId, new Guid(RoleDefinitionId), new Guid(objectId), scope);
}

public void DeleteRoleAssignmentById(string roleAssignmentId)
{
_accessControlClient.DeleteRoleAssignmentById(roleAssignmentId);
_roleAssignmentsClient.DeleteRoleAssignmentById(roleAssignmentId);
}

public void DeleteRoleAssignmentByName(string roleDefinitionId, string objectId)
{
string roleAssignmentId = roleDefinitionId + "-" + objectId;
_accessControlClient.DeleteRoleAssignmentById(roleAssignmentId);
_roleAssignmentsClient.DeleteRoleAssignmentById(roleAssignmentId);
}
Comment thread
zesluo marked this conversation as resolved.

public Pageable<SynapseRole> GetRoleDefinitions()
public IReadOnlyList<SynapseRoleDefinition> GetRoleDefinitions()
{
return _accessControlClient.GetRoleDefinitions();
return _roleDefinitionsClient.ListRoleDefinitions().Value;
}

public SynapseRole GetRoleDefinitionById(string roleId)
public SynapseRoleDefinition GetRoleDefinitionById(string roleId)
{
return _accessControlClient.GetRoleDefinitionById(roleId).Value;
return _roleDefinitionsClient.GetRoleDefinitionById(roleId).Value;
}

public string GetObjectIdFromSignInName(string signInName)
Expand Down Expand Up @@ -106,12 +108,12 @@ public string GetRoleDefinitionIdFromRoleDefinitionName(string roleDefinitionNam
{
return null;
}
var roleDefinition = _accessControlClient.GetRoleDefinitions().SingleOrDefault(element => element.Name == roleDefinitionName);
var roleDefinition = _roleDefinitionsClient.ListRoleDefinitions().Value.SingleOrDefault(element => element.Name == roleDefinitionName);
Comment thread
zesluo marked this conversation as resolved.
Outdated
if (roleDefinition == null)
{
throw new InvalidOperationException(String.Format(Resources.RoleDefinitionNameDoesNotExist, roleDefinitionName));
}
return roleDefinition.Id;
return roleDefinition.Id.ToString();
}
}
}
Binary file not shown.
Binary file not shown.