<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
  version="2.0">
  <channel>
    <title>Microsoft R Server Tiger Team</title>
    <atom:link
      href="https://docs.microsoft.com/archive/blogs/microsoftrservertigerteam/feed.xml"
      rel="self"
      type="application/rss+xml" />
    <link>https://docs.microsoft.com/archive/blogs/microsoftrservertigerteam/feed.xml</link>
    <description>This is the official team web log for Microsoft R Server Tiger Engineering team which is part of Data Group.</description>
    <lastBuildDate>Fri, 06 Oct 2017 20:44:56 GMT</lastBuildDate>
    <language>en-US</language>
    <sy:updatePeriod>hourly</sy:updatePeriod>
    <sy:updateFrequency>1</sy:updateFrequency>
    <item>
      <title>Using Certificates in R Server Operationalization for Linux</title>
      <link>https://docs.microsoft.com/archive/blogs/microsoftrservertigerteam/using-certificates-in-r-server-operationalization-for-linux</link>
      <pubDate>Fri, 19 May 2017 14:15:38 GMT</pubDate>
      <dc:creator><![CDATA[Ramkumar Chandrasekaran, Microsoft]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/microsoftrservertigerteam/?p=4565</guid>
      <description><![CDATA[In this article, we will look into how to generate a self-signed certificate in Linux and use it for...]]></description>
      <content:encoded><![CDATA[In this article, we will look into how to generate a self-signed certificate in Linux and use it for access token signing in <a target="_blank" href="https://msdn.microsoft.com/en-us/microsoft-r/operationalize/about" rel="noopener noreferrer">R Server Operationalization</a> Web Node. You must use a certificate for access token signing whenever you have multiple web nodes so that the tokens are signed consistently by every web node in your configuration. A certificate with a private key is required to sign the user access tokens between the web node and the LDAP server. Tokens are particularly useful to the application developer who can use them to <a target="_blank" href="https://msdn.microsoft.com/en-us/microsoft-r/operationalize/security-access-tokens" rel="noopener noreferrer">identify and authenticate the user</a> who is sending the API call within her or his application.

To try this out, you can spin up one of the R Server Linux images that are available in the Azure Portal:

<a target="_blank" href="https://portal.azure.com/#create/Microsoft.MicrosoftRServerversion910forLinuxUbuntuversion1604-ARM" rel="noopener noreferrer">Microsoft R Server (version 9.1.0) for Linux (Ubuntu version 16.04)</a>
<a target="_blank" href="https://portal.azure.com/#create/Microsoft.MicrosoftRServerversion910forLinuxCentOSversion72-ARM" rel="noopener noreferrer">Microsoft R Server (version 9.1.0) for Linux (CentOS version 7.2)</a>
<a target="_blank" href="https://portal.azure.com/#create/Microsoft.MicrosoftRServerversion910forLinuxRedHatversion72-ARM" rel="noopener noreferrer">Microsoft R Server (version 9.1.0) for Linux (RedHat version 7.2)</a>

<strong>Here are the list of steps:</strong>

1. Switch to root user and navigate to home directory /root
<pre>sudo su
cd /root</pre>
<strong>If you already have a certificate from Trusted Certificate Authority , skip step 2 and move to step 3.</strong>

<span>2. </span>Generate Self-Signed Certificate (.pfx file)

We are limited to using pfx files since dotnet core can <a target="_blank" href="https://github.com/dotnet/corefx/issues/14284" rel="noopener noreferrer">read private keys only from pfx files</a>. Using subjectName CN=LOCALHOST here, you can replace with a subject name of your choice.
<pre>openssl genrsa -out privateKey.pem 2048
openssl req -new -x509 -key privateKey.pem -out publicCert.pem -days 3650 -nodes -subj "/CN=LOCALHOST"
openssl pkcs12 -export -out merged.pfx -inkey privateKey.pem -in publicCert.pem -passout pass:</pre>
3. Install Certificate using dotnet code

Only Root and CertificateAuthority are supported for StoreName in Linux. We will use <strong>Root as StoreName</strong> since we start the WebNode as root user. On Linux, we don’t have any notion of machine-owned private keys, because Linux doesn’t have a machine-level private key store, and the LocalMachine\Root is loaded with that knowledge (it loads only X.509 PEM, X.509 DER, and X.509 PEM-series files). Hence, we will use <strong>CurrentUser</strong> <strong>as StoreLocation</strong>.
<pre>dotnet new console -o InstallCert
cd InstallCert
vi Program.cs</pre>
<script src="https://gist.github.com/ramnov/e26b8d695e148bdc7908fdb216ac66d4.js"></script>
<pre>dotnet restore
dotnet run</pre>
If the program ran successfully without any errors, certificate will be installed in the following path with its thumbprint as file name:
<pre>/root/.dotnet/corefx/cryptography/x509stores/root/D03B70561C0E61F188AC1A6EFF47C18B8E7767E1.pfx</pre>
4. Modify /usr/lib64/microsoft-r/rserver/o16n/9.1.0/Microsoft.RServer.WebNode/appsettings.json with the following JWTSigningCertificate information:
<pre>"JWTSigningCertificate": {
 "Enabled": true,
 "Description": "Enable this section if you want to sign the access token with a certificate instead of a randomly generated key",
 "StoreName": "Root",
 "StoreLocation": "CurrentUser",
 "SubjectName": "CN=LOCALHOST"
 }</pre>
At this point, you will see that JWTKey has a 'not set' value in appsettings.json file :
<pre>"JWTKey": "not set"
</pre>
5. <a target="_blank" href="https://msdn.microsoft.com/en-us/microsoft-r/operationalize/admin-utility#startstop" rel="noopener noreferrer">Start the web node</a> using the administration utility so that the changes can take effect.

6. Once the webnode starts successfully, check /usr/lib64/microsoft-r/rserver/o16n/9.1.0/Microsoft.RServer.WebNode/appsettings.json to see if the JWTKey has been generated :
<pre>"JWTKey": "eyJEIjoiSkp..........WdTRJZ009In0="</pre>
If you have multiple web nodes, Copy paste the certificate to all other webnodes and perform step 3 to 6.

Share the connection details with any users who authenticates with R Server either to make <a target="_blank" href="https://msdn.microsoft.com/en-us/microsoft-r/operationalize/api" rel="noopener noreferrer">API calls</a> directly or indirectly in R <a target="_blank" href="https://msdn.microsoft.com/en-us/microsoft-r/operationalize/mrsdeploy-connection" rel="noopener noreferrer">using remoteLogin() function in the mrsdeploy package</a>.

<strong>NOTE:</strong> Self-Signed Certificates are NOT recommended for production usage. Please obtain certificate from Trusted Certificate Authorities for production usage.

This method of using Self-Signed Certificates for JWTSigningCertificate is automated in <a target="_blank" href="https://github.com/Microsoft/microsoft-r/tree/master/rserver-arm-templates/enterprise-configuration/linux" rel="noopener noreferrer">Linux Enterprise ARM Template</a>.
<h3>UPDATE :</h3>
For the newly released <a target="_blank" href="https://blogs.technet.microsoft.com/machinelearning/2017/09/25/introducing-microsoft-machine-learning-server-9-2-release/" rel="noopener noreferrer">Machine Learning Server 9.2.1</a>, the webnode runs under webnode_usr and hence the certificate must be present in webnode_usr home directory. Follow steps 1-3 and then copy paste the generated pfx file into this location : <span>/home/webnode_usr/.dotnet/corefx/cryptography/x509stores/root. Here are the commands : </span>
<pre><span>mkdir -p /home/webnode_usr/.dotnet/corefx/cryptography/x509stores/root
cp </span>/root/.dotnet/corefx/cryptography/x509stores/root/D03B70561C0E61F188AC1A6EFF47C18B8E7767E1.pfx <span>/home/webnode_usr/.dotnet/corefx/cryptography/x509stores/root
chmod 777 </span><span>/home/webnode_usr/.dotnet/corefx/cryptography/x509stores/root</span></pre>
This is automated in <a target="_blank" href="https://github.com/Microsoft/microsoft-r/tree/master/mlserver-arm-templates/enterprise-configuration/linux" rel="noopener noreferrer">Machine Learning Server Linux Enterprise ARM Template</a>.
<h3>REFERENCES:</h3>
<p id="authentication-options-for-r-server-when-operationalizing-analytics"><a target="_blank" href="https://msdn.microsoft.com/en-us/microsoft-r/operationalize/security-authentication" rel="noopener noreferrer">Authentication options for R Server when operationalizing analytics</a></p>
<p id="access-token-management-for-api-requests"><a target="_blank" href="https://msdn.microsoft.com/en-us/microsoft-r/operationalize/security-access-tokens" rel="noopener noreferrer">Access Token Management for API Requests</a></p>
<p id="connection-security-ssltls"><a target="_blank" href="https://msdn.microsoft.com/en-us/microsoft-r/operationalize/security-https" rel="noopener noreferrer">Connection Security (SSL/TLS)</a></p>]]></content:encoded>
    </item>
    <item>
      <title>Configuring R Server to Operationalize Analytics using ARM Templates</title>
      <link>https://docs.microsoft.com/archive/blogs/microsoftrservertigerteam/configuring-r-server-to-operationalize-analytics-using-arm-templates</link>
      <pubDate>Sun, 14 May 2017 21:48:00 GMT</pubDate>
      <dc:creator><![CDATA[Ramkumar Chandrasekaran, Microsoft]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/microsoftrservertigerteam/?p=4545</guid>
      <description><![CDATA[To benefit from Microsoft R Server’s deployment and operationalization features, you can configure R...]]></description>
      <content:encoded><![CDATA[To benefit from <a target="_blank" href="https://blogs.msdn.microsoft.com/rserver/2017/04/19/whats-new-in-r-server-9-1-operationalization/">Microsoft R Server’s deployment and operationalization features</a>, you can configure R Server after installation to act as a deployment server and host analytic web services. R Server Web Services can be operationalized in two types of configuration :

<strong>One-box configuration:</strong> As the name suggests, one web node and one compute node run on a single machine. This configuration is useful when you want to explore what it is to operationalize R analytics using R Server. It is perfect for testing, proof-of-concepts, and small-scale prototyping, but might not be appropriate for production usage.

<strong>Enterprise configuration:</strong> In this configuration, multiple nodes are configured on multiple machines along with other enterprise features like High Availability, Active Directory Authentication, Secure Connectivity etc. This configuration can be scaled up or down by adding or removing nodes.

We have created the following 6 ARM Templates for easy deployment of One-Box and Enterprise Configurations:
<ol>
 	<li><a target="_blank" href="https://github.com/Microsoft/microsoft-r/tree/master/rserver-arm-templates/one-box-configuration/windows">OneBox Configuration for Windows</a></li>
 	<li><a target="_blank" href="https://github.com/Microsoft/microsoft-r/tree/master/rserver-arm-templates/one-box-configuration/linux">OneBox Configuration for Linux</a></li>
 	<li><a target="_blank" href="https://github.com/Microsoft/microsoft-r/tree/master/rserver-arm-templates/hdinsight">OneBox Configuration on Edge Node of R Server HDInsight Cluster</a></li>
 	<li><a target="_blank" href="https://github.com/Microsoft/microsoft-r/tree/master/rserver-arm-templates/enterprise-configuration/windows-sql-azure">Dynamic Scaling Enterprise Configuration on Windows with Azure SQL DB as WebNode Backend and Azure Active Directory Authentication</a></li>
 	<li><a target="_blank" href="https://github.com/Microsoft/microsoft-r/tree/master/rserver-arm-templates/enterprise-configuration/windows-sql-always-on">Dynamic Scaling Enterprise Configuration on Windows with SQL Always On cluster as WebNode Backend and Active Directory Authentication</a></li>
 	<li><a target="_blank" href="https://github.com/Microsoft/microsoft-r/tree/master/rserver-arm-templates/enterprise-configuration/linux">Dynamic Scaling Enteprise Configuration on Linux with Azure SQL DB as WebNode Backend and Azure Active Directory Authentication</a></li>
</ol>
Just Click “Deploy to Azure” button in the github page to deploy the ARM Templates. Architecture and Instructions to connect are provided in the respective github page.

There are several other ways to deploy ARM Templates: Azure Portal, .NET SDK, Powershell, Azure CLI, Ruby, Visual Studio, REST API, AzureSMR package. Refer to <a target="_blank" href="https://blogs.msdn.microsoft.com/microsoftrservertigerteam/2017/03/21/11-ways-to-deploy-r-server-on-hdinsight-cluster/">this article</a> for detailed steps.

For any issues (or) feature requests, please use the <a target="_blank" href="https://github.com/Microsoft/microsoft-r/issues">issues page</a> in github. Code contributions are also welcome by <a target="_blank" href="https://github.com/Microsoft/microsoft-r/pulls">creating a pull request</a>.

<strong>USEFUL LINKS : </strong>

<a target="_blank" href="https://blogs.technet.microsoft.com/dataplatforminsider/2017/04/19/introducing-microsoft-r-server-9-1-release/">Introducing Microsoft R Server 9.1 release</a>
<a target="_blank" href="https://blogs.msdn.microsoft.com/rserver/2017/04/19/whats-new-in-r-server-9-1-operationalization/">What’s new in R Server 9.1 Operationalization</a>
<a target="_blank" href="https://msdn.microsoft.com/en-us/microsoft-r/operationalize/about">About operationalizing analytics with R Server</a>
<a target="_blank" href="https://msdn.microsoft.com/en-us/microsoft-r/operationalize/configuration-initial#onebox">Configuring R Server to operationalize analytics (One-Box Configuration)</a>
<a target="_blank" href="https://msdn.microsoft.com/en-us/microsoft-r/operationalize/configure-enterprise">Configuring R Server to operationalize analytics (Enterprise Configuration)</a>]]></content:encoded>
    </item>
    <item>
      <title>Enterprise-grade R package management made easy in SQL Server</title>
      <link>https://docs.microsoft.com/archive/blogs/microsoftrservertigerteam/enterprise-grade-r-package-management-made-easy-in-sql-server</link>
      <pubDate>Thu, 11 May 2017 12:18:15 GMT</pubDate>
      <dc:creator><![CDATA[Te Zhang]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/microsoftrservertigerteam/?p=4485</guid>
      <description><![CDATA[As enterprise data scientists access SQL Server R Services to perform their in-database analytic...]]></description>
      <content:encoded><![CDATA[<p style="margin-top: 15pt;margin-bottom: 22pt;font-family: 'Segoe UI';font-size: 10.5pt;color: #333333"><span>As enterprise data scientists access </span><a target="_blank" href="https://docs.microsoft.com/en-us/sql/advanced-analytics/r/sql-server-r-services">SQL Server R Services</a><span> to perform their in-database analytic work such as data mining and machine learning, the R language's full power cannot be materialized without custom yet secure R package installation. SQL Server has offered </span><a target="_blank" href="https://docs.microsoft.com/en-us/sql/advanced-analytics/r/r-package-management-for-sql-server-r-services">R package management</a><span> functionality since 2016 (SQL R Services 9.0) which enables a team of data scientists to, for example,</span><span> m</span><span>anage R packages on a per-database basis, keep R packages in sync with the database, s</span><span>hare R packages and/or each have his/her own custom installation and automatically r</span><span>esolve R package dependencies during uninstallation. </span><span>This also eliminates the need for the database administrator to understand R and its package dependencies and gives R packages enterprise-level authentication and security. </span></p>
<p style="margin-top: 15pt;margin-bottom: 22pt;font-family: 'Segoe UI';font-size: 10.5pt;color: #333333">Currently the rx function APIs are only for use in a <a target="_blank" href="https://msdn.microsoft.com/en-us/microsoft-r/scaler-sql-server-getting-started#using-sql-server-as-a-compute-context">SQL Server compute context</a>. They are a convenient wrapper of the suite of package management functions like <span style="color: #ff0000"><code>install.packages()</code></span> in base R.</p>
<p style="margin-top: 15pt;margin-bottom: 22pt;font-family: 'Segoe UI';font-size: 10.5pt;color: #333333">Custom and secure package management is governed by scopes</p>

<ul>
 	<li><strong>Shared scope</strong> - this scope allows allowed users to install &amp; uninstall packages in per database shared location which in turn can be used by other users of the database on SQL server</li>
 	<li><strong>Private scope</strong> - this scope allows allowed users to install &amp; uninstall packages in per database per user private location which can only be used by the single user of the database on SQL server</li>
</ul>
<p style="margin-top: 15pt;margin-bottom: 22pt;font-family: 'Segoe UI';font-size: 10.5pt;color: #333333">and database roles</p>

<ul>
 	<li><strong>rpkgs-users</strong> - allows users to use shared packages installed by users belong to rpkgs-shared role</li>
 	<li><strong>rpkgs-private</strong> - allows all permissions as rpkgs-users role and also allows users to install, remove and use private packages</li>
 	<li><strong>rpkgs-shared</strong> - allows all permissions as rpkgs-private role and also allows users to install, remove shared packages</li>
 	<li><strong>db_owner</strong> - allows all permissions as rpkgs-shared role and also allows users to install &amp; remove shared and private packages for other users for management</li>
</ul>
<p style="margin-top: 15pt;margin-bottom: 22pt;font-family: 'Segoe UI';font-size: 10.5pt;color: #333333"><img width="273" height="481" class="size-full wp-image-4515 alignnone" alt="rp" src="https://msdnshared.blob.core.windows.net/media/2017/05/rp1.png" /></p>
<p style="margin-top: 15pt;margin-bottom: 22pt;font-family: 'Segoe UI';font-size: 10.5pt;color: #333333">By default, any user can use the packages in the shared scope. The beauty is that, each <span>rpkgs-private role</span> user can also install his/her own version of this package in his/her private scope. And when this happens, the shared-scope package will be masked, meaning that when this user calls <span style="color: #ff0000"><code>library(&lt;package name&gt;)</code></span>, only his/her installed private-scope version of this package will be loaded.</p>
<p style="margin: 0in;font-family: 'Segoe UI';font-size: 10.5pt;color: #333333"><span style="background: white">We will walk through a simple example to mimic a mock yet typical scenario where data scientists collaborate in a database.</span></p>


<hr />

<h1 style="margin: 0in;font-family: 'Segoe UI';font-size: 10.5pt;color: #333333"></h1>
<h1 style="margin: 0in;font-family: 'Segoe UI';font-size: 10.5pt;color: #333333"></h1>
<h1 style="margin: 0in;font-family: 'Segoe UI';font-size: 10.5pt;color: #333333"></h1>
<h1 style="margin: 0in;font-family: 'Segoe UI';font-size: 10.5pt;color: #333333"><strong>Example:</strong></h1>
&nbsp;
<p style="margin: 0in;font-family: 'Segoe UI';font-size: 10.5pt;color: #333333"><span style="background: white">First we create a database called RevoTestDB. Then we need to</span></p>

<ol>
 	<li style="margin: 0in;font-family: 'Segoe UI';font-size: 10.5pt;color: #333333"><span style="font-family: 'Segoe UI';font-size: 10.0pt;text-decoration: underline;background: white"><a href="https://docs.microsoft.com/en-us/sql/advanced-analytics/r/set-up-sql-server-r-services-in-database#a-namebkmkenablefeaturea-step-2-enable-external-script-services">Set up SQL Server R Services</a></span></li>
 	<li style="margin: 0in;font-family: 'Segoe UI';font-size: 10.5pt;color: #333333"><span style="text-decoration: underline;font-family: 'Segoe UI';font-size: 10.0pt;background: white"><a href="https://docs.microsoft.com/en-us/sql/advanced-analytics/r/r-package-how-to-enable-or-disable">Enable package management</a></span></li>
</ol>
<p style="margin: 0in;font-family: 'Segoe UI';font-size: 10.5pt;color: #333333"><span style="background: white">Step 2 will create the additional database roles rpkgs-private, rpkgs-shared and rpkgs-users which are specific for package management as shown on the left. </span>Then we run the T-SQL script below to create the following database users, each taking a specific database role, with their level of permissions in descending order:</p>
<span></span>
<div style="direction: ltr"></div>
<div style="direction: ltr">
<table width="341" title="" border="1" cellspacing="0" cellpadding="0" summary="">
<tbody>
<tr>
<td><span>data scientist lead</span></td>
<td><span>db_owner</span></td>
</tr>
<tr>
<td><span>senior data scientist</span></td>
<td><span>rpkgs-shared</span></td>
</tr>
<tr>
<td><span>junior data scientist</span></td>
<td><span>rpkgs-private</span></td>
</tr>
<tr>
<td><span>other users</span></td>
<td><span>rpkgs-users</span></td>
</tr>
</tbody>
</table>
</div>
<div style="direction: ltr"></div>
<p style="margin: 0in;font-family: 'Segoe UI';font-size: 10.5pt;color: #333333"><span style="background: white">
</span>
The script also grants other roles and permissions needed for these users to use the database as required in the <span style="text-decoration: underline;background: white"><a href="https://docs.microsoft.com/en-us/sql/advanced-analytics/r/set-up-sql-server-r-services-in-database#a-namebkmkenablefeaturea-step-2-enable-external-script-services">set up SQL Server R Services</a></span><span style="background: white"> step.</span></p>
<script src="https://gist.github.com/tezhangtiger/5f68e4bb4484ee4b6c538da49b0e1f1e.js?file=revo_ds_scenario.sql"></script>
<p style="margin-top: 15pt;margin-bottom: 22pt;font-family: 'Segoe UI';font-size: 10.5pt;color: #333333"><span>To install the package 'scales' in shared scope for anyone to use, the senior data scientist can run the following script, and by default he/she installed the lastest version (0.4.1) of 'scales' from <a target="_blank" href="https://mran.microsoft.com/">MRAN</a></span><span>:</span></p>
<script src="https://gist.github.com/tezhangtiger/5f68e4bb4484ee4b6c538da49b0e1f1e.js?file=senior_install_scales_shared.R"></script>
<p style="margin-top: 15pt;margin-bottom: 22pt;font-family: 'Segoe UI';font-size: 10.5pt;color: #333333">Then any user can use the package by either passing the package name to <code>transformPackages</code> in an rx fucntion or loading the package in an <code>rxExec</code> call. For example,</p>
<script src="https://gist.github.com/tezhangtiger/5f68e4bb4484ee4b6c538da49b0e1f1e.js?file=user_use_scales.R"></script>
<p style="margin: 0in"><span style="font-family: 'Segoe UI';font-size: 10.5pt;color: #333333;background: white">Now say the junior data scientist wants to install an older version of scales (0.4.0) for himself/herself's own use, he/she can, for example, download the .zip file to his local working directory and run the following script to install scales 0.4.0 from the downloaded .zip file by specifying <code>repos = NULL</code> in <code>rxInstallPackages</code> and verify that's actually the version that's loaded. Other users will not be affected by the junior data scientist's installation and will still be using scales 0.4.1.</span></p>
<script src="https://gist.github.com/tezhangtiger/5f68e4bb4484ee4b6c538da49b0e1f1e.js?file=ds_junior_install_scales_private.R"></script>
<p style="margin-top: 15pt;margin-bottom: 22pt;font-family: 'Segoe UI';font-size: 10.5pt;color: #333333">The data scientist lead can install/uninstall any packages on behalf of any user. And when he/she uninstalls a package, the dependencies are automatically taken care of by specifying <code>dependencies = TRUE</code> in <code>rxRemovePackages</code>.</p>
<script src="https://gist.github.com/tezhangtiger/5f68e4bb4484ee4b6c538da49b0e1f1e.js?file=ds_lead_remove_scales.R"></script>
<p style="margin-top: 15pt;margin-bottom: 22pt;font-family: 'Segoe UI';font-size: 10.5pt;color: #333333">The output will be something like this:</p>
<p style="margin-top: 15pt;margin-bottom: 22pt;font-family: 'Segoe UI';font-size: 10.5pt;color: #333333"><img width="960" height="291" class="alignnone size-full wp-image-4536" alt="rp2" src="https://msdnshared.blob.core.windows.net/media/2017/05/rp2.png" /></p>
<p style="margin-top: 15pt;margin-bottom: 22pt;font-family: 'Segoe UI';font-size: 10.5pt;color: #333333">To change a SQL Server instance's system package installation manually, refer to <a target="_blank" href="https://docs.microsoft.com/en-us/sql/advanced-analytics/r/install-additional-r-packages-on-sql-server">Install Additional R Packages on SQL Server</a>.</p>
<p style="margin: 0in"><span style="font-family: Calibri;font-size: 11.0pt"> </span></p>]]></content:encoded>
    </item>
    <item>
      <title>Introducing Zipkin-Azure</title>
      <link>https://docs.microsoft.com/archive/blogs/microsoftrservertigerteam/introducing-zipkin-azure</link>
      <pubDate>Wed, 10 May 2017 11:15:07 GMT</pubDate>
      <dc:creator><![CDATA[Rony Chatterjee]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/microsoftrservertigerteam/?p=4385</guid>
      <description><![CDATA[Today in Build 2017, we released Microsoft's contribution to the Open Source Community by...]]></description>
      <content:encoded><![CDATA[<p style="text-align: justify"><span style="font-size: 11.0pt;font-family: 'Segoe UI Emoji',sans-serif">Today in <a href="https://build.microsoft.com/"><span style="color: windowtext">Build 2017</span></a>, we released Microsoft's contribution to the Open Source Community by extending <a href="http://zipkin.io/">Zipkin</a><span class="apple-converted-space"> </span>with the power of Application Insights calling it “<a href="https://github.com/openzipkin/zipkin-azure">Zipkin-Azure</a>”. </span></p>
<p style="text-align: justify"><span style="font-size: 11.0pt;font-family: 'Segoe UI Emoji',sans-serif">Zipkin is a tracing tool for distributed systems to log events related to each individual activity (also known as job, transaction, or trace, depending on the context) in a way that allows the path of the activity through the system to be reconstructed. It offers correlation across multiple services within a customer’s application. With Application Insights integration, Zipkin now gains the ability to log data to an Application Insights store and to trace activities through multiple services including non-logging systems using impersonation. It provides application performance management features from Application Insights along with tracing capabilities provided by Zipkin. </span></p>
<p style="text-align: justify"><span style="font-size: 11.0pt;font-family: 'Segoe UI Emoji',sans-serif">Application Insights users would also be able to leverage the distributed tracing offered through Zipkin by instrumenting their services using existing <a href="http://zipkin.io/pages/existing_instrumentations.html"><span style="color: windowtext">libraries.</span></a> <span style="color: black">To use the Application Insights back-end store, configure your Zipkin server instance to use the Application Insights<span class="apple-converted-space"> </span></span><span style="color: #333333"><a href="https://github.com/openzipkin/zipkin-azure/pulls">plug-in</a></span><span style="color: black">. This integration makes monitoring and debugging your overall end-to-end applications much easier.</span></span></p>
<p style="text-align: justify"><span style="font-size: 11.0pt;font-family: 'Segoe UI Emoji',sans-serif;color: black">Azure-based systems may already have one or more associated Application Insights instances. If so, you can use any one of them. Otherwise, you can create a new Application Insights instance by logging in to the<span class="apple-converted-space"> </span></span><span style="font-size: 11.0pt;font-family: 'Segoe UI Emoji',sans-serif;color: #333333"><a href="https://portal.azure.com/">Azure Portal</a></span><span style="font-size: 11.0pt;font-family: 'Segoe UI Emoji',sans-serif;color: black">, and then navigate to the Application Insights blade, either by typing “Application Insights” into the search bar or by choosing “Application Insights” from the service list.</span><span style="font-size: 11.0pt;font-family: 'Segoe UI Emoji',sans-serif;color: #333333"></span></p>


[caption id="attachment_4416" align="alignnone" width="837"]<img src="https://msdnshared.blob.core.windows.net/media/2017/05/Zipkin_Azure.png" alt="Zipkin-Application Insights Integration Architecture" width="837" height="494" class=" wp-image-4416" /> Zipkin-Application Insights Integration Architecture[/caption]

You can also view our offerings through this short video -

[video width="1920" height="1080" mp4="https://msdnshared.blob.core.windows.net/media/2017/05/ZipKin_AppInsights-Video1.mp4"][/video]]]></content:encoded>
    </item>
    <item>
      <title>Using RxOdbcData with Oracle Wallet</title>
      <link>https://docs.microsoft.com/archive/blogs/microsoftrservertigerteam/using-oracle-wallet-with-rxodbcdata</link>
      <pubDate>Thu, 04 May 2017 17:31:09 GMT</pubDate>
      <dc:creator><![CDATA[Eqbal Zaffar]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/microsoftrservertigerteam/?p=4376</guid>
      <description><![CDATA[In Microsoft R Server you can use RxOdbcData class to connect to an ODBC DataSource, for example a...]]></description>
      <content:encoded><![CDATA[In Microsoft R Server you can use <code>RxOdbcData</code> class to connect to an ODBC DataSource, for example a table in an Oracle database. At times some of our customer's have a requirement to hide the credentials for their Oracle database (username and password) in the connection string they specify when writing an R script in Microsoft R Server. Oracle's driver does not support saving the password when creating an ODBC DSN in Windows. In this blog we describe a way to achieve this requirement using Oracle's Wallet.
<h2>Prerequisites</h2>
<ol>
 	<li><a href="http://www.oracle.com/technetwork/database/enterprise-edition/downloads/database12c-win64-download-2297732.html">Oracle client</a> must be installed and the client's bin folder must be added to PATH environment variable.</li>
 	<li>Recommend using separate <code>sqlnet.ora</code> and <code>tnsnames.ora</code> files so as to separate regular connections from wallet connection. Normally you can find these files under <code>$ORACLE_HOME/network/admin</code> folder or something similar.</li>
 	<li><code>TNS_ADMIN</code> environment variable should point to the approproate folder with <code>sqlnet.ora</code> and <code>tnsnames.ora</code>.</li>
</ol>
<h2>Setting up wallet</h2>
1. Create a directory for a wallet and use Oracle's <code>mkstore</code> command to create a wallet in that directory:
<p style="padding-left: 30px"><code>mkdir -p C:\Oracle\admin\mywallet</code></p>
<p style="padding-left: 30px"><code>mkstore -wrl C:\Oracle\admin\mywallet -create</code></p>
<p style="padding-left: 30px">For a comprehensive description of Oracle wallet see <a href="https://docs.oracle.com/middleware/1213/wls/JDBCA/oraclewallet.htm#JDBCA599">here</a>.</p>
2. Add the following lines to <code>sqlnet.ora</code> file (this will disallow other types of authentication, which is why recommendation is to separate it from the usual <code>sqlnet.ora</code> and point <code>TNS_ADMIN</code> to this only for running of R scripts purposes).
<p style="padding-left: 30px"><code>
SQLNET.WALLET_OVERRIDE = TRUE
WALLET_LOCATION=(
SOURCE=(METHOD=FILE)
(METHOD_DATA=(DIRECTORY=C:\Oracle\admin\mywallet))
)</code></p>
3. Add the username and password to the wallet we created above:
<p style="padding-left: 30px"><code>mkstore -wrl C:\<span>oracle\admin\</span><span>my</span><span>wallet -createCredential &lt;TNS alias&gt; &lt;myuser&gt; &lt;mypassword&gt;</span></code></p>
<p style="padding-left: 30px"><em>(TNS alias is the alias from tnsnames.ora file)</em></p>
<p style="padding-left: 30px">Now we can test the wallet using <code>sqlplus</code>:</p>
<p style="padding-left: 30px"><code>sqlplus /@&lt;TNS alias&gt;</code></p>
<p style="padding-left: 30px">This should log you in on <code>sqlplus/SQL</code> prompt without asking for username or password.</p>
4. After you have setup the wallet you can connect to it from R script by specifying the TNS alias in the connection string along with driver for Oracle. Note that we specify the <code>DBQ</code> and <code>Driver</code> parameters in the connection string instead of usual <code>DSN</code> and <code>Provider</code>. Here is an example that tests it:
<p style="padding-left: 30px"><code>
sConnectionStr &lt;- "Driver={Oracle in OraClient12Home1};DBQ=&lt;TNS alias&gt;;"
checkDBversion &lt;- RxOdbcData(sqlQuery="SELECT BANNER FROM V$VERSION", connectionString = sConnectionStr, rowBuffering=FALSE)
rxGetInfo(checkDBversion, numRows = 1)
</code></p>
OUTPUT:
<p style="padding-left: 30px"><code>
Connection string: Driver={Oracle in OraClient12Home1};DBQ=&lt;TNS alias&gt;;
Data Source: ODBC
Data (1 row starting with row 1):
BANNER
1 Oracle Database 11g Express Edition Release 11.2.0.2.0 - 64bit Production
</code></p>

<h2>References:</h2>
Oracle Wallet Reference: <a href="https://docs.oracle.com/middleware/1213/wls/JDBCA/oraclewallet.htm#JDBCA599">https://docs.oracle.com/middleware/1213/wls/JDBCA/oraclewallet.htm#JDBCA599</a>

RxOdbcData Reference: <a href="https://msdn.microsoft.com/en-us/microsoft-r/scaler/packagehelp/rxodbcdata">https://msdn.microsoft.com/en-us/microsoft-r/scaler/packagehelp/rxodbcdata</a>]]></content:encoded>
    </item>
    <item>
      <title>Using RStudio Server with Microsoft R Server Parcel for Cloudera</title>
      <link>https://docs.microsoft.com/archive/blogs/microsoftrservertigerteam/using-rstudio-server-with-microsoft-r-server-parcel-for-cloudera</link>
      <pubDate>Sun, 30 Apr 2017 15:06:53 GMT</pubDate>
      <dc:creator><![CDATA[Ramkumar Chandrasekaran, Microsoft]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/microsoftrservertigerteam/?p=4305</guid>
      <description><![CDATA[In previous releases of Microsoft R Server, parcel installation required downloading two pre-built...]]></description>
      <content:encoded><![CDATA[In previous releases of Microsoft R Server, parcel installation required downloading two pre-built parcel files. The <a target="_blank" href="https://blogs.technet.microsoft.com/dataplatforminsider/2017/04/19/introducing-microsoft-r-server-9-1-release/">9.1 release</a> improves upon this experience by providing a parcel generator script generate_mrs_parcel.sh to generate a single MRS-9.1.0-*.parcel file. Here are the <a target="_blank" href="https://msdn.microsoft.com/en-us/microsoft-r/rserver-install-cloudera-generate-parcel">complete instructions</a> to install MRS Parcel in Cloudera Cluster.

In this article we will look into how to make <a target="_blank" href="https://www.rstudio.com/products/rstudio/download/">RStudio Server</a> (both Open and Commercial) work with <a target="_blank" href="https://msdn.microsoft.com/en-us/microsoft-r/rserver-install-cloudera">MRS 9.1.0 Parcel Installation in Cloudera</a>. RStudio Server has an open source license as well as commercial license. You can view the differences <a target="_blank" href="https://www.rstudio.com/products/rstudio/download/">here</a>. RStudio Server with commercial license is also called RStudio Server Pro.

The following steps assume that you already have a Cloudera Cluster with MRS-9.1.0 parcel installed and activated. These steps can be run on edgenode/gateway node of the cluster.
<ul>
 	<li>Download and install RStudio Server Pro from <a target="_blank" href="https://www.rstudio.com/products/rstudio/download-commercial/">here</a> (OR) RStudio Server Open Source License from <a target="_blank" href="https://www.rstudio.com/products/rstudio/download-server/">here</a>.</li>
</ul>
<strong>RStudio Server Open Source License :</strong>
<pre>wget https://download2.rstudio.org/rstudio-server-rhel-1.0.143-x86_64.rpm
sudo yum install --nogpgcheck rstudio-server-rhel-1.0.143-x86_64.rpm
sudo rstudio-server verify-installation
sudo rstudio-server version
</pre>
<img src="https://msdnshared.blob.core.windows.net/media/2017/04/rs0.png" alt="rs0" width="608" height="42" class="alignnone size-full wp-image-4365" />

<strong>RStudio Server Pro :</strong>
<pre>wget https://download2.rstudio.org/rstudio-server-rhel-pro-1.0.143-x86_64.rpm
sudo yum install --nogpgcheck rstudio-server-rhel-pro-1.0.143-x86_64.rpm
sudo rstudio-server verify-installation
sudo rstudio-server version
</pre>
<img src="https://msdnshared.blob.core.windows.net/media/2017/04/rs1.png" alt="rs1" width="590" height="43" class="alignnone size-full wp-image-4317" />
<ul>
 	<li>We need to set some environment variables at the start of R session. This can be achieved using Renviron file. Append the following lines to /opt/cloudera/parcels/MRS/lib64/R/etc/Renviron</li>
</ul>
<pre>LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/opt/cloudera/parcels/MRS/lib64/R/lib
R_LIBS=/opt/cloudera/parcels/MRS/lib64/R/library
MRS_PARCEL_PATH=/opt/cloudera/parcels/MRS</pre>
<ul>
 	<li>Create libjvm.so symlink</li>
</ul>
<pre>sudo ln -s /usr/java/jdk1.7.0_67-cloudera/jre/lib/amd64/server/libjvm.so /opt/cloudera/parcels/MRS/hadoop/libjvm.so</pre>
<ul>
 	<li>Copy RevoHadoopEnvVars.site file from home directory into hadoop directory. (NOTE: If .RevoHadoopEnvVars.site file is not present in the home directory , just run R command once - this will generate site file in home directory)</li>
</ul>
<pre>sudo cp ~/.RevoHadoopEnvVars.site /opt/cloudera/parcels/MRS/hadoop
sudo mv /opt/cloudera/parcels/MRS/hadoop/.RevoHadoopEnvVars.site /opt/cloudera/parcels/MRS/hadoop/RevoHadoopEnvVars.site
</pre>
<ul>
 	<li>Restart RStudio Server</li>
</ul>
<pre>sudo rstudio-server stop
sudo rstudio-server restart
</pre>
<img src="https://msdnshared.blob.core.windows.net/media/2017/04/rs2.png" alt="rs2" width="570" height="98" class="alignnone size-full wp-image-4326" />
<ul>
 	<li>RStudio Server will be available in the following url : http://&lt;nodename&gt;:8787. (Make sure port 8787 is open)</li>
</ul>
Let us run Microsoft R Server Examples on Local, Hadoop and Spark Compute Context using RStudio Server :
<h3>LOCAL COMPUTE CONTEXT</h3>
<script src="https://gist.github.com/ramnov/4d36276a2e69117dc1d6d8d9a8aaeb5e.js"></script>

<img src="https://msdnshared.blob.core.windows.net/media/2017/04/local.png" alt="local" width="1600" height="868" class="alignnone size-full wp-image-4335" />
<h3>LOCAL COMPUTE CONTEXT ON HDFS DATA</h3>
<script src="https://gist.github.com/ramnov/c5e65d176adadcabd3da87787490e8d2.js"></script>

<img src="https://msdnshared.blob.core.windows.net/media/2017/04/localhdfs.png" alt="localhdfs" width="1928" height="1048" class="alignnone size-full wp-image-4375" />
<h3>HADOOP COMPUTE CONTEXT</h3>
<script src="https://gist.github.com/ramnov/c41e1285676d95d7ec2a920212a4ea06.js"></script>

<img src="https://msdnshared.blob.core.windows.net/media/2017/04/hadoop.png" alt="hadoop" width="1600" height="868" class="alignnone size-full wp-image-4345" />
<h3>SPARK COMPUTE CONTEXT</h3>
<script src="https://gist.github.com/ramnov/f0ed6a3fab929f47564cf540f3f68a0c.js"></script>

<img src="https://msdnshared.blob.core.windows.net/media/2017/04/spark.png" alt="spark" width="1600" height="868" class="alignnone size-full wp-image-4346" />

&nbsp;

&nbsp;]]></content:encoded>
    </item>
    <item>
      <title>Stratified Splitting using rxExecBy</title>
      <link>https://docs.microsoft.com/archive/blogs/microsoftrservertigerteam/stratified-splitting-using-rxexecby</link>
      <pubDate>Sun, 23 Apr 2017 13:04:54 GMT</pubDate>
      <dc:creator><![CDATA[Ramkumar Chandrasekaran, Microsoft]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/microsoftrservertigerteam/?p=4285</guid>
      <description><![CDATA[In Microsoft R Server 9.1, we have a new function called rxExecBy() which can be used to partition...]]></description>
      <content:encoded><![CDATA[<span>In <a target="_blank" href="https://blogs.technet.microsoft.com/dataplatforminsider/2017/04/19/introducing-microsoft-r-server-9-1-release/">Microsoft R Server 9.1</a>, we have a new function called rxExecBy() which can be used to partition input data source by keys and apply user defined function on individual partitions. You can read more about rxExecBy() here : <a target="_blank" href="https://blogs.msdn.microsoft.com/rserver/2017/04/12/pleasingly-parallel-using-rxexecby/">Pleasingly Parallel using rxExecBy</a></span>

In this article, we will look at how to use rxExecby to perform <a target="_blank" href="https://en.wikipedia.org/wiki/Stratified_sampling">Stratified Splitting</a>. The training and test datasets contain a representative sample of the value in the <em>strata column</em> or <em>stratification key column</em>. With stratified splitting, the data is divided in such a way that a percentage of each target column value is put in both training and test dataset. This is used if the column you choose as the strata has categories that should be balanced. For example, you might want to balance by income, gender, etc. In stratified splitting, the strata column must contain nominal or categorical data. If the strata column you specify has continuous numeric data (or) has too many unique values, the column is not a good candidate for splitting over strata.

In the following example, we will split the AirlineDemoSmall XDF file into 75%  train and 25% test XDF stratifiying over the column DayOfWeek. After splitting, we will check the counts of each category of strata column DayOfWeek in train and test to verify the stratified split.

<script src="https://gist.github.com/ramnov/e3c6f193ec4d4b4da19534bbc401c985.js"></script>

<strong>OUTPUT:</strong>

<img width="607" height="140" class="alignnone wp-image-4295 size-full" alt="capture" src="https://msdnshared.blob.core.windows.net/media/2017/04/Capture8.png" />]]></content:encoded>
    </item>
    <item>
      <title>New Features in 9.1: Microsoft R Server with sparklyr Interoperability</title>
      <link>https://docs.microsoft.com/archive/blogs/microsoftrservertigerteam/new-features-in-9-1-microsoft-r-server-with-sparklyr-interoperability</link>
      <pubDate>Wed, 19 Apr 2017 07:55:09 GMT</pubDate>
      <dc:creator><![CDATA[Kirill Glushko, Microsoft]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/microsoftrservertigerteam/?p=3425</guid>
      <description><![CDATA[Introduction
With the launch of Microsoft R Server 9.1, many optimizations and new features were...]]></description>
      <content:encoded><![CDATA[<img width="638" height="96" class="alignright size-full wp-image-4275" alt="mrs_heart_sparklyr" src="https://msdnshared.blob.core.windows.net/media/2017/04/mrs_heart_sparklyr.png" />
<h1>Introduction</h1>
With the launch of <a href="https://blogs.technet.microsoft.com/dataplatforminsider/2017/04/19/introducing-microsoft-r-server-9-1-release/">Microsoft R Server 9.1</a>, many optimizations and new features were delivered to our users. One key feature is interoperability between Microsoft R Server and sparklyr.

<a href="https://cran.r-project.org/package=sparklyr">sparklyr</a>, a package by RStudio, is an R interface to Apache Spark. It allows users to utilize Spark as the backend for dplyr, one of the most popular data manipulation packages. sparklyr also provides interfaces to Spark packages, allows users to query data in Spark using SQL, and develop extension in R by creating an interface to the full Spark API. Another key feature is it allows users the ability to use Spark integrated Machine Learning algorithms directly from within R. For H2O users, the Microsoft R Server sparklyr Interop can be used to covert sparklyr data frames to H2O data frames. This allows data imported from Microsoft R Server to be used with H2O modelling and data partitioning algorithms, via the rsparkling package. (to learn more about dplyr, please visit their CRAN site <a href="https://cran.r-project.org/package=dplyr">here</a>.)

Microsoft R Server and sparklyr can now be used in tandem within a single Spark session. With this, Data Scientists and Solution Engineers can use all features of Microsoft R Server advanced Machine Learning algorithms on data prepared using the dplyr grammar.
<h1>Using Microsoft R Server with sparklyr</h1>
Prerequisites:
<ul>
 	<li>A Hadoop cluster with Spark and valid installation of Microsoft R Server</li>
 	<li>Microsoft R Server is configured for use with Hadoop and Spark (Instructions <a href="https://msdn.microsoft.com/en-us/microsoft-r/rserver-install-hadoop">here</a>)</li>
 	<li>Microsoft R Server SampleData loaded into HDFS</li>
 	<li>gcc and g++ installed on the edgenode that the example will be run on</li>
 	<li>Write permissions to the R Library Directory</li>
 	<li>Read/Write permissions to HDFS directory /user/RevoShare</li>
 	<li>An internet connection or the ability to download and manually install sparklyr and h2o</li>
</ul>
<em>Note: if you are unfamiliar with using Microsoft R Server with Spark, please see <a href="https://msdn.microsoft.com/en-us/microsoft-r/scaler-spark-getting-started">here</a>.
</em>
<em>Note: To load SampleData into HDFS, please use one of the following was to load SampleData:</em>

Microsoft R Server Functions:
<script src="https://gist.github.com/kiglus/3f20f09dfe6833658f4f64c18bdcc8d2.js"></script>
Shell Script:
<script src="https://gist.github.com/kiglus/6fbc6c6d78d38adbb22e06b80f75b869.js"></script>
<h3>Installation of sparklyr package</h3>
If you on HDI, please install the sparklyr package in the following way:

<b><span style="color: #000000;font-family: Calibri">options(repos = "</span><a href="https://mran.microsoft.com/snapshot/2017-05-01"><span style="color: #0563c1;font-family: Calibri">https://mran.microsoft.com/snapshot/2017-05-01</span></a><span style="color: #000000;font-family: Calibri">")</span></b>

<b><span style="color: #000000;font-family: Calibri">install.packages("sparklyr")</span></b>

If you are not on HDI, please install in the following way:

<span style="color: #000000;font-family: Calibri"><b>install.packages("sparklyr")</b></span>
<h3>Example One: Load and Partition Data in sparklyr, Train and Predict in MRS</h3>
In this example, we will:
<ol>
 	<li>Create a connection to Spark using rxSparkConnect(), specifying a sparklyr interop; using sparklyr and its interfaces to connect to Spark.</li>
 	<li>Call rxGetSparklyrConnection() on the compute context to get a sparklyr connection object.</li>
 	<li>We will use dplyr to load mtcars into a Spark DataFrame via the sparklyr connection object.</li>
 	<li>Partition the data in-Spark into a training and scoring set using dplyr.</li>
 	<li>After partitioning, we will register the training set DataFrame in Spark to a Hive table.</li>
 	<li>Train a model in ScaleR using rxLinMod() on an RxHiveData() object.</li>
 	<li>With that trained model, well will run a toy prediction using rxPredict() on the test partition.</li>
 	<li>After prediction, take the root mean square to determine accuracy.</li>
</ol>
<em>Note: We will use the Standard R dataset mtcars for this example, for more information, please see <a href="https://stat.ethz.ch/R-manual/R-devel/library/datasets/html/mtcars.html">here</a>.</em>

<strong>Sample Code</strong>

<script src="https://gist.github.com/kiglus/07852da6b91b07ddd2d7594c4c289676.js"></script>

<strong>Sample Output, Comments Removed</strong>

<script src="https://gist.github.com/kiglus/1a6257e9c296e490649a9de219dd1ac1.js"></script>
<h3>Example Two: Load Data with MRS, Partition and Train a Model with sparklyr</h3>
In this example, we will:
<ol>
 	<li>Create a connection to Spark using rxSparkConnect(), specifying a sparklyr interop; using sparklyr and its interfaces to connect to Spark.</li>
 	<li>Call rxGetSparklyrConnection() on the compute context to get a sparklyr connection object.</li>
 	<li>Use Microsoft R Server to load data from many sources</li>
 	<li>Partition the data in-Spark into a training and scoring set using dplyr.</li>
 	<li>After partitioning, we will register the training set DataFrame in Spark to a Hive table.</li>
 	<li>Train a model using sparklyr to call Spark ML algorithms</li>
 	<li>Take a summary of the trained model to see estimates and errors</li>
</ol>
<strong>Sample Code</strong>

<script src="https://gist.github.com/kiglus/1acaa48ffcbeacdfca7817b7361bd873.js"></script>

<strong>Sample Output, Comments Removed</strong>

<script src="https://gist.github.com/kiglus/273436cfd8ad071bcf199a53ccf46112.js"></script>
<h3>Example Three: Connect to Spark and Load Data with MRS, Cache Data with dplyr, Train a Model and Predict with H2O, Gather Metrics with MRS</h3>
In this example, we will:
<ol>
 	<li>Create a connection to Spark using rxSparkConnect(), specifying a sparklyr interop; using sparklyr and its interfaces to connect to Spark.</li>
 	<li>Call rxGetSparklyrConnection() on the compute context to get a sparklyr connection object.</li>
 	<li>Use Microsoft R Server to load Training and Test Data from HDFS</li>
 	<li>Represent the Data as Hive Tables, and Cache the Tables in Spark</li>
 	<li>Cast the data to h2o data frames for analysis</li>
 	<li>Train a model using h2o's built in GLM algorithm</li>
 	<li>Print the model data</li>
 	<li>Run a prediction on the test data with h2o.predict</li>
 	<li>Take the ROC and Area Under the Curve (AUC) to see how our model did</li>
</ol>
<em>Note: In the call to rxSparkConnect, we define numExecutors, executorCores, and executorMem. These are the minimum requirements to run this example. Allocating less memory to the Spark App may cause a hang on the call to as_h2o_frame().</em>

<strong>Sample Code</strong>

<script src="https://gist.github.com/kiglus/fb5d1a0edc3b1ad5ccd386a5adcd6d21.js"></script>

<strong>Sample Output, Comments Removed</strong>

<script src="https://gist.github.com/kiglus/baab8cf58945de165b51fc88a78e54ba.js"></script>

&nbsp;
<h1>Conclusion</h1>
The ability to use both Microsoft R Server and sparklyr from within one Spark session will allow Microsoft R Server users to quickly and seamlessly utilize features provided by sparklyr within their solutions.

-----

Author: Kirill Glushko, Premal Shah

For a comprehensive view of all the capabilities in Microsoft R Server 9.1, refer to <a href="https://blogs.technet.microsoft.com/dataplatforminsider/2017/04/19/introducing-microsoft-r-server-9-1-release">this blog</a>]]></content:encoded>
    </item>
    <item>
      <title>SQL Saturday 613: Building 1 million predictions per second with R-services and SQL Server 2016</title>
      <link>https://docs.microsoft.com/archive/blogs/microsoftrservertigerteam/sql-saturday-613-building-1-million-predictions-per-second-with-r-services-and-sql-server-2016</link>
      <pubDate>Wed, 12 Apr 2017 21:02:02 GMT</pubDate>
      <dc:creator><![CDATA[Amit Banerjee]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/microsoftrservertigerteam/?p=4105</guid>
      <description><![CDATA[SQL Saturday is round the corner again! SQL Saturday is a great event to meet the community, gather...]]></description>
      <content:encoded><![CDATA[<p><a href="https://msdnshared.blob.core.windows.net/media/2017/04/image318.png"><img title="image" style="border-left-width: 0px;border-right-width: 0px;border-bottom-width: 0px;float: left;padding-top: 0px;padding-left: 0px;padding-right: 0px;border-top-width: 0px" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/2017/04/image_thumb308.png" width="240" align="left" height="114"></a></p> <p>SQL Saturday is round the corner again! SQL Saturday is a great event to meet the community, gather feedback and meet some great friends that we made during our last few SQL Saturdays. This time the Tiger team will be presenting a session on how to use R-Services with SQL Server to build an analytical workflow for banking solutions. We will talk about how our customer Jack Henry &amp; Associates, an S&amp;P 400 company that supports more than 11,300 financial institutions with core processing services, is leveraging the power of SQL Server and R to make drive intelligent insights into their data warehousing software. Post the session, I will share a complete solution which you can deploy on our <a href="https://azuremarketplace.microsoft.com/en-us/marketplace/partners/microsoft-ads/standard-data-science-vm/">Data Science Virtual Machine</a> on Azure and tinker around with the demo solution at your free time. </p> <p>Our Corporate Vice President, Joseph Sirosh, had demonstrated this solution along with Jack Henry &amp; Associates at <a href="https://blogs.technet.microsoft.com/dataplatforminsider/2016/10/11/1000000-predictions-per-second/">Ignite</a>. In this session, I will talk about the nuts and bolts on how to build a scalable predictive engine with SQL Server and using the enhancements shipped in SQL Server 2016. After this session, you will be able to build your very own scalable predictive engine on SQL Server 2016!</p> <p><strong>Title: <strong>Building 1 million predictions per second using SQL-R [<a href="http://www.sqlsaturday.com/613/Sessions/Details.aspx?sid=61018">Session Link</a>]</strong></strong></p> <p><strong>When: 15th April, 2017 | 2:45PM – 3:45PM PST</strong></p> <p><strong>Where: Building 92, 15010 NE 36th St, Redmond (Room: Utopia)</strong></p> <p><strong>Abstract</strong>: <em>Using the power of OLTP and data transformation in SQL 2016 and advanced analytics in Microsoft R Server, various industries really push the boundary of processing higher number of transaction per second (tps) for different use cases. In this talk, we will walk through the use case of predicting loan charge off (loan default) rate, architecture configuration that enable this use case, and rich visual dashboard that allow customer to do what-if analysis. Attend this session to find out how SQL + R allows you to build an "intelligent datawarehouse".</em> </p> <p>My colleague, Pedro Lopes, will be presenting a session on “<a href="http://www.sqlsaturday.com/613/Sessions/Details.aspx?sid=57862">Enhancements that will make your SQL database roar</a>”.</p> <p>Looking forward to meet the community this Saturday!</p> <p>The slide deck used for my presentation can be found on <a href="https://www.slideshare.net/banerjeeamit/building-1-million-predictions-per-second-using-sqlr">SlideShare</a>. The PowerBI dashboard and the demo scripts can be downloaded from the <a href="https://github.com/Microsoft/sql-server-samples/tree/master/samples/features/r-services/loan-classification">tigertoolbox</a> repo on GitHub.</p>]]></content:encoded>
    </item>
    <item>
      <title>Logging in Microsoft R Server Engine</title>
      <link>https://docs.microsoft.com/archive/blogs/microsoftrservertigerteam/logging-in-microsoft-r-server-engine</link>
      <pubDate>Tue, 11 Apr 2017 19:31:13 GMT</pubDate>
      <dc:creator><![CDATA[Eqbal Zaffar]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/microsoftrservertigerteam/?p=4065</guid>
      <description><![CDATA[With Microsoft R Server 9.1 release we have made improvements that can help us better diagnose and...]]></description>
      <content:encoded><![CDATA[With <a href="https://blogs.technet.microsoft.com/dataplatforminsider/2017/04/19/introducing-microsoft-r-server-9-1-release/">Microsoft R Server 9.1 release</a> we have made improvements that can help us better diagnose and troubleshoot problems that can occur in a customer's deployments. If you run into any errors/issues with Microsoft R Server and contact Microsoft support you might be asked to collect BxlServer logs in addition to other information. This blog describes how to enable and collect logs for various compute contexts that can be shared with Microsoft support.
<h1>How to enable logging</h1>
Enable logging for RevoScaleR package is very simple. We use the rxOptions function to set the traceLevel parameter:

<b><code>rxOptions(traceLevel=&lt;level&gt;)</code></b>

Logging has the following levels defined
<table border="1">
<tbody>
<tr>
<td><b>traceLevel value</b></td>
<td><b>Logging level</b></td>
<td><b>Description</b></td>
</tr>
<tr>
<td>0</td>
<td>NONE</td>
<td>By default logging is disabled</td>
</tr>
<tr>
<td>1</td>
<td>ERROR</td>
<td>Error messages are logged</td>
</tr>
<tr>
<td>2</td>
<td>WARN</td>
<td>Warning log messages are logged</td>
</tr>
<tr>
<td>3</td>
<td>INFO</td>
<td>Informational log messages are logged</td>
</tr>
<tr>
<td>4</td>
<td>DEBUG</td>
<td>More granular debug messages are logged</td>
</tr>
<tr>
<td>5</td>
<td>Reserved</td>
<td>currently treated as DEBUG</td>
</tr>
<tr>
<td>6</td>
<td>Reserved</td>
<td>currently treated as DEBUG</td>
</tr>
<tr>
<td>7</td>
<td>R runtime tracing enabled</td>
<td>This level also enables some detailed call trace output in R code that implements the RevoScaleR functions. In the engine it is treated same as DEBUG</td>
</tr>
</tbody>
</table>
&nbsp;
<h1>Log file locations</h1>
Once you enable logging and run your RevoScaleR computation, the next step is to collect the logs from various nodes involved in the computation for the particular RevoScaleR function. The logs are written to specific places on the node where computation takes place and varies by what compute context is specified for the computation. The naming of the log files follows the following convention:

Client - <code>BxlServer.client.&lt;processid&gt;.log</code>

Master - <code>BxlServer.master.&lt;processid&gt;.log</code>

Worker - <code>BxlServer.worker.&lt;processid&gt;.log</code>

On Hadoop we also have files that indicate whether the files was generated through by map or reduce phase of the computation

Worker mapper - <code>BxlServer.mapper.&lt;processid&gt;.log</code>

Worker reducer - <code>BxlServer.reducer.&lt;processid&gt;.log</code>

&nbsp;
<h2>Local Compute Context</h2>
For local compute context the log files are written to the R temp directory (output of <code>tempdir</code> function call), this could be a directory similar to <code>/tmp/RtmpMLrRiq</code> on Linux for example or <code>C:\TEMP\RtmpMLrRiq</code> on Windows. Below is an example from Linux

<code>[dev@host-client ~]$ ll -rth /tmp/RtmpMLrRiq/</code>

<code>total 0</code>

<code>-rw-rw-r-- 1 dev dev 0 Mar 15 10:54 BxlServer.client.45379.log</code>

&nbsp;
<h2>Distributed compute contexts</h2>
Since the computations in a distributed compute context could take place on multiple different nodes, we have various ways to find and collect the log files depending on which compute context you are using. For all the compute context there is a client R process that's either running on a user's desktop or on an edge node (in case of a Hadoop cluster) and the client communicates with the cluster based on where it's executing. In all cases there is a job directory (with a GUID name) that is used to store various files that are required for the computation. Once the computation is complete the log files from various nodes are collected into the job directory for the client R process (except in case of Hadoop, see following section). You can get the client job GUID folder using the following object in your R session:

<code>rxgLastPendingJob@clientGUIDDir</code>

&nbsp;
<h3>RxHadoopMR and RxSpark</h3>
For Hadoop cluster client R process can be either running on your desktop or on the edge node. If you are on a desktop ssh is used in the background to communicate with an edge node. If you are directly on an edge node of the cluster then no ssh is required.

&nbsp;
<h4>Client (when not on edge node):</h4>
Below is an example script to demonstrate the logging output

<script src="https://gist.github.com/eqbalz/673dce2c57cb92b85c69f3ab7e70f349.js"></script>

&nbsp;

You can then check the <code>shareDir/&lt;GUID&gt;</code> (<code>shareDir</code> is a parameter for the compute context):

<code>C:\ClientShareDir\43E70EA1D18F41AF88DADF13E5156590&gt; dir</code>

<code>Directory: C:\ClientShareDir\43E70EA1D18F41AF88DADF13E5156590</code>

<code>Mode                LastWriteTime     Length Name</code>
<code>----                -------------     ------ ----</code>
<code>-a---         3/15/2017  11:29 AM       1427 0.RInData</code>
<code>-a---         3/15/2017  11:31 AM         31 <span style="color: #0000ff">applicationIds.txt</span></code>
<code>-a---         3/15/2017  11:31 AM       1445 <span style="color: #0000ff">BxlServer.client.74204.log</span></code>
<code>-a---         3/15/2017  11:30 AM       4256 <span style="color: #0000ff">BxlServer.master.53954.log</span></code>
<code>-a---         3/15/2017  11:29 AM        906 cleanupHadoopMRJob.sh</code>
<code>-a---         3/15/2017  11:29 AM       1415 createOutfileChunk.sh</code>
<code>-a---         3/15/2017  11:30 AM       1565 DEV_VM1.ROutData</code>
<code>-a---         3/15/2017  11:29 AM       1448 getHadoopStatus.sh</code>
<code>-a---         3/15/2017  11:29 AM         26 input.R</code>
<code>-a---         3/15/2017  11:29 AM          6 jobIdentifier.txt</code>
<code>-a---         3/15/2017  11:29 AM      16523 jobInfo.RData</code>
<code>-a---         3/15/2017  11:30 AM          9 jobStatus.txt</code>
<code>-a---         3/15/2017  11:29 AM       1397 killRemoteJob.sh</code>
<code>-a---         3/15/2017  11:31 AM          0 lastOutputBlock.txt</code>
<code>-a---         3/15/2017  11:30 AM       5450 MergedOut0.txt</code>
<code>-a---         3/15/2017  11:29 AM       2049 run-r.sh</code>

&nbsp;
<h4>On Edge node:</h4>
The master R process log file is in the cluster GUID folder (usually under <code>/var/RevoShare</code> by default and can be changed using <code>shareDir</code> parameter of the compute context). We also write another file called <code>applicationIds.txt</code> that contains the applicationIds of the YARN jobs that have been submitted to the cluster as part of the computation (this will be useful in getting worker logs, see further below). At the end of the computation the files are copied over to the client process' GUID dir (<code>rxgLastPendingJob@clusterGUIDDir</code>)

<code>[dev@dev-vm1 ~]$ ll -rth /tmp/474DBA206AA144A99025F79D8248C960</code>
<code>total 80</code>
<code>-rw-rw-r-- 1 dev dev  1317 Apr 12 13:04 0.RInData</code>
<code>-rw-rw-r-- 1 dev dev    31 Apr 12 13:05 <span style="color: #0000ff">applicationIds.txt</span></code>
<code>-rw-rw-r-- 1 dev dev  1785 Apr 12 13:05 <span style="color: #0000ff">BxlServer.client.3853.log</span></code>
<code>-rw-rw-r-- 1 dev dev  6018 Apr 12 13:05 <span style="color: #0000ff">BxlServer.master.4521.log</span></code>
<code>-rw-rw-r-- 1 dev dev   904 Apr 12 13:04 cleanupHadoopMRJob.sh</code>
<code>-rw-rw-r-- 1 dev dev  1411 Apr 12 13:04 createOutfileChunk.sh</code>
<code>-rw-rw-r-- 1 dev dev  1562 Apr 12 13:05 DEV_VM.ROutData</code>
<code>-rw-rw-r-- 1 dev dev  1609 Apr 12 13:04 getHadoopStatus.sh</code>
<code>-rw-rw-r-- 1 dev dev    24 Apr 12 13:04 input.R</code>
<code>-rw-rw-r-- 1 dev dev     5 Apr 12 13:04 jobIdentifier.txt</code>
<code>-rw-rw-r-- 1 dev dev 16247 Apr 12 13:04 jobInfo.RData</code>
<code>-rw-rw-r-- 1 dev dev     9 Apr 12 13:05 jobStatus.txt</code>
<code>-rw-rw-r-- 1 dev dev  1349 Apr 12 13:04 killRemoteJob.sh</code>
<code>-rw-rw-r-- 1 dev dev     0 Apr 12 13:05 lastOutputBlock.txt</code>
<code>-rw-rw-r-- 1 dev dev  5505 Apr 12 13:05 MergedOut0.txt</code>
<code>-rw-rw-r-- 1 dev dev  2030 Apr 12 13:04 run-r.sh</code>

&nbsp;

The client R process log for edge nodes are under <code>tempdir</code> location.
<h4>Worker node logs:</h4>
For Hadoop worker node processes are managed through YARN containers and as such the logs are written to yarn log directories for the respective containers. To collect the logs from worker nodes we need to use "yarn logs -applicationId &lt;applicationId&gt; command. The applicationId can be obtained from the applicationIds.txt file as shown above (there can be more than one applicationId written to the file depending on if multiple iterations are required).

&nbsp;

NOTE: yarn logs command will return stdout, stderr, sysout logs as well. Look for log type BxlServer.*.log

<code>[dev@dev-vm1 ~]$ cat /var/RevoShare/dev/cluster-F6AABFC81FAC4E36BA1B28C1881A532A/applicationIds.txt</code>
<code>application_1489107491981_0320</code>

<code>[dev@dev-vm1 ~]$ yarn logs -applicationId application_1489107491981_0320 &gt; yarn-logs.txt</code>

<code>17/03/15 11:12:58 INFO client.RMProxy: Connecting to ResourceManager at dev-vm1/102.123.215.107:8032</code>

<code>[dev@dev-vm1 ~]$ vi yarn-logs.txt</code>
<code>Container: container_1489107491981_0320_01_000002 on dev-vm3.sys-sqlsvr.local_8041</code>
<code>=========================================================================================</code>
<span style="color: #ff0000"><code><span style="color: #0000ff">LogType:BxlServer.mapper.59762.log</span></code></span>
<code>Log Upload Time:Wed Mar 15 10:53:00 -0700 2017</code>
<code>LogLength:1685</code>
<code>Log Contents:</code>
<code>[2017-03-15.10:52:28.438.464][ INFO]Logging configuration completed.  traceLevel=4 process type=WORKER_MAP log dir=/var/log/hadoop-yarn/container/application_148910749198</code>
<code>1_0320/container_1489107491981_0320_01_000002</code>
<code>[2017-03-15.10:52:28.441.100][DEBUG]Server Reserved Memory size=10485760</code>
<code>[2017-03-15.10:52:28.441.429][ INFO]RxUtil request received USE=HdfsConnect</code>
<code>[2017-03-15.10:52:31.630.485][DEBUG]Server Reserved Memory size=10485760</code>
<code>[2017-03-15.10:52:31.630.714][ INFO]RxUtil request received USE=SetSplitInfo</code>
<code>[2017-03-15.10:52:31.634.074][DEBUG]Server Reserved Memory size=10485760</code>
<code>[2017-03-15.10:52:31.634.285][ INFO]RxUtil request received USE=ComputeHadoopTask</code>

<code>Container: container_1489107491981_0320_01_000003 on dev-vm3.sys-sqlsvr.local_8041</code>
<code>=========================================================================================</code>
<span style="color: #ff0000"><code><span style="color: #0000ff">LogType:BxlServer.reducer.60310.log</span></code></span>
<code>Log Upload Time:Wed Mar 15 10:53:00 -0700 2017</code>
<code>LogLength:741</code>
<code>Log Contents:</code>
<code>[2017-03-15.10:52:48.438.501][ INFO]Logging configuration completed.  traceLevel=4 process type=WORKER_REDUCE log dir=/var/log/hadoop-yarn/container/application_148910749</code>
<code>1981_0320/container_1489107491981_0320_01_000003</code>
<code>[2017-03-15.10:52:48.440.055][DEBUG]Server Reserved Memory size=10485760</code>
<code>[2017-03-15.10:52:48.440.441][ INFO]RxUtil request received USE=HdfsConnect</code>
<code>[2017-03-15.10:52:51.699.914][DEBUG]Server Reserved Memory size=10485760</code>
<code>[2017-03-15.10:52:51.700.103][ INFO]RxUtil request received USE=UpdateIRO</code>
<code>[2017-03-15.10:52:51.702.203][DEBUG]Server Reserved Memory size=10485760</code>
<code>[2017-03-15.10:52:51.702.385][ INFO]RxUtil request received USE=WriteIRO</code>
<code>[2017-03-15.10:52:52.431.104][ NONE]Shutting Down Log Processing</code>

&nbsp;
<h3>Teradata</h3>
All Log files for master and worker processes are aggregated into the client GUID directory on the R client. The number of worker logs is determined by the number of AMP nodes in your Teradata system.
Below is an example of how you can setup <code>RxInTeradata</code> compute context

<script src="https://gist.github.com/eqbalz/c6cb5cc58d6264c399f55a679945c676.js"></script>

After running your script you can check the shareDir for log files

<code>PS C:\&gt; dir C:/User//Documents/A0A8235B879E4AAB94E937C9666541C8</code>

<code>    Directory: C:\User\\Documents\A0A8235B879E4AAB94E937C9666541C8</code>

<code>Mode                LastWriteTime     Length Name</code>
<code>----                -------------     ------ ----</code>
<code>-a---         4/12/2017   3:18 PM       1073 0.RInData</code>
<code>-a---         4/12/2017   3:18 PM      47163 <span style="color: #0000ff">BxlServer.client.10128.log</span></code>
<code>-a---         4/12/2017   3:18 PM       5778 <span style="color: #0000ff">BxlServer.master.22047.log</span></code>
<code>-a---         4/12/2017   3:18 PM       4953 <span style="color: #0000ff">BxlServer.worker.24278.log</span></code>
<code>-a---         4/12/2017   3:18 PM       4953 <span style="color: #0000ff">BxlServer.worker.24280.log</span></code>
<code>-a---         4/12/2017   3:18 PM        285 input.R</code>
<code>-a---         4/12/2017   3:18 PM      15439 jobInfo.RData</code>
<code>-a---         4/12/2017   3:18 PM         33 MasterOut.txt</code>
<code>-a---         4/12/2017   3:18 PM        218 MergedOut0.txt</code>
<code>-a---         4/12/2017   3:18 PM        218 MergedOut1.txt</code>
<code>-a---         4/12/2017   3:18 PM       2897 sample-ds1.xdf</code>
<code>-a---         4/12/2017   3:18 PM       3969 tdIn.zip</code>
<code>-a---         4/12/2017   3:18 PM       1342 DEVTD_VM.ROutData</code>

&nbsp;
<h3>SQL Server</h3>
All log files for client, master and worker processes are aggregated into client GUID directory on client. Below is an example:

<script src="https://gist.github.com/eqbalz/320e8883db036450516b7782a7730aa3.js"></script>

After running the example you can check the log files in the <code>shareDir/&lt;GUID&gt; directory</code>

<code>C:\Users\dev\AppData\Local\Temp\RevoJobs\8C25E32014EE468AAC3F036D1FC2FD6E&gt;ls -la</code>

<code>total 53</code>

<code>drwx------+ 1 4294967295 dev     0 Mar 15 13:34 .</code>
<code>drwx------+ 1 4294967295 dev     0 Mar 15 13:34 ..</code>
<code>-rwx------+ 1 4294967295 dev   988 Mar 15 13:34 0.RInData</code>
<code>-rwx------+ 1 4294967295 dev   159 Mar 15 13:34 <span style="color: #0000ff">BxlServer.client.461160.log</span></code>
<code>-rwx------+ 1 4294967295 dev   242 Mar 15 13:34 <span style="color: #0000ff">BxlServer.master.520864.log</span></code>
<code>-rwx------+ 1 4294967295 dev   242 Mar 15 13:34 <span style="color: #0000ff">BxlServer.worker.349880.log</span></code>
<code>-rwx------+ 1 4294967295 dev  1146 Mar 15 13:34 MergedOut.txt</code>
<code>-rwx------+ 1 4294967295 dev   478 Mar 15 13:34 DEV_DESKTOP.ROutData</code>
<code>-rwx------+ 1 4294967295 dev 15388 Mar 15 13:34 jobInfo.RData</code>
<code>-rwx------+ 1 4294967295 dev  1944 Mar 15 13:34 results.zip</code>
<code>-rwx------+ 1 4294967295 dev     3 Mar 15 13:34 state.txt</code>
<code>-rwx------+ 1 4294967295 dev  1235 Mar 15 13:34 tdIn.zip</code>

With more logging in Microsoft R Server we can get a better picture of analytics execution pipeline and this can greatly help with troubleshooting issues by Microsoft when required. Hopefully this blog clarified the way you can collect logs to share with Microsoft support in case you need any help. Feel free to comment if there are any questions.

For a comprehensive view of all the capabilities in Microsoft R Server 9.1, refer to <a href="https://blogs.technet.microsoft.com/dataplatforminsider/2017/04/19/introducing-microsoft-r-server-9-1-release">this blog</a>]]></content:encoded>
    </item>
  </channel>
</rss>