@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:
- 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.
- 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
- Connect your Automation Account to Private endpoint using the steps here - Connect to a private endpoint
- 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.