Requirements for AI Analyses
AI Analyses require a SQL environment that can execute R scripts with Machine Learning Services.
AI Analyses only work if R can run and the processed dataset fits into the memory available to the R runtime.
Supported SQL environments
| Environment | Supported | Notes |
|---|---|---|
| SQL Server 2019 / 2022 on Windows | Yes | Machine Learning Services with R required |
| SQL Server on Azure Virtual Machine (Windows) | Yes | Machine Learning Services with R required |
| Azure SQL Managed Instance | Yes | Machine Learning Services with R is supported by the platform |
| Azure SQL Database | No | Does not support Machine Learning Services with R |
| SQL Server Express | No | Not supported |
| SQL Server on Linux | No | Not supported |
For RAM sizing, CPU guidance, and Azure SQL Managed Instance hardware recommendations, see Resource requirements for R based AI analytics.
1. Choose your platform
1.1 SQL Server on-premises or Azure Virtual Machine
Use this option if you want the most control over memory allocation, SQL Server configuration, and the R runtime.
- Supported versions: SQL Server 2019 and SQL Server 2022 on Windows
- Machine Learning Services with
Rmust be installed - The dab prepackaged
Rruntime is recommended max server memoryand Resource Governor can be used to leave enough memory forR
Microsoft documentation
- Install SQL Server
- Install SQL Server Machine Learning Services on Windows
- SQL Server on Azure Virtual Machines
1.2 Azure SQL Managed Instance
Use this option if you want a managed Azure SQL platform and accept the platform limits of Machine Learning Services.
- Machine Learning Services with
Ris supported by Azure SQL Managed Instance - The base
Rruntime is provided by Azure SQL Managed Instance - Do not use
RegisterRext.exeor Windows service steps on Azure SQL Managed Instance - Resource Governor external resource pools are not supported on Azure SQL Managed Instance
- By default,
Rcan use only up to 20% of Managed Instance resources - Required packages must be installed with
sqlmlutils
Microsoft documentation
- Machine Learning Services in Azure SQL Managed Instance
- Key Differences for Machine Learning Services in Azure SQL Managed Instance
- Install R packages with sqlmlutils
2. Enable Machine Learning Services
2.1 SQL Server on-premises or Azure Virtual Machine
Run the following command on the SQL instance:
sp_configure 'external scripts enabled', 1;
RECONFIGURE;
Restart the SQL Server Launchpad service afterwards.
2.2 Azure SQL Managed Instance
Run the same command on the Managed Instance:
sp_configure 'external scripts enabled', 1;
RECONFIGURE WITH OVERRIDE;
Azure SQL Managed Instance restarts the instance automatically during this change and is unavailable for a short time. There is no Launchpad service for you to restart manually.
3. Verify R execution
Execute the following on the SQL environment:
EXEC sp_execute_external_script @language = N'R', @script = N'print("OK")';
Expected output:
OK
To check the installed R version:
EXEC sp_execute_external_script @language = N'R', @script = N'print(R.version)';
To list installed packages:
EXEC sp_execute_external_script @language = N'R', @script = N'print(installed.packages()[, c("Package", "Version")])';
4. Install required R packages
4.1 SQL Server on-premises or Azure Virtual Machine
The recommended option is to use the dab prepackaged R runtime.
-
Download the runtime from dab Portal.
-
Copy it to the SQL Server.
-
Extract it to a local folder accessible by the SQL Server service account.
-
Change to the folder where you extracted it, go to the
library\RevoScaleR\rxLibs\x64subfolder in the R installation -
Register it with SQL Server:
RegisterRext.exe /configure /rhome:"C:\Program Files\R\R-4.x.x" /instance:"MSSQLSERVER" -
Restart the SQL Server Launchpad service.
-
Verify execution with a simple
Rscript.
This runtime registration process applies only to self-managed SQL Server on Windows and SQL Server on Azure Virtual Machine. It does not apply to Azure SQL Managed Instance.
4.2 Azure SQL Managed Instance
Azure SQL Managed Instance already includes the base R runtime. Only the required packages must be installed.
- Install required packages with
sqlmlutilsfrom a client machine - Do not attempt to copy a local
Rruntime to the service - If you use failover groups, install packages into a user database rather than
master
Use the Microsoft package management guide:
Troubleshooting
| Issue | Likely cause | Solution |
|---|---|---|
R scripts do not execute | external scripts enabled is disabled | Enable the setting and retry |
| Out-of-memory error during analysis | The dataset does not fit into the memory available to R | Reduce dataset size or increase available RAM. See Resource requirements for R based AI analytics |
| Launchpad does not start | Windows service misconfiguration | Check the SQL Server Launchpad service. Applies only to self-managed SQL Server |
RegisterRext.exe does not work | Wrong platform | Use it only on self-managed SQL Server on Windows or Azure VM |
| Azure SQL Managed Instance package installation fails | Wrong package installation method | Use sqlmlutils |
| Nexus cannot connect | SQL Auth disabled or firewall restrictions | Enable SQL Auth and open the required network path |