Skip to content

[Synapse] Add customer-managed key related cmdlets#16224

Merged
jsntcy merged 14 commits intoAzure:devfrom
sunsw1994:synapse-cmk
Jan 26, 2021
Merged

[Synapse] Add customer-managed key related cmdlets#16224
jsntcy merged 14 commits intoAzure:devfrom
sunsw1994:synapse-cmk

Conversation

@sunsw1994
Copy link
Contributor

@sunsw1994 sunsw1994 commented Dec 10, 2020

Description

Add some new commands to manage customer-managed key under synapse workspace.

Testing Guide

az synapse workspace create -h
az synapse workspace key -h
az synapse workspace managed-identity -h

History Notes

[Synapse] az synapse workspace create : Add key-identifier parameter to support to create workspace using customer-managed key.
[Synapse] az synapse workspace key: Add CRUD cmdlets to support to manage keys under specified synapse workspace.
[Synapse] az synapse workspace managed-identity: Add cmdlets to support CRUD managed identity to sql access setting.
[Synapse] az synapse workspace: Add data exfiltration protection support, add allowed_aad_tenant_ids parameter.


This checklist is used to make sure that common guidelines for a pull request are followed.

@yonzhan
Copy link
Collaborator

yonzhan commented Dec 10, 2020

Synapse

@yonzhan yonzhan requested a review from jsntcy December 10, 2020 10:51
@yonzhan yonzhan added this to the S180 milestone Dec 10, 2020
@sunsw1994
Copy link
Contributor Author

Existing ci errors are not caused by the code change from this PR.


def create_workspace(cmd, client, resource_group_name, workspace_name, storage_account, file_system,
sql_admin_login_user, sql_admin_login_password, location, enable_managed_virtual_network=None,
sql_admin_login_user, sql_admin_login_password, location, key_name="default", key_identifier=None, enable_managed_virtual_network=None,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just curious here:
As you know key identifier contains the key name, if customer only provides the key_identifier and maybe the key name in key identifier is not "default", what will happen?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The key name is the display name at synapse workspace, different from the name of key-vault.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The key name is the display name at synapse workspace, different from the name of key-vault.

But the parameter is --key-name, maybe customer will think it is the key vault name, do you think it is a little confused?
@idear1203 How do you like?
I suggest to change the parameter name and give a clear description.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the current name --key-name is fine. It it different from --key-vault-name


In reply to: 540663549 [](ancestors = 540663549)

@aim-for-better
Copy link
Member

Could you please also update the related test cases?

c.argument('sql_admin_login_password', options_list=['--sql-admin-login-password', '-p'],
help='The sql administrator login password.')
c.argument('tags', arg_type=tags_type)
c.argument('key_name', help='The workspace key name.')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The workspace key name. [](start = 41, length = 23)

Shall we give more concrete description to make it clear that it is the workspace display key name instead of the name of key vault?

@sunsw1994 sunsw1994 marked this pull request as draft December 11, 2020 05:10
@sunsw1994 sunsw1994 marked this pull request as ready for review December 25, 2020 07:04
@yonzhan yonzhan modified the milestones: S180, S181 Dec 26, 2020
@sunsw1994
Copy link
Contributor Author

@jsntcy Could you please help to review this PR? Thanks.

@jsntcy jsntcy requested a review from Juliehzl January 15, 2021 01:56
@yonzhan yonzhan modified the milestones: S181, S182 Jan 15, 2021
identity = ManagedIdentity(type=identity_type)
account_url = "https://{}.dfs.{}".format(storage_account, cmd.cli_ctx.cloud.suffixes.storage_endpoint)
default_data_lake_storage = DataLakeStorageAccountDetails(account_url=account_url, filesystem=file_system)
if str(key_identifier).endswith('/'):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

key_identifier [](start = 11, length = 14)

If key_identifier is none, will logic here fail or not?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

str(None).endswith('/') will return false.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it can be removed. Do you think so?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree to remove the check logic. It seems not quite necessary. Server side should determine whether to accept backslash.

encryption = EncryptionDetails(cmk=CustomerManagedKeyDetails(key=workspace_key_detail))
managed_virtual_network_settings = None
if enable_managed_virtual_network:
managed_virtual_network_settings = ManagedVirtualNetworkSettings(preventDataExfiltration=True, allowed_aad_tenant_ids_for_linking=allowed_aad_tenant_ids)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

preventDataExfiltration=True [](start = 73, length = 28)

I remember from portal, this property can be False

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will add a parameter to indicate whether enable data exfiltration.

--enable_data_exfiltration is fine?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, sounds good.

def update_workspace(cmd, client, resource_group_name, workspace_name, sql_admin_login_password=None,
tags=None, no_wait=False):
workspace_patch_info = WorkspacePatchInfo(tags=tags, sql_admin_login_password=sql_admin_login_password)
allowed_aad_tenant_ids=None, disable_all_allowed_aad_tenant_ids=None, tags=None, key_name=None, key_identifier=None, no_wait=False):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

allowed_aad_tenant_ids=None, disable_all_allowed_aad_tenant_ids=None, [](start = 21, length = 69)

Is it possible to combine these two parameters? For example, is it possible for users to pass an empty list (v.s. None value) to CLI?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

allowed_aad_tenant_ids is a List type defined in CLI, so it can't be Empty when user add it as parameter.

Can we design it like "az synapse workspace update --allowed_aad_tenant_ids None", if allowed_aad_tenant_ids list contains "None", will disable all tenant ids.

    if allowed_aad_tenant_ids is not None and "None" in allowed_aad_tenant_ids:
        allowed_aad_tenant_ids = []

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jsntcy , could you please provide some insights on this? What is the general guidelines for users to update a list to none or empty.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you should use another command to clear the list, for example az synapse workspace disable_allowed_aad_tenant_ids to do that.

Copy link
Contributor Author

@sunsw1994 sunsw1994 Jan 21, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Find a similar cmdlet:

nargs='*' instead of nargs='+' , user can pass an empty list

c.argument('key_ops', arg_type=get_enum_type(JsonWebKeyOperation), options_list=['--ops'], nargs='*',

Copy link
Member

@jsntcy jsntcy Jan 25, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Refer to

c.argument('dns_servers', help='Space-separated list of DNS server IP addresses. Use ""(\'""\' in PowerShell) to revert to default Azure servers.', nargs='+', arg_group='DNS')

Use "" to clear.
@sunsw1994

g.custom_command('list', 'list_workspaces')
g.custom_command('create', 'create_workspace', supports_no_wait=True)
g.custom_command('activate', 'activate_workspace', client_factory=cf_synapse_client_cmk_factory, supports_no_wait=True)
g.custom_command('update', 'update_workspace', supports_no_wait=True)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For what purpose that you make it a separate command rather than integrating it into az synapse workspace update?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there must be some reasons that you use different SDK update method. Could you please share more details?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry didn't descript it clearly.
activate_workspace using the SDK defined at Key.json(CreateOrUpdate)

g.custom_command('activate', 'activate_workspace', client_factory=cf_synapse_client_cmk_factory, supports_no_wait=True)

update_workspace using the SDK defined at workspace.json(Update)

That means these two cmdlets will use different client to send request. We can put activate_workspace 's logic into az synapse workspace key update. But I don't think it may be more clear. How do you design at Powershll?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will move it to az synapse workspace key update according to offline discussion.

@idear1203 idear1203 self-requested a review January 21, 2021 08:14
@sunsw1994
Copy link
Contributor Author

hi @jsntcy, please help to merge this PR if that looks good to you. Thanks a lot.

@sunsw1994
Copy link
Contributor Author

Hi @Juliehzl ,please help to merge this PR if that looks good to you. Thanks a lot.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants