Connect to Azure SQL from Leapwork
Connect to Azure SQL from Leapwork
Introduction
This article explains how to connect Leapwork to Azure SQL using a Service Principal, covering steps to register an application in Microsoft Entra ID, configure networking, and set up database roles. Key credentials (ClientId, ClientSecret, TenantId) are integrated into Leapwork during installation for secure access. Users should also consider potential latency, scaling costs, and the need for independent data migration to Azure SQL.
Using Service Principal:
Client needs to create an Enterprise Application on their Azure portal, and while installing Leapwork, they need to pass the clientId, clientSecret, and TenantId for that app, using which we will create a token.
Go to Microsoft Entra ID → Go to App Registrations → Create New Registration.
Create the ClientId, ClientSecret, and TenantId as mentioned below:
NOTE: The client secret can be max generated with a validity of 2 years from Azure portal, so we will design a fallback screen to update secret in Leapwork app.
- Create new SQL server below:
When creating SQL server set a user to Admin using the Set Admin option below (this user will also be used to connect to the SQL server in step (e) below):
After creating new SQL server in the above step, go to that server and navigate to Networking tab from the right navigation pane:
- Select Selected networks option.
- Add your client IPv4 in Firewall rules.
Open SQL Server Management Studio (SSMS) and connect to the Azure SQL Server using Microsoft Entra MFA.
Create a contained user (name must be same that was used in app registration step) in the master database using below script:
CREATE USER [<service principle name>] FROM EXTERNAL PROVIDER; GO EXEC sp_addrolemember dbmanager, '<service principle name>'; GODuring Leapwork Installation, there will be an option for Azure SQL login, paste the above generated ClientId, ClientSecret, and TenantId, which will be stored in the system registry.
Limitations:
Latency: As currently, we are using physical servers with the current versions, and we have a very high volume of database calls, if we switch to Azure SQL, we might expect latency as the number of HTTP calls will be increased, which will affect the performance.
Cost: As the latency will increase, we might have to ask the customer to scale up the Azure SQL database, which will increase the cost for the customer.
Data Migration: Leapwork won’t be involved in the process of data migration from on-premise SQL database to Azure SQL, the customer needs to take care of it on their own.
If you have any questions, contact our Priority Support team.