Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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
16 changes: 16 additions & 0 deletions src/azure-cli/azure/cli/command_modules/sql/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -1039,6 +1039,14 @@ def _configure_security_policy_storage_params(arg_ctx):
help='Generate and assign an Azure Active Directory Identity for this server'
'for use with key management services like Azure KeyVault.')

c.argument('public_network_access',
options_list=['--public-network-access', '-a'],
arg_type=get_three_state_flag(positive_label='Enabled',
negative_label='Disabled',
return_label=True),
help='Sets whether public network access to server is allowed or not. When disabled,'
'only connections made through Private Links can reach this server.')

with self.argument_context('sql server create') as c:
c.argument('location',
arg_type=get_location_type_with_default_from_resource_group(self.cli_ctx))
Expand All @@ -1062,6 +1070,14 @@ def _configure_security_policy_storage_params(arg_ctx):
help='Generate and assign an Azure Active Directory Identity for this server'
'for use with key management services like Azure KeyVault.')

c.argument('public_network_access',
options_list=['--public-network-access', '-a'],
Copy link
Contributor

@Juliehzl Juliehzl Mar 2, 2020

Choose a reason for hiding this comment

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

What about using something like --enable-public-network for the argument?

I have two questions here:

  1. What is the default network access policy for sql server? public or private?
  2. If using private link, should users create private endpoint connection by themselves?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do you mean a flag? So --enable-public-network means Enabled while no flag means disabled? If so, two things about this, first off powershell uses PublicNetworkAcces and takes in a string Enabled/Disabled. I wanted to keep it consistent between the two. Also, we would want a third option, None, where no change to PublicNetworkAccess occurs and if we use a flag, we wouldn't be able to have that.

In response to the other questions:

  1. Default is Public (aka PublicNetworkAccess == Enabled)
  2. Yes, user has to create private endpoint connection by themselves

arg_type=get_three_state_flag(positive_label='Enabled',
negative_label='Disabled',
return_label=True),
help='Sets whether public network access to server is allowed or not. When disabled,'
'only connections made through Private Links can reach this server.')

with self.argument_context('sql server update') as c:
c.argument('administrator_login_password',
help='The administrator login password.')
Expand Down
10 changes: 9 additions & 1 deletion src/azure-cli/azure/cli/command_modules/sql/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -1909,6 +1909,7 @@ def server_create(
server_name,
assign_identity=False,
no_wait=False,
public_network_access=None,
**kwargs):
'''
Creates a server.
Expand All @@ -1917,6 +1918,9 @@ def server_create(
if assign_identity:
kwargs['identity'] = ResourceIdentity(type=IdentityType.system_assigned.value)

if public_network_access is not None:
kwargs['public_network_access'] = public_network_access

# Create
return sdk_no_wait(no_wait, client.create_or_update,
server_name=server_name,
Expand All @@ -1942,7 +1946,8 @@ def server_list(
def server_update(
instance,
administrator_login_password=None,
assign_identity=False):
assign_identity=False,
public_network_access=None):
'''
Updates a server. Custom update function to apply parameters to instance.
'''
Expand All @@ -1955,6 +1960,9 @@ def server_update(
instance.administrator_login_password = (
administrator_login_password or instance.administrator_login_password)

if public_network_access is not None:
instance.public_network_access = public_network_access

return instance


Expand Down
Loading