Using Active Directory Service Principal authentication to connect to Azure SQL
This article describes how to authorize a .NET application to connect to an Azure SQL Server through Azure Active Directory. Why You don't want to connect to a database with your personal account details. You want to be able to control the login over time, expiring access as needed. Register your application Presuming you have an Azure SQL Server and a Database you'd like to connect to, you'll need to register your application in Azure AD. This is done through the App Registrations blade : You won't need to register a Redirect URL for this example. At this point, it will be prudent to write down the following properties for later use: Application (client) ID (called AppId in the accompanying code) Directory (tenant) ID (called TenantId in the accompanying code) Grant access to Azure SQL Database Next up, we need to give your application access to the Azure SQL Database service . This is done through the API Permissions blade: Add client authentication In order for yo