Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
I'm trying to create a custom PostgreSQL connector that used Microsoft Entra Id as the authentication method with the Power query SDK.
As a test I'm trying to just recreate the PostgreSQL connector that is already in Power-bi with UsernamePassword authentication.
Should be pretty straight forward but I'm stuck.
This is my .pq file
// Main function to connect to the PostgreSQL server
[DataSource.Kind="PostgreSQLConnector", Publish="PostgreSQLConnector.Publish"]
shared PostgreSQLConnector.Contents = (server as text, database as text) =>
let
// Connect to PostgreSQL without hardcoding credentials
result = PostgreSQL.Database(server, database)
in
result;
// Publish metadata
PostgreSQLConnector.Publish = [
Beta = true,
Category = "Database",
ButtonText = { Extension.LoadString("DataSourceButtonText"), Extension.LoadString("DataSourceButtonHelp") },
SourceImage = PostgreSQLConnector.Icons,
SourceTypeImage = PostgreSQLConnector.Icons,
SupportsDirectQuery = true
];
// Data source definition and authentication
PostgreSQLConnector = [
Authentication = [
UsernamePassword = []
],
Label = Extension.LoadString("DataSourceLabel")
];
But I'm getting the error that I need to specify how to connect.
And in visual studio code I get this error, that the credentials are missing even if I already set them.
I try to do this with Odbc.DataSource in stead of PostgreSQL.Database and this works but I don't want the need to install a PostgreSQL driver locally.
Hi @Anonymous,
At the moment I'm not even trying to implement the Aad. I'm just trying to recreate a postgreSQl connector with UsernamePassword authentication and try to connect as a test.
I'm using this 'PostgreSQl.Database' function but I'm getting the error specify how to connect.
Kind regards,
Antony
Hi @AntonyKlipper ,
Here are a few things you can try to check:
Authentication Definition: Ensure that the Authentication section is correctly defined and that the credentials are being passed properly.
Connection String: Verify that the connection string is correctly formatted and includes all necessary parameters.
Error Handling: Add error handling to capture and display any issues that occur during the connection process.
Also, you can check the steps to Implement Microsoft Entra ID Authentication:
Register Your Application:
Configure OAuth:
Update Connector Definition:
Example:
MyConnector = [
Authentication = [
Aad = [
AuthorizationUri = "https://login.microsoftonline.com/common/oauth2/authorize",
Resource = "{YourApplicationIdUri}"
Scope = ".default"
]
]
];
Configuring Microsoft Entra for a custom connector - Power Query | Microsoft Learn
Best Regards,
Stephen Tao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!
| User | Count |
|---|---|
| 19 | |
| 9 | |
| 8 | |
| 7 | |
| 6 |