-
Notifications
You must be signed in to change notification settings - Fork 3.3k
[Synapse] Update role assignment/definition related cmdlets #17476
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
38d6c61
10f3a22
c401ddb
b5774e9
a3c5667
4dc2a9b
6c3eb78
bdf53ca
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -858,6 +858,20 @@ | |
| short-summary: Manage Synapse's role assignments and definitions. | ||
| """ | ||
|
|
||
| helps['synapse role scope'] = """ | ||
| type: group | ||
| short-summary: Manage Synapse's role scopes. | ||
| """ | ||
|
|
||
| helps['synapse role scope list'] = """ | ||
| type: command | ||
| short-summary: List role scopes. | ||
| examples: | ||
| - name: List role scopes. | ||
| text: |- | ||
| az synapse role scope list --workspace-name testsynapseworkspace | ||
| """ | ||
|
|
||
| helps['synapse role assignment'] = """ | ||
| type: group | ||
| short-summary: Manage Synapse's role assignments. | ||
|
|
@@ -883,15 +897,23 @@ | |
| - name: List role assignments by role id/name. | ||
| text: |- | ||
| az synapse role assignment list --workspace-name testsynapseworkspace \\ | ||
| --role "Sql Admin" | ||
| --role "Synapse Apache Spark Administrator" | ||
| - name: List role assignments by assignee. | ||
| text: |- | ||
| az synapse role assignment list --workspace-name testsynapseworkspace \\ | ||
| --assignee sp_name | ||
| - name: List role assignments by objectId of the User, Group or Service Principal. | ||
| text: |- | ||
| az synapse role assignment list --workspace-name testsynapseworkspace \\ | ||
| --assignee 00000000-0000-0000-0000-000000000000 | ||
| --assignee-object-id 00000000-0000-0000-0000-000000000000 | ||
| - name: List role assignments by scope. | ||
| text: |- | ||
| az synapse role assignment list --workspace-name testsynapseworkspace \\ | ||
| --scope "workspaces/{workspaceName}" | ||
| - name: List role assignments by item type and item name. | ||
| text: |- | ||
| az synapse role assignment list --workspace-name testsynapseworkspace \\ | ||
| --item-type "bigDataPools" --item "bigDataPoolName" | ||
| """ | ||
|
|
||
| helps['synapse role assignment create'] = """ | ||
|
|
@@ -901,15 +923,24 @@ | |
| - name: Create a role assignment using service principal name. | ||
| text: |- | ||
| az synapse role assignment create --workspace-name testsynapseworkspace \\ | ||
| --role "Sql Admin" --assignee sp_name | ||
| --role "Synapse Administrator" --assignee sp_name | ||
| - name: Create a role assignment using user principal name. | ||
| text: |- | ||
| az synapse role assignment create --workspace-name testsynapseworkspace \\ | ||
| --role "Sql Admin" --assignee [email protected] | ||
| --role "Synapse Administrator" --assignee [email protected] | ||
| - name: Create a role assignment using objectId of the User, Group or Service Principal. | ||
| text: |- | ||
| az synapse role assignment create --workspace-name testsynapseworkspace \\ | ||
| --role "Sql Admin" --assignee 00000000-0000-0000-0000-000000000000 | ||
| --role "Synapse Administrator" --assignee 00000000-0000-0000-0000-000000000000 | ||
| - name: Create a role assignment at scope. | ||
| text: |- | ||
| az synapse role assignment create --workspace-name testsynapseworkspace \\ | ||
| --scope "workspaces/{workspaceName}" --role "Synapse Administrator" --assignee [email protected] | ||
| - name: Create a role assignment at scope that combination of item type and item name. | ||
| text: |- | ||
| az synapse role assignment create --workspace-name testsynapseworkspace \\ | ||
| --item-type "bigDataPools" --item "bigDataPoolName" --role "Synapse Administrator" \\ | ||
| --assignee [email protected] | ||
| """ | ||
|
|
||
| helps['synapse role assignment delete'] = """ | ||
|
|
@@ -919,11 +950,11 @@ | |
| - name: Delete role assignments by role and assignee. | ||
| text: |- | ||
| az synapse role assignment delete --workspace-name testsynapseworkspace \\ | ||
| --role "Sql Admin" --assignee sp_name | ||
| --role "Synapse Administrator" --assignee sp_name | ||
| - name: Delete role assignments by role id/name. | ||
| text: |- | ||
| az synapse role assignment delete --workspace-name testsynapseworkspace \\ | ||
| --role "Sql Admin" | ||
| --role "Synapse Administrator" | ||
evelyn-ys marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| - name: Delete role assignments by service principal name. | ||
| text: |- | ||
| az synapse role assignment delete --workspace-name testsynapseworkspace \\ | ||
|
|
@@ -954,6 +985,15 @@ | |
| - name: List role definitions. | ||
| text: |- | ||
| az synapse role definition list --workspace-name testsynapseworkspace | ||
| - name: List role definitions by scope. | ||
| text: |- | ||
| az synapse role definition list --workspace-name testsynapseworkspace --scope "workspaces/{workspaceName}" | ||
| - name: List role definitions by item type. | ||
| text: |- | ||
| az synapse role definition list --workspace-name testsynapseworkspace --item-type "bigDataPools" | ||
| - name: List role definitions built-in by Synapse. | ||
| text: |- | ||
| az synapse role definition list --workspace-name testsynapseworkspace --is-built-in True | ||
| """ | ||
|
|
||
| helps['synapse role definition show'] = """ | ||
|
|
@@ -964,6 +1004,10 @@ | |
| text: |- | ||
| az synapse role definition show --workspace-name testsynapseworkspace \\ | ||
| --role 00000000-0000-0000-0000-000000000000 | ||
| - name: Get role definition by role name. | ||
| text: |- | ||
| az synapse role definition show --workspace-name testsynapseworkspace \\ | ||
| --role "Synapse SQL Administrator" | ||
| """ | ||
|
|
||
| helps['synapse linked-service'] = """ | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -139,8 +139,12 @@ def get_custom_sdk(custom_module, client_factory): | |
| operations_tmpl='azure.synapse.spark.operations#SparkBatchOperations.{}', | ||
| client_factory=None) | ||
|
|
||
| synapse_accesscontrol_sdk = CliCommandType( | ||
| operations_tmpl='azure.synapse.accesscontrol.operations#AccessControlClientOperationsMixin.{}', | ||
| synapse_role_assignment_sdk = CliCommandType( | ||
| operations_tmpl='azure.synapse.accesscontrol.operations#RoleAssignmentsOperations.{}', | ||
| client_factory=None) | ||
Juliehzl marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| synapse_role_definitions_sdk = CliCommandType( | ||
| operations_tmpl='azure.synapse.accesscontrol.operations#RoleAssignmentsOperations.{}', | ||
evelyn-ys marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| client_factory=None) | ||
|
|
||
| synapse_linked_service_sdk = CliCommandType( | ||
|
|
@@ -375,18 +379,22 @@ def get_custom_sdk(custom_module, client_factory): | |
| g.custom_command('cancel', 'cancel_spark_session_statement', confirmation=True) | ||
|
|
||
| # Data Plane Commands --Access control operations | ||
| with self.command_group('synapse role assignment', synapse_accesscontrol_sdk, | ||
| with self.command_group('synapse role assignment', synapse_role_assignment_sdk, | ||
| custom_command_type=get_custom_sdk('accesscontrol', None)) as g: | ||
| g.custom_command('create', 'create_role_assignment') | ||
| g.custom_command('list', 'list_role_assignments') | ||
| g.custom_show_command('show', 'get_role_assignment_by_id') | ||
| g.custom_command('delete', 'delete_role_assignment', confirmation=True) | ||
|
|
||
| with self.command_group('synapse role definition', synapse_accesscontrol_sdk, | ||
| with self.command_group('synapse role definition', synapse_role_definitions_sdk, | ||
| custom_command_type=get_custom_sdk('accesscontrol', None)) as g: | ||
| g.custom_command('list', 'list_role_definitions') | ||
| g.custom_show_command('show', 'get_role_definition') | ||
|
|
||
| with self.command_group('synapse role scope', synapse_role_definitions_sdk, | ||
| custom_command_type=get_custom_sdk('accesscontrol', None)) as g: | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You could declare your client factory here and don't need to define in every fuction. |
||
| g.custom_command('list', 'list_scopes') | ||
|
|
||
| # Data Plane Commands --Artifacts Linked service operations | ||
| with self.command_group('synapse linked-service', synapse_linked_service_sdk, | ||
| custom_command_type=get_custom_sdk('artifacts', None)) as g: | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,6 +12,9 @@ | |
| SPARK_DOTNET_UDFS_FOLDER_NAME = 'udfs' | ||
| SPARK_SERVICE_ENDPOINT_API_VERSION = '2019-11-01-priview' | ||
| AdministratorType = "activeDirectory" | ||
| ITEM_NAME_MAPPING = {'bigDataPools': '{bigDataPoolName}', 'integrationRuntimes': '{integrationRuntimeName}', | ||
| 'linkedServices': '{linkedServiceName}', 'credentials': '{credentialName}', | ||
| 'scopePools': '{scopePoolName}'} | ||
evelyn-ys marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
|
|
||
| class SynapseSqlCreateMode(str, Enum): | ||
|
|
@@ -62,3 +65,17 @@ class SqlPoolConnectionClientAuthenticationType(str, Enum): | |
| SqlPassword = 'SqlPassword' | ||
| ActiveDirectoryPassword = 'ADPassword' | ||
| ActiveDirectoryIntegrated = 'ADIntegrated' | ||
|
|
||
|
|
||
| class PrincipalType(str, Enum): | ||
| user = "User" | ||
| group = "Group" | ||
| service_principal = "ServicePrincipal" | ||
|
|
||
|
|
||
| class ItemType(str, Enum): | ||
| bigDataPools = "bigDataPools" | ||
| scopePools = "scopePools" | ||
evelyn-ys marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| integrationRuntimes = "integrationRuntimes" | ||
| credentials = "credentials" | ||
| linkedServices = "linkedServices" | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why not define in SDK?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @Juliehzl I think this not belong to SDK's scope, we define these item type for CLI using friendly. User can pass item type and CLI code will use this parameter to generate
@idear1203 Do we have a plan to move it to SDK?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Currently we don't have such definitions in SDK. This is a good suggestion.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see. |
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does
Sql Adminstill work?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, now Synapse is using new role name.
Synapse SQL Administrator
Synapse Apache Spark Administrator
...
https://docs.microsoft.com/en-us/azure/synapse-analytics/security/synapse-workspace-synapse-rbac-roles
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this way, it is breaking change to existing customers and we should try to avoid such breaking.
To not break customers, you should try to make previous definition work and add deprecation info to redirect to new definition.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we just allow this breaking change considering that the module is still in preview? Now Synapse moves to new names, we don't want to allow the old names.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding breaking change description at History Notes
[Synapse] BREAKING CHANGE: az synapse role assignment create: Role names at old version are not allowed, Sql Admin, Apache Spark Admin, Workspace Admin
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see. According to the telemetry, there is no much usage for this command as it is in preview. So we could accept the breaking change this time. Please note that we need to avoid breaking change as possible as we can in future design.