Hi I am new to Azure and I got a requirement to deploy Postgres DB to Azure Container app. I know its not a good practice to host a DB inside a containerize environment.
I followed this link from the Microsoft documentation to deploy the app and following are my configurations,
I created a VNET since I need to select TCP as the Ingress type and mapped the target port and and exposed port port as 5432 to 5432
After I deploy the application and try to connect to the DB using Pgadmin I am getting the following error.
I want to make sure the Postgres DB running successfully inside the Azure Container App and need to connect from Pgadmin.
There are 2 problems here:
Regarding the first problem, the "Command override" is for overriding the command running in your docker image, not the docker command itself.
So those values will need to be put in the environment variables section below:
like:
or using the azure cli
az containerapp create \
--name $POSTGRES_INSTANCE_NAME \
--resource-group $RESOURCE_GROUP \
--environment $CONTAINERAPPS_ENVIRONMENT \
--image docker.io/postgres:15 \
--secrets pgpass="$POSTGRES_PASSWORD" \
--env-vars POSTGRES_USER="$POSTGRES_USER" POSTGRES_DB="$POSTGRES_DB" POSTGRES_PASSWORD=secretref:pgpass \
--transport tcp \
--target-port 5432 \
--ingress external \
--min-replicas 1 \
--max-replicas 1
you could change --ingress external
to --ingress internal
then deploy pgadmin on the same environment. Then pgadmin should be able to reach postgres on $POSTGRES_INSTANCE_NAME:5432
to deploy pgadmin
az containerapp create \
--name pgadmin \
--resource-group $RESOURCE_GROUP \
--environment $CONTAINERAPPS_ENVIRONMENT \
--image dpage/pgadmin4:6.15 \
--secrets pgpass="$PGADMIN_PASSWORD" \
--env-vars PGADMIN_DEFAULT_EMAIL="$PGADMIN_EMAIL" PGADMIN_LISTEN_PORT="8080" PGADMIN_DEFAULT_PASSWORD=secretref:pgpass \
--transport http \
--target-port 8080 \
--ingress external \
--min-replicas 1 \
--max-replicas 1