Skip to content

[rdbms] az postgresql flexible-server create: Handle failed IP address check#31834

Merged
evelyn-ys merged 2 commits intoAzure:devfrom
cclark-work:chrisclark_ip_address_check_fail
Jul 28, 2025
Merged

[rdbms] az postgresql flexible-server create: Handle failed IP address check#31834
evelyn-ys merged 2 commits intoAzure:devfrom
cclark-work:chrisclark_ip_address_check_fail

Conversation

@cclark-work
Copy link
Copy Markdown
Contributor

@cclark-work cclark-work commented Jul 17, 2025

Related command
az postgresql flexible-server create

Description
If the IP address check to ipify.org fails, the server creation command fails with no explanation of how to resolve it. This will fail 100% of the time in USSec and USNat if the server is not VNet, the user does not provide an IP address or IP range, or the user does not specify that public access is disabled.

Testing Guide

History Notes


This checklist is used to make sure that common guidelines for a pull request are followed.

Copilot AI review requested due to automatic review settings July 17, 2025 14:17
@azure-client-tools-bot-prd
Copy link
Copy Markdown

azure-client-tools-bot-prd bot commented Jul 17, 2025

️✔️AzureCLI-FullTest
️✔️acr
️✔️latest
️✔️3.12
️✔️3.9
️✔️acs
️✔️latest
️✔️3.12
️✔️3.9
️✔️advisor
️✔️latest
️✔️3.12
️✔️3.9
️✔️ams
️✔️latest
️✔️3.12
️✔️3.9
️✔️apim
️✔️latest
️✔️3.12
️✔️3.9
️✔️appconfig
️✔️latest
️✔️3.12
️✔️3.9
️✔️appservice
️✔️latest
️✔️3.12
️✔️3.9
️✔️aro
️✔️latest
️✔️3.12
️✔️3.9
️✔️backup
️✔️latest
️✔️3.12
️✔️3.9
️✔️batch
️✔️latest
️✔️3.12
️✔️3.9
️✔️batchai
️✔️latest
️✔️3.12
️✔️3.9
️✔️billing
️✔️latest
️✔️3.12
️✔️3.9
️✔️botservice
️✔️latest
️✔️3.12
️✔️3.9
️✔️cdn
️✔️latest
️✔️3.12
️✔️3.9
️✔️cloud
️✔️latest
️✔️3.12
️✔️3.9
️✔️cognitiveservices
️✔️latest
️✔️3.12
️✔️3.9
️✔️compute_recommender
️✔️latest
️✔️3.12
️✔️3.9
️✔️computefleet
️✔️latest
️✔️3.12
️✔️3.9
️✔️config
️✔️latest
️✔️3.12
️✔️3.9
️✔️configure
️✔️latest
️✔️3.12
️✔️3.9
️✔️consumption
️✔️latest
️✔️3.12
️✔️3.9
️✔️container
️✔️latest
️✔️3.12
️✔️3.9
️✔️containerapp
️✔️latest
️✔️3.12
️✔️3.9
️✔️core
️✔️latest
️✔️3.12
️✔️3.9
️✔️cosmosdb
️✔️latest
️✔️3.12
️✔️3.9
️✔️databoxedge
️✔️latest
️✔️3.12
️✔️3.9
️✔️dls
️✔️latest
️✔️3.12
️✔️3.9
️✔️dms
️✔️latest
️✔️3.12
️✔️3.9
️✔️eventgrid
️✔️latest
️✔️3.12
️✔️3.9
️✔️eventhubs
️✔️latest
️✔️3.12
️✔️3.9
️✔️feedback
️✔️latest
️✔️3.12
️✔️3.9
️✔️find
️✔️latest
️✔️3.12
️✔️3.9
️✔️hdinsight
️✔️latest
️✔️3.12
️✔️3.9
️✔️identity
️✔️latest
️✔️3.12
️✔️3.9
️✔️iot
️✔️latest
️✔️3.12
️✔️3.9
️✔️keyvault
️✔️latest
️✔️3.12
️✔️3.9
️✔️lab
️✔️latest
️✔️3.12
️✔️3.9
️✔️managedservices
️✔️latest
️✔️3.12
️✔️3.9
️✔️maps
️✔️latest
️✔️3.12
️✔️3.9
️✔️marketplaceordering
️✔️latest
️✔️3.12
️✔️3.9
️✔️monitor
️✔️latest
️✔️3.12
️✔️3.9
️✔️mysql
️✔️latest
️✔️3.12
️✔️3.9
️✔️netappfiles
️✔️latest
️✔️3.12
️✔️3.9
️✔️network
️✔️latest
️✔️3.12
️✔️3.9
️✔️policyinsights
️✔️latest
️✔️3.12
️✔️3.9
️✔️privatedns
️✔️latest
️✔️3.12
️✔️3.9
️✔️profile
️✔️latest
️✔️3.12
️✔️3.9
️✔️rdbms
️✔️latest
️✔️3.12
️✔️3.9
️✔️redis
️✔️latest
️✔️3.12
️✔️3.9
️✔️relay
️✔️latest
️✔️3.12
️✔️3.9
️✔️resource
️✔️latest
️✔️3.12
️✔️3.9
️✔️role
️✔️latest
️✔️3.12
️✔️3.9
️✔️search
️✔️latest
️✔️3.12
️✔️3.9
️✔️security
️✔️latest
️✔️3.12
️✔️3.9
️✔️servicebus
️✔️latest
️✔️3.12
️✔️3.9
️✔️serviceconnector
️✔️latest
️✔️3.12
️✔️3.9
️✔️servicefabric
️✔️latest
️✔️3.12
️✔️3.9
️✔️signalr
️✔️latest
️✔️3.12
️✔️3.9
️✔️sql
️✔️latest
️✔️3.12
️✔️3.9
️✔️sqlvm
️✔️latest
️✔️3.12
️✔️3.9
️✔️storage
️✔️latest
️✔️3.12
️✔️3.9
️✔️synapse
️✔️latest
️✔️3.12
️✔️3.9
️✔️telemetry
️✔️latest
️✔️3.12
️✔️3.9
️✔️util
️✔️latest
️✔️3.12
️✔️3.9
️✔️vm
️✔️latest
️✔️3.12
️✔️3.9

@azure-client-tools-bot-prd
Copy link
Copy Markdown

azure-client-tools-bot-prd bot commented Jul 17, 2025

️✔️AzureCLI-BreakingChangeTest
️✔️Non Breaking Changes

@yonzhan
Copy link
Copy Markdown
Collaborator

yonzhan commented Jul 17, 2025

Thank you for your contribution! We will review the pull request and get back to you soon.

@github-actions
Copy link
Copy Markdown

The git hooks are available for azure-cli and azure-cli-extensions repos. They could help you run required checks before creating the PR.

Please sync the latest code with latest dev branch (for azure-cli) or main branch (for azure-cli-extensions).
After that please run the following commands to enable git hooks:

pip install azdev --upgrade
azdev setup -c <your azure-cli repo path> -r <your azure-cli-extensions repo path>

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds error handling around the external IP lookup and provides a clearer error message when the lookup fails in restricted environments.

  • Wrapped the get(IP_ADDRESS_CHECKER).text call in a try/except and raise a CLIError with guidance.
  • Added an inline explanatory comment for environments without public Internet access (USSec/USNat).
Comments suppressed due to low confidence (1)

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

  • Consider adding a unit test that simulates a failure of the IP address checker to verify that this CLIError is raised with the expected message.
            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))

try:
'''
In USSec and USNat, the IP address checker is not available as the public Internet is not accessible.
When the user does not provide a public IP address or does not disble public access,
Copy link

Copilot AI Jul 17, 2025

Choose a reason for hiding this comment

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

There is a typo in the comment: "disble" should be spelled "disable".

Suggested change
When the user does not provide a public IP address or does not disble public access,
When the user does not provide a public IP address or does not disable public access,

Copilot uses AI. Check for mistakes.
Comment on lines +458 to +463
'''
In USSec and USNat, the IP address checker is not available as the public Internet is not accessible.
When the user does not provide a public IP address or does not disble public access,
the `az cli postgres flexible-server create` command will fail with the error
HTTPSConnectionPool(host='api.ipify.org', port443): Max retries excceeded with url
'''
Copy link

Copilot AI Jul 17, 2025

Choose a reason for hiding this comment

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

Using a triple-quoted string as an inline comment can be confusing and is executed as a no-op literal. Consider replacing this with # comments for clarity.

Suggested change
'''
In USSec and USNat, the IP address checker is not available as the public Internet is not accessible.
When the user does not provide a public IP address or does not disble public access,
the `az cli postgres flexible-server create` command will fail with the error
HTTPSConnectionPool(host='api.ipify.org', port443): Max retries excceeded with url
'''
# In USSec and USNat, the IP address checker is not available as the public Internet is not accessible.
# When the user does not provide a public IP address or does not disable public access,
# the `az cli postgres flexible-server create` command will fail with the error:
# HTTPSConnectionPool(host='api.ipify.org', port=443): Max retries exceeded with URL.

Copilot uses AI. Check for mistakes.
@evelyn-ys
Copy link
Copy Markdown
Member

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 3 pipeline(s).

@evelyn-ys evelyn-ys changed the title [postgresql] Adding try/except block to handle failed IP Addr check and comments [rdbms] az postgresql flexible-server create: Handle failed IP address check Jul 28, 2025
@evelyn-ys evelyn-ys merged commit 27dcc3c into Azure:dev Jul 28, 2025
48 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants