Version 0.1.1 Date 2015-08-14 Type Package Package AzureML August 15, 2015 Title Discover, Publish and Consume Web Services on Microsoft Azure Machine Learning Maintainer Raymond Laghaeian <raymondl@microsoft.com> Provides an interface with Microsoft Azure to easily publish functions and trained models as a web service, and discover and consume web service. License MIT + file LICENSE Copyright Microsoft Corporation LazyData TRUE Imports RCurl, uuid, codetools, base64enc, df2json, jsonlite, rjson Suggests testthat, knitr VignetteBuilder knitr NeedsCompilation no Author Raymond Laghaeian [aut, cre], Brianna Gerads [aut], Ritika Ravichandra [aut], Alex Wang [aut] Repository CRAN Date/Publication 2015-08-15 08:01:54 R topics documented: AzureML-package..................................... 2 consumedataframe..................................... 3 consumefile......................................... 4 consumelists........................................ 5 discoverschema....................................... 6 getendpoints........................................ 7 getepdetails........................................ 8 1
2 AzureML-package getwebservices....................................... 9 getwsdetails........................................ 10 publishwebservice..................................... 11 updatewebservice..................................... 12 Index 13 AzureML-package Discover, publish and consume Microsoft Azure Web Services This package implements an interface with Microsoft Azure Machine Learning, allowing you to publish a function, e.g. a prediction function using a trained machine learning model, as a web service from which it can be utilized by users on Visual Studio, Excel, etc., or consumed within R itself. You are also able to access pre-existing web service endpoints to consume directly from R. Finding the workspace ID and authorization token All functions require a workspace ID (wsid) and authorization token (authtoken). You can find these on the settings tab of https://studio.azureml.net, but users can make a temporary free account at https://azure.microsoft.com/en-us/pricing/free-trial/. For more information, see: https://github.com/azure/azure-machinelearning-clientlibrary-r or refer to the vignette included in this package. Summary of functions 1. Discovery Get web services: getwebservices Get web service details getwsdetails Get endpoints: getendpoints Get endpoint details: getepdetails 2. Publish Publish a new web service: publishwebservice Update an existing web service: updatewebservice 3. Consume Discover web service schema: discoverschema Score a file: consumefile Score a dataframe: consumedataframe Score data as lists: consumelists
consumedataframe 3 consumedataframe Use a web service to score a data frame Score a data frame, where each row is the input to the scoring function, using a Microsoft Azure Machine Learning web service consumedataframe(apikey, requesturl, scoredataframe, globalparam = setnames(list(), character(0)), batchsize = 300, retrydelay = 0.3) apikey requesturl primary access key of the web service as a string API URL scoredataframe the data frame to be scored globalparam global parameters entered as a list, default value is an empty list batchsize batch size of each batch, default value is 300 retrydelay the time in seconds to delay before retrying in case of a server error, default value is 0.3 seconds returndataframe data frame containing results returned from web service call discoverschema publishwebservice Other consumption functions: consumefile; consumelists add <- function(x,y) { return(x+y) } newservice <- publishwebservice("add", "add", list("x"="int","y"="int"), list("z"="int"), wsid, authtoken) webservicedetails <- newservice[[1]] endpoints <- newservice[[2]] df <- data.frame("x"=c(1,2), "y"=c(3,4)) response <- consumedataframe(endpoints[[1]]$primarykey, endpoints[[1]]$apilocation, df)
4 consumefile consumefile Use a web service to score a file Read in a csv and score it in batches using a Microsoft Azure Machine Learning Web Service. The results are stored in a new csv, default named "results.csv" consumefile(apikey, requesturl, infilename, globalparam = setnames(list(), character(0)), outputfilename = "results.csv", batchsize = 300, retrydelay = 0.3) apikey requesturl infilename globalparam primary access key as a string API URL the name of the file to be scored as a string global parameters entered as a list, default value is an empty list outputfilename the name of the file to output results to, entered as a string, default value is "results.csv" batchsize batch size of each batch, default value is 300 retrydelay the time in seconds to delay before retrying in case of a server error, default value is 0.3 seconds returndataframe data frame containing results returned from web service call discoverschema publishwebservice Other consumption functions: consumedataframe; consumelists add <- function(x,y) { return(x+y) } newservice <- publishwebservice("add", "add", list("x"="int","y"="int"), list("z"="int"), wsid, authtoken) webservicedetails <- newservice[[1]] endpoints <- newservice[[2]] response <- consumefile(endpoints[[1]]$primarykey, endpoints[[1]]$apilocation, "test.csv")
consumelists 5 consumelists Use a web service to score data in list format Score data represented as lists, where each list represents one parameter of the web service consumelists(apikey, requesturl,..., globalparam = setnames(list(), character(0)), retrydelay = 0.3) apikey requesturl primary access key as a string API URL... variable number of requests entered as lists in key-value format globalparam retrydelay global parameters entered as a list, default value is an empty list the time in seconds to delay before retrying in case of a server error, default value is 0.3 seconds returndataframe data frame containing results returned from web service call discoverschema publishwebservice Other consumption functions: consumedataframe; consumefile add <- function(x,y) { return(x+y) } newservice <- publishwebservice("add", "add", list("x"="int","y"="int"), list("z"="int"), wsid, authtoken) webservicedetails <- newservice[[1]] endpoints <- newservice[[2]] response <- consumelists(endpoints[[1]]$primarykey, endpoints[[1]]$apilocation, list("x"=1, "y"=2), list("x"=3, "y"=4))
6 discoverschema discoverschema Discover web service schema Discover the expected input to a web service specified by a web service ID ng the workspace ID and web service ID, information specific to the consumption functions discoverschema(helpurl, scheme = "https", host = "ussouthcentral.services.azureml.net", api_version = "2.0") helpurl URL of the help page of the web service scheme the URI scheme host optional parameter that defaults to ussouthcentral.services.azureml.net api_version defaults to 2.0 List containing the request URL of the webservice, column names of the data, sample input as well as the input schema publishwebservice consumelists Other discovery functions: getepdetails; getendpoints; getframework; getwsdetails; getwebservices endpoints <- getendpoints("wsid", "wsauth", "webserviceid") wsschema <- discoverschema(endpoints[[1]]$helplocation)
getendpoints 7 getendpoints Get Web Service Endpoints. Get the API endpoints that belong to a Microsoft Azure Machine Learning web service. getendpoints(wkid, authtoken, wsid, url = produrl) wkid authtoken wsid url workspace ID primary authorization token the web service ID the API url to make the call to, by default hits the Azure management API Returns a list of lists, where each endpoint is represented as a nested named list with the following fields: Name CreationTime WorkspaceId WebServiceId HelpLocation PrimaryKey SecondaryKey ApiLocation Version MaxConcurrentCalls DiagnosticsTraceLevel ThrottleLevel publishwebservice consumelists Other discovery functions: discoverschema; getepdetails; getframework; getwsdetails; getwebservices
8 getepdetails endpoints <- getendpoints("wkid", "authtoken", "wsid") helpurl <- endpoints[[1]]$helplocation pkey <- endpoints[[1]]$primarykey apiurl <- endpoints[[1]]$apilocation getepdetails Get Endpoint Details. Get detailed information about a specific endpoint for a web service specified by the Azure ML web service ID and endpoint name. getepdetails(wkid, authtoken, wsid, epname, url = produrl) wkid authtoken wsid epname url workspace ID primary authorization token the web service ID endpoint name, e.g. "default" the API url to make the call to, by default hits the Azure management API Returns a list with the following fields: Name CreationTime WorkspaceId WebServiceId HelpLocation PrimaryKey SecondaryKey ApiLocation Version MaxConcurrentCalls DiagnosticsTraceLevel ThrottleLevel
getwebservices 9 publishwebservice consumelists Other discovery functions: discoverschema; getendpoints; getframework; getwsdetails; getwebservices getwebservices Get Available Web Services. Get a list of webservices available to the Microsoft Azure Machine Learning workspace specified by the Azure ML workspace ID. getwebservices(wkid, authtoken, url = produrl) wkid authtoken url workspace ID primary authorization token the API url to make the call to, by default hits the Azure management API Returns a list of lists, where each web service is represented as a nested named list with the following fields: Id Name CreationTime WorkspaceId DefaultEndpointName publishwebservice consumelists Other discovery functions: discoverschema; getepdetails; getendpoints; getframework; getwsdetails services = getwebservices("wsid", "authtoken") serviceid = services[[1]]["id"]
10 getwsdetails getwsdetails Get Web Service Details. Get detailed information about a specific Microsoft Azure Machine Learning web service specified by the Azure ML web service ID. getwsdetails(wkid, authtoken, wsid, url = produrl) wkid authtoken wsid url workspace ID primary authorization token the web service ID the API url to make the call to, by default hits the Azure management API Returns a list with the following fields: Id Name CreationTime WorkspaceId DefaultEndpointName publishwebservice consumelists Other discovery functions: discoverschema; getepdetails; getendpoints; getframework; getwebservices
publishwebservice 11 publishwebservice Publish a function to Microsoft Azure Publish a function to Microsoft Azure Machine Learning as a web service. The web service created is a standard Azure ML web service, and can be utilized from any web or mobile platform. as long as the user has the API key and URL. The function to be published can use arbitrary objects and packages. Currently, the function to be published can only take in primitive data types as input, i.e. no data frames or lists, but support for those functions will be added in the future. publishwebservice(functionname, servicename, inputschema, outputschema, wkid, authtoken) functionname function name as a string to be published servicename name of the new web service inputschema list of input parameters of format list("arg1"="type", "arg2"="type",...) outputschema list of outputs of format list("output1"="type", "output2"="type",...) wkid the workspace ID authtoken primary authorization token nested list, the first element is a list containing information about the new web service, the second element is a list of its endpoints getwsdetails getendpoints discoverschema consumelists Other publishing functions: updatewebservice add <- function(x,y) { return(x+y) } newservice <- publishwebservice("add", "add", list("x"="int","y"="int"), list("z"="int"), wsid, authtoken) webservicedetails <- newservice[[1]] endpoints <- newservice[[2]] helpurl <- endpoints[[1]]$helplocation pkey <- endpoints[[1]]$primarykey apiurl <- endpoints[[1]]$apilocation
12 updatewebservice updatewebservice Update a Published Web Service Update a web service, i.e. change the underlying R code that the service will run when called. The same restrictions that apply to publishwebservice() also apply to updatewebservice() updatewebservice(functionname, servicename, wsid, inputschema, outputschema, wkid, authtoken) functionname servicename wsid function name as a string to be published name of the new web service ID of the web service to be updated inputschema list of input parameters of format list("arg1"="type", "arg2"="type",...) outputschema list of outputs of format list("output1"="type", "output2"="type",...) wkid authtoken the workspace ID primary authorization token List of webservice details, default endpoint details, and the consumption function getwsdetails getendpoints discoverschema consumelists Other publishing functions: publishwebservice add1 <- function(x) { return(x+1) } addservice <- publishwebservice("add1", "add1", list("x"="int"), list("z"="int"), wsid, wsauth) add2 <- function(x) { return(x+2) } addservice <- updatewebservice("add2", "add2", addservice[[1]]$id, list("x"="int"), list("z"="int"), wsid, wsauth)
Index Topic package AzureML-package, 2 AzureML (AzureML-package), 2 AzureML-package, 2 consumedataframe, 2, 3, 4, 5 consumefile, 2, 3, 4, 5 consumelists, 2 4, 5, 6, 7, 9 12 discoverschema, 2 5, 6, 7, 9 12 getendpoints, 2, 6, 7, 9 12 getepdetails, 2, 6, 7, 8, 9, 10 getframework, 6, 7, 9, 10 getwebservices, 2, 6, 7, 9, 9, 10 getwsdetails, 2, 6, 7, 9, 10, 11, 12 publishwebservice, 2 7, 9, 10, 11, 12 updatewebservice, 2, 11, 12 13