Azure ML Package-Publish a Web service from R-Part2

In the last post, I have explained, how to use AzureML package with the aim of exploration of Azure ML studio experiments and datasets inside R studio environment. moreover how we can use this package to upload a dataset from R studio into Azure ML has been shown.

In this post, I am going to show you how we can create a function inside R and then publish an API from it.

imagine we have a function for the adding two number in R studio as below there

add <- function(x, y) { x + y }

is a function of the AzureML package “publishWebService” that able to publish function in R studio into Azure Ml as API.

api <- publishWebService( ws, fun = add, name = "AzureML_Add_Function", inputSchema = list( x = "numeric", y = "numeric" ), outputSchema = list( ans = "numeric" ))

this function gets :

1- ws, information about the web service that has been explained in the last post,

2-fnn, the name of the function

3- name, the name that we want to display it in the Azure environment

4- input dataset, as a list

5-output dataset as a list

NOTE: when you run the code, it may ask you to install zip, you able to handle the error by downloading one version of Rtools into your machine from https://cran.r-project.org/bin/windows/Rtools/

Just go and check the web service in Azure ML,  you will see the function in top of the list (see below)

you able to test it

Moreover, you able to share the API key and URL with any other application, language to have smarter application.

Leila Etaati on LinkedinLeila Etaati on TwitterLeila Etaati on Youtube
Leila Etaati
Trainer, Consultant, Mentor
Leila is the first Microsoft AI MVP in New Zealand and Australia, She has Ph.D. in Information System from the University Of Auckland. She is the Co-director and data scientist in RADACAD Company with more than 100 clients in around the world. She is the co-organizer of Microsoft Business Intelligence and Power BI Use group (meetup) in Auckland with more than 1200 members, She is the co-organizer of three main conferences in Auckland: SQL Saturday Auckland (2015 till now) with more than 400 registrations, Difinity (2017 till now) with more than 200 registrations and Global AI Bootcamp 2018. She is a Data Scientist, BI Consultant, Trainer, and Speaker. She is a well-known International Speakers to many conferences such as Microsoft ignite, SQL pass, Data Platform Summit, SQL Saturday, Power BI world Tour and so forth in Europe, USA, Asia, Australia, and New Zealand. She has over ten years’ experience working with databases and software systems. She was involved in many large-scale projects for big-sized companies. She also AI and Data Platform Microsoft MVP. Leila is an active Technical Microsoft AI blogger for RADACAD.

Leave a Reply