Connect from python Function app with managed identity to Azure Database for PostgreSQL- Flexible Server

Sivanesan 20 Reputation points
2024-04-22T12:46:59.7566667+00:00

Hi Everyone

I have a python function app which is connecting to PostgreSQL- Flexible Server. I have used password authentication to connect the server. Now, I have to use managed identity to connect the server. I came across 2 different and not sure which one to follow completely for this scenario.

https://learn.microsoft.com/en-us/azure/postgresql/flexible-server/how-to-connect-with-managed-identity

I was able to connect from VM's system-assigned managed identity and use it to call Azure Database for PostgreSQL flexible server using the above document. I am not sure how to achieve this using a function app. I have found below article to connect from function but its for PostgreSQL – Single Server. Can anyone guide me how to proceed further.

https://techcommunity.microsoft.com/t5/azure-database-for-postgresql/connect-from-function-app-with-managed-identity-to-azure/ba-p/1517032

Regards

Sivanesan

Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
Azure Database for PostgreSQL
Microsoft Security | Microsoft Entra | Microsoft Entra ID
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Ryan Hill 30,326 Reputation points Microsoft Employee Moderator
    2024-04-22T20:46:22.2866667+00:00

    Hi @Sivanesan

    Same principals apply. Refer to Managed identities - Azure App Service | Microsoft Learn to create the identity for your function app. Then use the application id of the function app for the <identity-name> in the steps outlined under Create an Azure Database for PostgreSQL flexible server user for your Managed Identity.


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.