c-w / r-sql-server-demo

Demo project deploying and running R machine learning models on SQL Server

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

R SQL Server Demo

Build Status

What's this?

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.

One-time set up

  1. Install PowerShell, install the SQL Server PowerShell module, install Terraform, install the Azure CLI and authenticate with Azure via az login.

  2. Set up the required Azure resources by executing ./infrastructure/setup.ps1.

  3. Set up the train_and_deploy pipeline with the variables listed in secrets.env.

Training, publishing and scoring a model

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

Troubleshooting

'sp_execute_external_script' is disabled on this instance of SQL Server

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.

Unable to communicate with the LaunchPad service

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.

About

Demo project deploying and running R machine learning models on SQL Server

License:MIT License


Languages

Language:PowerShell 47.1%Language:HCL 36.4%Language:TSQL 10.5%Language:R 5.9%