# Azure SQL Server Configuration Prerequisites

Before the Azure SQL Server Provider can be configured and used for Azure Active Directory (AAD) methods, there are certain prerequisites that must be followed.

### Azure Active Directory User

1. Create a new user or use an existing user in Azure Active Directory.

{% hint style="info" %}
**Note:** Note down the *Principal Name* and *password* as it will be used later.
{% endhint %}

![](https://3083465318-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsR50Wa7EwZGlmPSAMkkf%2Fuploads%2FtmIT03swgCahwK6KcMzV%2F01-Priniple.PNG?alt=media\&token=89cd6be6-bcb3-46fb-812c-a02d35663907)

### Creating a Service Principal

1. Create a service principal from the Azure Portal by navigating to Azure Active Directory and selecting *App Registrations*. Then, select *New Registration.*

![](https://3083465318-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsR50Wa7EwZGlmPSAMkkf%2Fuploads%2FLxs7Gm7jlFLlJBGWCD7O%2F02-App-Regis.PNG?alt=media\&token=c727b6c4-db17-49ef-a7ed-e871b1efb1b5)

2. Provide the name of the new application and select *Accounts in this organizational directory only*

{% hint style="info" %}
**Note:** For *Redirect URI*, select *Public client/native (mobile & desktop)* or *Web* and provide [*http://localhost:8050/*](http://localhost:8050/).
{% endhint %}

Click *Register*.

![](https://3083465318-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsR50Wa7EwZGlmPSAMkkf%2Fuploads%2FeJnybl9pHDVW6t9k2ChE%2F03-Register.PNG?alt=media\&token=3d67f922-b7d0-45eb-a35d-81222498b8e5)

3. Write down the *Application (client) ID* for later use.

![](https://3083465318-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsR50Wa7EwZGlmPSAMkkf%2Fuploads%2FHG3olNMZ2VZDbAZZnj6y%2F04-Name.PNG?alt=media\&token=e57c156e-3b6e-4690-b830-05e77064c687)

4. Add new permissions for Azure SQL Database by navigating to the *API permissions* and clicking *Add a permission*.

Select *APIs my organization uses* and search for *Azure SQL Database.*

![](https://3083465318-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsR50Wa7EwZGlmPSAMkkf%2Fuploads%2FXwBFZt4uIKFzosg00HAB%2F05-Permissions-App.png?alt=media\&token=79a7eef9-c028-419d-9459-cf67b0887751)

5. Select *Delegated permissions* and check *user\_impersonation*.

Click on *Add permission.*

![](https://3083465318-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsR50Wa7EwZGlmPSAMkkf%2Fuploads%2FBAysyv83K2HWVa8srIXa%2F06-Add-Permission.PNG?alt=media\&token=4459fd27-dd7a-4bfb-8782-53e864cfbcd5)

### Provisioning Azure AD Admin for Azure SQL Server

1. Create an SQL Server by navigating to the SQL Server at Azure Portal.

{% hint style="info" %}
**Note:** Write down the Server name.
{% endhint %}

![07-Add](https://3083465318-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsR50Wa7EwZGlmPSAMkkf%2Fuploads%2FJdqNbVlWR1DVOhmG4fH4%2F07-Add.PNG?alt=media\&token=1e4b1254-6401-4a2e-9b1f-3ffee002adc6)

2. Set an admin by navigating to Azure Active Directory in settings.

Click *Set Admin* and search for the user (existing or new) in Azure Active Directory. Then Click *Select.*

![08-Set-Admin](https://3083465318-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsR50Wa7EwZGlmPSAMkkf%2Fuploads%2FEkx162eYcVJxsNyEnIiu%2F08-Set-Admin.PNG?alt=media\&token=27dbda40-8424-42be-bda3-44ca1e6fd63d)

All the above-mentioned steps will be used in configuring the Azure SQL Server connecter for Azure Active Directory (AAD) methods.
