This repository is a demo project that shows how to train, deploy and run R machine learning models on SQL Server.
The repository is adapted from the tutorial R data analytics for SQL developers with the following changes:
- Using standard library R functions to train and run the machine learning model instead of RevoScaleR.
- Showing how to use Azure DevOps pipelines to implement a MLOps workflow in the context of R and SQL Server.
-
Install PowerShell, install the SQL Server PowerShell module, install Terraform, install the Azure CLI and authenticate with Azure via
az login
. -
Set up the required Azure resources by executing
./infrastructure/setup.ps1
. -
Set up the train_and_deploy pipeline with the variables listed in
secrets.env
.
Run the train_and_deploy pipeline to:
- Fetch training and validation data from SQL Server
- Train a model and validate it locally on the Azure DevOps agent
- Archive the model binary, training and validation data to Azure Storage
- Wait for approval and then deploy the model to SQL Server and score it against production data
Connect to the SQL Server using SSMS and execute the following:
sp_configure 'external scripts enabled', 1;
RECONFIGURE WITH OVERRIDE;
Next, restart the VM from the Azure portal.
Connect to the VM via RDP (ensure to prefix the username with LOCAL\
), open SQL Server Configuration Manager, select the SQL Server Services
option, find the SQL Server Launchpad
entry, right click and start the service.