R Programming using RTVS – Part 3

This article assumes that you have RTVS extension added to your VS IDE.  You can refer my previous blogs on installation & configuration of RTVS.

  1. R Support in Visual Studio (RTVS)
  2. R Programming using RTVS – Part 2
1. Basic knowledge of R programming
2. RTVS Extension

Key RTVS features that a developer should be aware of :

The following is just a list for you to explore rather than extensive walk through.

  1. Step through :  use Ctrl+Enter
  2. Execute a block of code in R interactive  : Select a block of code and Ctrl+ Enter (or right click and choose Execute in Interactive)
  3. Debug : Use Debug > Source startup file or F5
  4. Set Debug points : Native VS behavior (refer image below)rtvs_5_r_debug.png
  5. Reset current work space : To clear everything by using R Tools > Session > Reset
  6. Examine variables : Use ‘variable explorer’ (Ctrl + 8)
  7. IntelliSense : RTVS_5_R_IntelliSense
  8. Help : Use ? and ?? (Use ?? to search term in quotes if it include spaces)
  9. Code snippet manager :  View them at Tools > Code Snippets Manager.  RTVS_5_R_CodeSnipptType the abbreviated name and use tab to insert a snippet to your codeRTVS_5_R_CodeSnippt1
  10.  R interactive window or REPL (Read-Evaluate-Print-Loop) window : Use already illustrated in previous steps/posts
  11. Plot window : Ctrl + 6
  12. Plot history : Preserves all your plots in the session.  R Tools > Plots > Plot History Window (refer image below)RTVS_5_R_Plot_history

There are many more which an R programmer or VS developer can explore themselves. We will go through some samples using RTVS in the upcoming posts.

R Programming using RTVS – Part 2

This article assumes that you have RTVS extension added to your VS IDE.  You can refer my previous blog on installation & configuration of RTVS.

1. Basic knowledge of R programming
2. RTVS Extension

Once you install ‘Data Science and Analytical Applications’ workload using VS2017 installer (May 2017 update), new R Project template will be available for creating new project.


Those who are familiar with R Studio will certainly find themselves home with this IDE. Additionally we have all VS native features. Given below is a view that shows Solution Explorer, Script file (Script.R) and Interactive Window (Microsoft R Client which is equivalent to console in R Studio)


Notice that there is an ‘R Plot’ tab which is where the plots/visualizations will be generated.

To start with lets draw a basic plot

ds <- c(1,500,300,100,350)


Alternately use the normal VS debug (starting new instance) and watch the interactive window as the plot is generated.

ds <- c(1,500,300,100,350) > plot(ds)
> rtvs::debug_source("~/visual studio 2017/Projects/rproject1/rproject1/script.R")
Sourcing: c:\users\geek2\documents\visual studio 2017\Projects\rproject1\rproject1\script.R

That’s basic start. I recommend R developers to explore the VS menu “R Tools” for the complete set of R integration options available.

R Support in Visual Studio (RTVS)

If you are a visual studio developer who is also into data analytics and R development, there is good news for you. The support for R and Python development is currently available in Visual Studio.

R Tools for Visual Studio (RTVS) is a free open-source extension for Visual Studio. This is supported in VS 2017 (community, enterprise and pro editions) and VS 2015 update 3 or higher.

To install it, select the ‘Data science and analytical applications workload’ in the installer.


Note the default options selected on right pane. For R development, ensure that you have selected the following items (minimum requirement)

  1. R language support
  2. Runtime support for R development
  3. Microsoft R client.

This will install RTVS extension and once completed you will see ‘R Project’ as a template in VS. I’m excited to share VS experience (R Projects, intellisense, plot view and many) for R development. I will go through integrated development features in upcoming blogs.

Data Analytics using Tableau

Though we discussed extensively about SAP Business Objects w.r.t business intelligence tools, I could not get a chance to write about Tableau visualizations till now. Not a great thing considering that my experiments with Tableau started way back in 2012 with Tableau version 7.0 (it wasn’t as popular as today, but it was clearly emerging as a leader). Tableau is one of the best visualizations tool that I have experienced and you can’t stop admiring its performance (thanks to in-memory processing of data), interactivity and analytics options (trends and forecasts).

Starting with a few visualizations from my PC. We will explore specific features and steps in later blogs.

Lets analyze data of a company (data source: Local SQL Server database). As you see the sales and profits are declining. I have added a trend line for its sales. This shows a consistent fall and its time for the company to do something serious to revive the business, isn’t it?


Sometimes a different visualization is what the need of the hour to convey the same data. How about a packed bubble visualization with the sizes corresponding to Yearly sales. Note that the data is categorized further by Divisions (company locations)


And my favorite Geo Maps


We will dig into its analytic features and Tableau Online in the upcoming posts.

Docker Integration for Visual Studio Developers

Containerization using Docker

As implementation of solutions based on micro services and containerization are growing like never before, it is important for us to weigh the advantages.  As we know, Docker in this area has gone way ahead of others. Even though it evolved as a container solution based on Linux, of late native support for Docker has been released in Windows Server 2016 and Windows 10 OS.

Docker for Visual Studio Developers


Support for Docker is available in Visual Studio 2017. To build, run and debug your applications from VS in Docker container, you should install Docker for Windows (https://docs.docker.com/docker-for-windows/install/) installed on your PC in addition to Visual Studio 2017.

Once installed, you can specify the option as below to enable Docker support while creating your project. Alternately you can right click on the particular project in solution explorer and use Add->Docker Support.


Visual studio integration adds the following files to your project

  • Dockerfile – build instructions for the image

Compose Files (to define and run multi-container applications with Docker)

  • Docker-compose.yml
  • Docker-compose.dev.debug.yml
  • Docker-compose.dev.release.yml

The docker-compose.yml file contains the name of the image that is created when project is run

version: '2'
 image: microsoft/aspnetcore-build:1.1.0-msbuild
 - .:/src
 working_dir: /src
 command: /bin/bash -c "dotnet restore && dotnet publish -c Release -o ./bin/Release/PublishOutput"

Sample Dockerfile

FROM microsoft/aspnetcore:1.1
ARG source
COPY ${source:-obj/Docker/publish} .
ENTRYPOINT ["dotnet", "MyDockerApplication.dll"]

Configure Puppet Enterprise master and agent for your Azure VMs

In my previous blog, we have seen usage of DSC scripts to install and maintain configuration across VM sets in Azure. Azure is flexible that it provides the option to make advantage of Puppet Enterprise.  Windows azure offers Puppet Enterprise in Marketplace so that you can easily spin a VM for Puppet Enterprise.

Go to Azure portal and click New and type ‘puppet enterprise’ as the search entry


Select the template and proceed to provide Puppet Master VM details such as Master VM name, console password, user name, SSH key etc.

Once the VM is created, you can get the public address DNS name label of the VM from the portal.

Using an SSH client, run the command ssh @ with the DNS name you found above (fully qualified domain name -FQDN). You will be asked to accept the remote host’s public key. Accept and provide the VM authentication password.

Once the VM is provisioned, you can access Puppet Enterprise Console using https:// .cloudapp.net .  In the authentication dialog, use ‘admin’ as user name and provide the console password that you entered while configuring puppet master.  This completes the first stage and next will be to install and configure puppet agent.

1- Create a windows server VM to install puppet agent

  • Click New, go to Marketplace and select ‘Virtual Machines’
  • Select Windows Server and image version (e.g. Windows server 2012 R2 Datacenter)
  • Click ‘create’ and provide user name, password, select pricing tier, resource group, location settings etc.
  • Click ‘create’ to provision the VM

2- Install Puppet Agent

  • Navigate to the blade of your VM
  • Go to ‘Configure’ and click ‘Extensions’
  • Click ‘Add’ in the Extensions box and click ‘Puppet Ent Agent’ ribbon, and click create
  • On the add extension blade, supply the fully qualified domain name of the Puppet Master (created in previous step above)
  • Click ‘create’

Windows Azure – Automation of Configuration across VMs

What are the options or tools available if you want to maintain consistent state or configuration to all your VMs in Windows Azure?

The first approach is to use Custom Script Extension. Set-AzureVMCustomScriptExtension command can be used from Powershell to add the Custom Script extension to an existing virtual machine.

However this approach can become inefficient or difficult to manage in a scaled environment with large number or different groups of VMs. Automation Desired State Configuration (DSC) can be used in such scenarios to set and maintain consistent configurations and states across all your VMs. You configure them and DSC push these to all nodes.

DSC extends PowerShell with ‘Configuration’ syntax with which you can set all the required configuration details for nodes.

Configuration SampleDSCConfig 
 Node "MyNode1" 
 #Enable IIS
 WindowsFeature IIS 
 Ensure = "Present"
 Name = "Web-Server"

 #Install ASP.NET 4.5
 WindowsFeature ASP
 Ensure = “Present”
 Name = “Web-Asp-Net45”

DSC can be used to perform many practical tasks/configurations across VMs such as:

• Setting server roles and features
• Registry settings
• Files and directories
• Start/stop processes and services
• Manage user accounts
• Deploy software
• Run Windows PowerShell scripts
• Managing environment variables
• Fix configuration drifts

Given below is another example of setting a registry value:

Configuration SampleDSCConfig 
Node "MyNode1" 
 Registry DisableShutdownTracking
 Ensure = "Present"
 ValueName = "MyValueName"
 ValueData = "0"
 ValueType = "Dword"
 Force = $true

For advanced configuration and management of your scaled VM infrastructure, you can also use CM tools such as Puppet and Chef which will be described in another blog.