How i can access a PostgreSQL server DB in a VNet in Azure thorugh python runbook inside an Automation Account ?

Koushik Purva Mahendra 50 Reputation points
2024-05-03T13:04:21.4433333+00:00

Hello team,

I have a problem statement, i have an automation account in azure in which i have a python runbook in that runbook i have a script to make a connection to postgreSQL DB server and do some transactions in the DB but the problem is now i have to put that DB server inside a Vnet and have to do VNet integration and i am not able to find any option in automation account to do Vnet integration of that, so can you please help me out with this and tell me the exact steps to achieve this.

Thank you.

Azure Automation
Azure Automation
An Azure service that is used to automate, configure, and install updates across hybrid environments.
1,256 questions
Azure Database for PostgreSQL
{count} votes

Accepted answer
  1. AnuragSingh-MSFT 21,386 Reputation points
    2024-05-06T08:29:40.5833333+00:00

    @Koushik Purva Mahendra, thank you for posting this question on Microsoft Q&A.

    Based on my understanding you are limiting the public access to the PostgreSQL Db and trying to use Private Link. In such case, the Azure Private Link for Azure Automation can be used to connect to this DB. The following are the steps:

    1. In the current implementation of Private Link, Automation account cloud jobs (which run on sandbox) cannot access Azure resources that are secured using private endpoint.
    2. Therefore, Hybrid Worker will have to be configured to ensure that the Azure Automation Jobs (in this case the execution of Python Script) happens on a Hybrid Worker VM which is connected to the same VNet. To do that, create a VM in the VNET in which the PostgreSQL DB will be connected to. The prerequisite for this VM and the steps to make it a hybrid automation worker is available here - Deploy an extension-based Windows or Linux User Hybrid Runbook Worker in Azure Automation
    3. Connect your Automation Account to Private endpoint using the steps here - Connect to a private endpoint
    4. Ensure that the private DNS zone or one of the options specified in the article below are followed for name resolution of PostgreSQL. In short, ensure that you can connect to the DB from the VM created as hybrid worker - there is no further change required on Automation Account settings. For details, see DNS configuration

    Hope this helps.

    If the answer did not help, please add more context/follow-up question for it.

    1 person found this answer helpful.
    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.