Using azure services

Younes 21 Reputation points
2022-12-01T09:04:02.15+00:00

Hi, I am new to azure and networking and am trying to query a DB in a flexible Postgres server from the azure client using "az postgres flexible-server execute". The server is set to private and is inside a subnet.
I get the following feedback from the client :
Connecting to postgres database by default.
Failed connection to myserver. Check error and validate firewall and public access or virtual network settings.
Unable to connect to flexible server: could not translate host name "myserver.postgres.database.azure.com" to address: Name or service not known

How do I enable access to the server to execute the command "az postgres flexible-server execute" from the azure client?
I found some documentation to enable azure services but couldn't find it in the Azure platform.
Appreciate your help thanks.

Azure SQL Database
Azure Virtual Network
Azure Virtual Network
An Azure networking service that is used to provision private networks and optionally to connect to on-premises datacenters.
2,772 questions
0 comments No comments
{count} votes

Accepted answer
  1. SSingh-MSFT 16,371 Reputation points Moderator
    2022-12-01T10:03:06.317+00:00

    Hi @Younes ,

    Welcome to Microsoft Q&A platform and thanks for using Azure services.

    As I understand your question, upon execution of az postgres flexible-server execute, you are getting error to validate firewall and network settings.

    For firewall, you can refer this documentation to create Firewall rule: firewall-rule

    Try to connect to the server using az postgres flexible-server connect -n postgresdemoserver -u dbuser -p "dbpassword" -d postgres

    If the connection failed, try these solutions:

    • Check if port 5432 is open on your client machine.
    • if your server administrator user name and password are correct
    • if you have configured firewall rule for your client machine(as mentioned above)
    • if you've configured your server with private access in virtual networking, make sure your client machine is in the same virtual network.

    Further to Note:

    • The virtual network and subnet should be in the same region and subscription as your flexible server.
    • The virtual network should not have any resource lock set at the VNET or subnet level. Make sure to remove any lock (Delete or Read only) from your VNET and all subnets before creating the server in a virtual network, and you can set it back after server creation.

    Additionally, please go through the below mentioned link for better understanding of Networking in Flexible server:

    how-to-manage-virtual-network-portal
    concepts-networking
    concepts-firewall-rules

    Hope this helps. If this answers your query, do click Accept Answer and Up-Vote for the same. And, if you have any further query do let us know.

    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.