Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
6 changes: 2 additions & 4 deletions src/azure-cli/azure/cli/command_modules/sql/_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -672,10 +672,6 @@
helps['sql server ad-admin update'] = """
type: command
short-summary: Update an existing server Active Directory administrator.
examples:
- name: Update an existing server Active Directory administrator. (autogenerated)
text: az sql server ad-admin update --display-name MyDisplay --resource-group MyResourceGroup --server-name MyServer
crafted: true
"""

helps['sql server conn-policy'] = """
Expand Down Expand Up @@ -707,6 +703,8 @@
examples:
- name: Create a server.
text: az sql server create -l westus -g mygroup -n myserver -u myadminuser -p myadminpassword
- name: Create a server with disabled public network access to server.
text: az sql server create -l westus -g mygroup -n myserver -u myadminuser -p myadminpassword -e false
"""

helps['sql server dns-alias'] = """
Expand Down
7 changes: 7 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,13 @@ 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('enable_public_network',
Copy link
Contributor

Choose a reason for hiding this comment

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

  1. Please add help.py example showing how to specify false.
  2. Check with other RP's that their argument definition is the same, e.g. help text and -e shortcut
  3. Mark the param as preview?

options_list=['--enable-public-network', '-e'],
arg_type=get_three_state_flag(),
help='Set whether public network access to server is allowed or not. When false,'
'only connections made through Private Links can reach this server.',
is_preview=True)

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 Down
17 changes: 15 additions & 2 deletions src/azure-cli/azure/cli/command_modules/sql/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@
ManagedInstancePairInfo,
PartnerRegionInfo,
InstanceFailoverGroupReadOnlyEndpoint,
InstanceFailoverGroupReadWriteEndpoint
InstanceFailoverGroupReadWriteEndpoint,
ServerPublicNetworkAccess
)

from knack.log import get_logger
Expand Down Expand Up @@ -1974,6 +1975,7 @@ def server_create(
server_name,
assign_identity=False,
no_wait=False,
enable_public_network=None,
**kwargs):
'''
Creates a server.
Expand All @@ -1982,6 +1984,11 @@ def server_create(
if assign_identity:
kwargs['identity'] = ResourceIdentity(type=IdentityType.system_assigned.value)

if enable_public_network is not None:
kwargs['public_network_access'] = (
ServerPublicNetworkAccess.enabled if enable_public_network
else ServerPublicNetworkAccess.disabled)

# Create
return sdk_no_wait(no_wait, client.create_or_update,
server_name=server_name,
Expand All @@ -2007,7 +2014,8 @@ def server_list(
def server_update(
instance,
administrator_login_password=None,
assign_identity=False):
assign_identity=False,
enable_public_network=None):
'''
Updates a server. Custom update function to apply parameters to instance.
'''
Expand All @@ -2020,6 +2028,11 @@ def server_update(
instance.administrator_login_password = (
administrator_login_password or instance.administrator_login_password)

if enable_public_network is not None:
instance.public_network_access = (
ServerPublicNetworkAccess.enabled if enable_public_network
else ServerPublicNetworkAccess.disabled)

return instance


Expand Down

Large diffs are not rendered by default.

Loading