Skip to content

Commit cb73c6b

Browse files
committed
{Synapse} az synapse workspace update: Add support for public-network-access
This adds support for enabling/disabling public network access to the synapse workspace Signed-off-by: Frank Villaro-Dixon <frank.villarodixon@merkle.com>
1 parent 2f4f0ed commit cb73c6b

File tree

3 files changed

+48
-3
lines changed

3 files changed

+48
-3
lines changed

src/azure-cli/azure/cli/command_modules/synapse/manual/_params.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ def load_arguments(self, _):
105105
c.argument('user_assigned_identity_id', options_list=['--uami-id'], nargs='+', help='The list of User-assigned Managed Identity Id for workspace.')
106106
c.argument('user_assigned_identity_in_encryption', options_list=['--uami-id-in-encrypt'], help='User assigned identity resource Id used in Workspace Encryption')
107107
c.argument('use_system_assigned_identity_in_encryption', options_list=['--use-sami-in-encrypt'], help='Whether use System assigned identity in Workspace Encryption. If use uami, please set True.If not, set False')
108+
c.argument('public_network_access', arg_type=get_three_state_flag(), help="Whether to enable public network access to the workspace.")
108109

109110
with self.argument_context('synapse workspace create') as c:
110111
c.argument('location', get_location_type(self.cli_ctx), validator=get_default_location_from_resource_group)

src/azure-cli/azure/cli/command_modules/synapse/manual/operations/workspace.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from azure.mgmt.synapse.models import Workspace, WorkspacePatchInfo, ManagedIdentity, \
88
DataLakeStorageAccountDetails, WorkspaceKeyDetails, CustomerManagedKeyDetails, EncryptionDetails, ManagedVirtualNetworkSettings, \
99
ManagedIdentitySqlControlSettingsModelPropertiesGrantSqlControlToManagedIdentity, IpFirewallRuleInfo, Key, ManagedIdentitySqlControlSettingsModel, WorkspaceRepositoryConfiguration, \
10-
KekIdentityProperties, UserAssignedManagedIdentity
10+
KekIdentityProperties, UserAssignedManagedIdentity, WorkspacePublicNetworkAccess
1111
from azure.mgmt.cdn.models import CheckNameAvailabilityInput
1212

1313

@@ -102,7 +102,7 @@ def update_workspace(cmd, client, resource_group_name, workspace_name, sql_admin
102102
allowed_aad_tenant_ids=None, tags=None, key_name=None, repository_type=None, host_name=None, account_name=None,
103103
collaboration_branch=None, repository_name=None, root_folder=None, project_name=None, last_commit_id=None, tenant_id=None,
104104
user_assigned_identity_id=None, user_assigned_identity_action=None, user_assigned_identity_in_encryption=None,
105-
use_system_assigned_identity_in_encryption=None, no_wait=False):
105+
use_system_assigned_identity_in_encryption=None, public_network_access=None, no_wait=False):
106106
encryption = None
107107
identity = None
108108
tenant_ids_list = None
@@ -192,8 +192,14 @@ def update_workspace(cmd, client, resource_group_name, workspace_name, sql_admin
192192
last_commit_id=last_commit_id,
193193
tenant_id=tenant_id)
194194

195+
if public_network_access is not None:
196+
if public_network_access:
197+
public_network_access = WorkspacePublicNetworkAccess.ENABLED
198+
else:
199+
public_network_access = WorkspacePublicNetworkAccess.DISABLED
200+
195201
updated_vnet_settings = ManagedVirtualNetworkSettings(allowed_aad_tenant_ids_for_linking=tenant_ids_list) if allowed_aad_tenant_ids is not None else None
196-
workspace_patch_info = WorkspacePatchInfo(tags=tags, sql_administrator_login_password=sql_admin_login_password, encryption=encryption, managed_virtual_network_settings=updated_vnet_settings, workspace_repository_configuration=workspace_repository_configuration, identity=identity)
202+
workspace_patch_info = WorkspacePatchInfo(tags=tags, sql_administrator_login_password=sql_admin_login_password, encryption=encryption, managed_virtual_network_settings=updated_vnet_settings, workspace_repository_configuration=workspace_repository_configuration, identity=identity, public_network_access=public_network_access)
197203
return sdk_no_wait(no_wait, client.begin_update, resource_group_name, workspace_name, workspace_patch_info)
198204

199205

src/azure-cli/azure/cli/command_modules/synapse/tests/latest/test_synapse_scenario.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3177,3 +3177,41 @@ def test_user_assigned_identity_id_workspace(self):
31773177
self.not_exists('identity.userAssignedIdentities[1]')
31783178
])
31793179

3180+
@ResourceGroupPreparer(name_prefix='synapse-cli', random_name_length=16)
3181+
@StorageAccountPreparer(name_prefix='adlsgen2', length=16, location=location, key='storage-account')
3182+
def test_workspace_update_network_access(self, resource_group, storage_account):
3183+
# create a workspace
3184+
self._create_workspace()
3185+
3186+
# check workspace name
3187+
self.cmd('az synapse workspace check-name --name {workspace}', checks=[
3188+
self.check('available', False)
3189+
])
3190+
3191+
# get workspace with workspace name
3192+
workspace = self.cmd('az synapse workspace show --name {workspace} --resource-group {rg}', checks=[
3193+
self.check('publicNetworkAccess', True)
3194+
]).get_output_in_json()
3195+
self.kwargs["workspace-id"] = workspace['id']
3196+
3197+
# Disable public network access
3198+
self.cmd('az synapse workspace update --ids {workspace-id} --public_network_access=False', checks=[
3199+
self.check('publicNetworkAccess', False)
3200+
])
3201+
3202+
# update tags; shouldn't change network access
3203+
self.cmd('az synapse workspace update --ids {workspace-id} --tags key1=value1', checks=[
3204+
self.check('tags.key1', 'value1'),
3205+
self.check('publicNetworkAccess', False)
3206+
])
3207+
3208+
# Enable public network access
3209+
self.cmd('az synapse workspace update --ids {workspace-id} --public_network_access=True', checks=[
3210+
self.check('publicNetworkAccess', True)
3211+
])
3212+
3213+
# update tags; shouldn't change network access
3214+
self.cmd('az synapse workspace update --ids {workspace-id} --tags key1=value2', checks=[
3215+
self.check('tags.key1', 'value1'),
3216+
self.check('publicNetworkAccess', True)
3217+
])

0 commit comments

Comments
 (0)