Search code examples
rdatabaseazureazure-sql-databaseazure-machine-learning-service

Run R script using sp_invoke_external_rest_endpoint on Azure SQL


I'm trying to execute an R script from Azure SQL database. Using an Azure function is not possible due to project policies, so goes for containers, they are not allowed. Therefore I'll like to know if there are other possible solutions to the problem.

Recently I've found about the sp_invoke_external_rest_endpoint, nonetheless I'ld like to know if it possible to use this procedure to trigger an Azure Machine Learning Notebook (which would contain my R code), since I'm not seeing the resource available on the Microsoft official documentation for this command.

Please review below the link, since I'm a bit newbie on this topic and I might have misread something

https://learn.microsoft.com/en-us/sql/relational-databases/system-stored-procedures/sp-invoke-external-rest-endpoint-transact-sql?view=azuresqldb-current&tabs=request-headers


Solution

  • As you can see in this MS Document

    enter image description here

    Only this endpoints are allowed to call from sp_invoke_external_rest_endpoint

    To achieve your requirement, AFAIK, there are no alternatives to trigger ML notebooks apart from functions. you can try to run R script in azure databricks and with logic app trigger the databricks notebook then call that azure logic app URL in sp_invoke_external_rest_endpoint from azure SQL.

    To create databricks connector in logic app you can follow this answer