From 4b1005a45879bd9e8d7638703fb3bc17d7b83d3f Mon Sep 17 00:00:00 2001 From: Naia Scott Date: Wed, 1 Nov 2023 20:27:50 -0400 Subject: [PATCH] init --- .../azure/cli/command_modules/rdbms/_helptext_pg.py | 4 ++++ .../command_modules/rdbms/flexible_server_custom_common.py | 7 +++++++ 2 files changed, 11 insertions(+) diff --git a/src/azure-cli/azure/cli/command_modules/rdbms/_helptext_pg.py b/src/azure-cli/azure/cli/command_modules/rdbms/_helptext_pg.py index e0383bf006a..b26fd083b87 100644 --- a/src/azure-cli/azure/cli/command_modules/rdbms/_helptext_pg.py +++ b/src/azure-cli/azure/cli/command_modules/rdbms/_helptext_pg.py @@ -377,6 +377,10 @@ Create a firewall rule allowing connections to all Azure services text: > az postgres flexible-server firewall-rule create --resource-group testGroup --name testserver --rule-name allowazureservices --start-ip-address 0.0.0.0 + - name: > + Create a firewall rule allowing connections to all IP addresses. This may be insecure. + text: > + az postgres flexible-server firewall-rule create --resource-group testGroup --name testserver --rule-name allowall --start-ip-address 0.0.0.0 """ helps['postgres flexible-server firewall-rule list'] = """ diff --git a/src/azure-cli/azure/cli/command_modules/rdbms/flexible_server_custom_common.py b/src/azure-cli/azure/cli/command_modules/rdbms/flexible_server_custom_common.py index a3b0e325866..243238572cf 100644 --- a/src/azure-cli/azure/cli/command_modules/rdbms/flexible_server_custom_common.py +++ b/src/azure-cli/azure/cli/command_modules/rdbms/flexible_server_custom_common.py @@ -88,6 +88,13 @@ def firewall_rule_create_func(cmd, client, resource_group_name, server_name, fir logger.warning('Configuring server firewall rule to accept connections from \'%s\' to \'%s\'...', start_ip_address, end_ip_address) + if firewall_rule_name == 'allowall': + start_ip_address = '0.0.0.0' + end_ip_address = '255.255.255.255' + now = datetime.now() + firewall_rule_name = 'AllowAll_{}-{}-{}_{}-{}-{}'.format(now.year, now.month, now.day, now.hour, now.minute, now.second) + logger.warning('Configuring server firewall rule to accept connections from \'%s\' to \'%s\'...', start_ip_address, end_ip_address) + parameters = { 'name': firewall_rule_name, 'start_ip_address': start_ip_address,