I have a bash script that exports ENV vars to use in connecting to an Azure Postgres DB (mydb.postgres.database.azure.com). For the user portion of that specifically it looks like this:
export PGUSER="postgres@mydb"
This works fine to connect to my local DB where the @mydb part isn't required, but it fails when connecting to Azure (where it is required) with:
psql: FATAL: Invalid Username specified. Please check the Username and retry connection. The Username should be in username@hostname format.
I've found lots of solutions/answers to this like this one and this one however those aren't viable solutions when using ENV vars to set connection details (and while I didn't expect it to work I nonetheless tried changing my script to export PGUSER="postgres%40mydb" and indeed it did yield the same error).
Does anyone know how to accomplish this?
@required in the username. There are nopsqloptions on the command line, that's the point of exporting the env vars.FATAL: role "postgres@mydb" does not exist. Have you inspected the env to make sure it is actually set the way you think it is?@mydbpart of that user identifier is not req'd in your environment, it also is not in mine. It is however required with Azure.