docs/user_guide/connecting/azure-entraid.md
Connecting to a database in Azure using Entra ID is straightforward once you're familiar with Azure's authentication methods. This guide outlines the three most common methods to connect to databases such as MySQL, PostgreSQL, and MS SQL via Entra ID.
We support 3 methods for connecting to databases using EntraID:
If you've used any of these tools you'll likely be familiar with the workflows, nevertheless a walkthrough of each of these methods can be seen below.
We recommend using the Azure CLI authentication whenever possible.
!!! info "MS SQL Server Supported"
Uses your Microsoft EntraID credentials via a browser for a streamlined sign-in experience.
<video controls> <source id="workspaces" type="video/mp4" src="https://assets.beekeeperstudio.io/bks-azure-entra-sso.mp4" /> </video> <small>Video walkthrough</small>!!! warning "Passes through the BKS webserver" Signing in to your database this way does require authentication through the Beekeeper Studio web server which will temporarily store a token for the app to use. No credentials are stored by the webserver.
!!! info "MySQL, PostgreSQL and MS SQL Server Supported" Installation of the Azure CLI is required.
Sign into azure using the Azure CLI, then use your authenticated session to access your database in Azure.
This is the most enterprise-friendly workflow as it does not require the cooperation of the Beekeeper Studio servers, simply a pre-authenticated AZ client with the right permissions.
<video controls> <source id="workspaces" type="video/mp4" src="https://assets.beekeeperstudio.io/bks-azure-entra-cli.mp4" /> </video> <small>Azure CLI authentication walkthrough video</small>To start, make sure you have installed the Azure CLI From Microsoft, and know how to use az login to sign into your Azure account.
If you're part of a large enterprise, they likely have documentation on how to do this.
az login and following the prompts!!! info "MS SQL Server Supported"
Service principals are best suited for automated services or non-interactive applications, but we support them in Beekeeper Studio in case they are your only option.
We recommend using Azure CLI whenever possible.
<video controls> <source id="workspaces" type="video/mp4" src="https://assets.beekeeperstudio.io/bks-azure-entra-principal.mp4" /> </video> <small>Service Principal authentication walkthrough</small>!!! warning Beekeeper Studio will store your client ID and Secret in this authentication workflow.
Cause: This error occurs when the SSO-authenticated user is not mapped to a SQL database user.
Solution:
You need to explicitly create a user in SQL that maps to the Microsoft Entra identity.
š Reference: Login failed for user - Microsoft Q&A
Fix Example (run in SQL):
CREATE USER [<user>@<tenant>.onmicrosoft.com] FROM EXTERNAL PROVIDER;
ALTER ROLE db_datareader ADD MEMBER [<user>@<tenant>.onmicrosoft.com];
ALTER ROLE db_datawriter ADD MEMBER [<user>@<tenant>.onmicrosoft.com];
Ensure the user has necessary permissions within the target database.