Binding Azure Function to Postgres running in a Docker (local)

Daniele Mellino (IT) 41 Reputation points
2022-05-17T09:30:57.3+00:00

Hi, I'm pretty new with Azure functions and bindings.
For my project I need to run an azure function when a new action is made on a postgres database.
The database is running on a docker container as well as my future functions (so I'm not using an azure database).
I though about binding the function with the postgres db. However I understood that this could not be supported from here. Therefore my questions are :

Is it true? Can I bind an azure function with a postgres db on a docker?

Do you know about some helpful references where I can look at ?

Which is the right way to tackle it ?

Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
4,321 questions
.NET
.NET
Microsoft Technologies based on the .NET software framework.
3,415 questions
Azure Database for PostgreSQL
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Bruno Lucas 4,411 Reputation points MVP
    2022-05-17T10:57:10.397+00:00

    Hi @Daniele Mellino (IT) ,

    Ideally to get "when something happens in Postgres" you would need a azure function trigger with a Postgres binding. Unfortunately that is not available.
    202776-image.png

    You can try an azure function time trigger to query postgress every x seconds.
    https://learn.microsoft.com/en-us/azure/azure-functions/functions-bindings-timer?tabs=in-process&pivots=programming-language-csharp#ncrontab-expressions

    Problem is getting hold of the connection string. you said it is on a docker image. the next will depend of where the docker is hosted. Is that on Azure VM? On-prem?