Skip to content

Commit 27dcc3c

Browse files
authored
[rdbms] az postgresql flexible-server create: Handle failed IP address check (#31834)
1 parent b71e202 commit 27dcc3c

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

src/azure-cli/azure/cli/command_modules/rdbms/flexible_server_virtual_network.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,15 @@ def prepare_private_dns_zone(db_context, resource_group, server_name, private_dn
454454

455455
def prepare_public_network(public_access, yes):
456456
if public_access is None:
457-
ip_address = get(IP_ADDRESS_CHECKER).text
457+
try:
458+
# In USSec and USNat, the IP address checker is not available as the public Internet is not accessible.
459+
# When the user does not provide a public IP address or does not disble public access,
460+
# the `az cli postgres flexible-server create` command will fail with the error
461+
# HTTPSConnectionPool(host='api.ipify.org', port443): Max retries excceeded with url
462+
ip_address = get(IP_ADDRESS_CHECKER).text
463+
except Exception as ex:
464+
raise CLIError("Unable to detect your current IP address. Please provide a valid IP address or CIDR range for --public-access parameter or set --public-access Disabled. Error: {}".format(ex))
465+
458466
logger.warning("Detected current client IP : %s", ip_address)
459467
if yes:
460468
return ip_address, ip_address

0 commit comments

Comments
 (0)