Hi,
I can't quite tell from your post if it's timing out from being unable to reach, or permissions. So I'll detail both ways I would get it working.
There should be a Private DNS for 'privatelink.database.windows.net' of which there is a Virtual network link to your virtual network where the SQL and ACI are located. Is that setup and associated?
Bicep IaC for this is here: https://video2.skills-academy.com/en-us/azure/templates/microsoft.network/privatednszones/virtualnetworklinks?pivots=deployment-language-bicep
For permissions, check you have enabled the system-assigned managed identity on the ACI https://video2.skills-academy.com/en-us/azure/container-instances/container-instances-managed-identity then you can look to add the managed identity of the ACI into the PostgreSQL with the appropriate permissions to write.
SET aad_validate_oids_in_tenant = off; CREATE ROLE myuser WITH LOGIN PASSWORD 'CLIENT_ID' IN ROLE azure_ad_user;
Client_id being the MS Entra Enterprise Application - Application Id guid.
More information here on that setup: https://video2.skills-academy.com/en-us/azure/postgresql/single-server/how-to-connect-with-managed-identity#creating-a-postgresql-user-for-your-managed-identity
Bicep IaC is here: https://video2.skills-academy.com/en-us/azure/templates/microsoft.containerinstance/containergroups?pivots=deployment-language-bicep
You'll want configure this section to enable system-assigned MI on the ACI if it's not already from the code above:
identity: {
type: 'SystemAssigned'
}
With these two setup and verified, things should work for you. If this was helpful, feel free to mark as an accepted answer.