Save the date for Microsoft Azure OpenDev virtual event


Azure OpenDev, the first-ever virtual event from Microsoft that showcases open source technologies in the cloud.

Hosted by John Gossman, Lead Architect, Microsoft Azure, the event features industry thought leaders including Mark Shuttleworth of Canonical and speakers from Docker, Pivotal, Red Hat, and Chef—as well as Microsoft teams dedicated to open source. Hear from customers such as Mastercard about solutions they’ve built with open source that run on Azure today.

Join online to learn how to:

  • Use containers to build microservice-based solutions on Azure, in Java, Node.js, and more.
  • Use existing open source skills and tools to enable your DevOps pipeline in the cloud.
  • Modernize your existing apps and implement community best practices.

Have your questions answered by subject matter experts in a live Q&A, and participate in hands-on sessions with open source on Azure.

Save the date


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:// .  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.

ApplicationInsights.config – Tailoring Application Insights Configuration

We have seen the use of Application Insights configuration file in my previous article that described how to integrate AI to your application. Today, we will explore the sections of ApplicationInsights.config (Note that the file is ApplicationInsights.xml for Java web apps) in detail.

As mentioned in that article, this file get automatically added to your application when you add the ApplicationInsights to your application via NuGet or if you specify the AI integration while creating a new project in Visual Studio. And the file will have the default entries/configuration values as shown below:


I have described the key sections in this configuration file  below:

Telemetry Modules

As shown above, each module added in this section collects the specific data/counts. You can add or remove line items for these module nodes depending on the information that you want to collect. Some of the common tracker modules under this section are:

Dependency Tracking

You might have noticed this telemetry data in the graphs that I posted in my previous articles which talked about creation of AI telemetry charts. This data represents the number of calls that your application makes to the external databases or services.

<Add Type=”Microsoft.ApplicationInsights.DependencyCollector.DependencyTrackingTelemetryModule, Microsoft.AI.DependencyCollector” />

Performance collector

This is to collect system performance parameters such as your CPU and memory load.

<Add Type=”Microsoft.ApplicationInsights.Extensibility.PerfCounterCollector.PerformanceCollectorModule, Microsoft.AI.PerfCounterCollector”>

Application Insights Diagnostics

Use this if you want to collect error information from the AI instrumentation.

<Add Type=”Microsoft.ApplicationInsights.Extensibility.Implementation.Tracing.DiagnosticsTelemetryModule, Microsoft.ApplicationInsights” />

Developer Mode

Use this if you want your application to send telemetry data one at a time while you step through your lines of code while debugging. Yes, you do not need this in your production configuration.

<Add Type=”Microsoft.ApplicationInsights.WindowsServer.DeveloperModeWithDebuggerAttachedTelemetryModule, Microsoft.AI.WindowsServer” />

Web Request Tracking

Used to collect the http requests, response time and response codes

<Add Type=”Microsoft.ApplicationInsights.Web.RequestTrackingTelemetryModule, Microsoft.AI.Web” />

Exception tracking

This one collects data for unhandled exceptions in your applications. Very useful indeed!

<Add Type=”Microsoft.ApplicationInsights.Web.ExceptionTrackingTelemetryModule, Microsoft.AI.Web” />


Telemetry Channel

This is responsible for buffering and sending the telemetry data collected in your application.

 Telemetry Initializers


Notice the screenshot above and the initializers placed for client IP, Session, User, Domain, Device etc. These are set to set the context properties along with the telemetry data that is collected and sent to the AI service.

Instrumentation Key


Use this section to specify the instrumentation key of the desired Application Insights Resource that you set up in your Azure account. Refer my previous article here for learning more about creating AI resource in Azure.


Adding Custom Application Insights instrumentaiton to Web Pages

In my previous article, we explored how to configure Application Insights to your application. The configuration explained there applies to the entire application which is good. The immediate doubt for many would be – Is it possible to track specific pages or custom events in specific pages in my applicaion using Application Insights?  The answer is Yes.

If you are familiar using Google Analytics (note that the objectives for Azure AI and Google Analytics aren’t the same; hence no comparison intended here), it is similar method that we have to add custom instrumentation to your pages using Application Insight.

Before we start, here are the prerequisites

  • Windows Azure Account
  • An Application Insights resournce created in Azure (explained here)
  • A running web application (Azure or on-premise hosted)

Login to your Azure account and select the Application Insights resource that you want to use for instrumentaiton.


You will be provided with the code snippet below.

   var appInsights=window.appInsights||function(config){     function r(config){t[config]=function(){var i=arguments;t.queue.push(function(){t[config].apply(t,i)})}}var t={config:config},u=document,e=window,o="script",s=u.createElement(o),i,f;for(s.src=config.url||"//",u.getElementsByTagName(o)[0].parentNode.appendChild(s),t.cookie=u.cookie,t.queue=[],i=["Event","Exception","Metric","PageView","Trace"];i.length;)r("track"+i.pop());return r("setAuthenticatedUserContext"),r("clearAuthenticatedUserContext"),config.disableExceptionTracking||(i="onerror",r("_"+i),f=e[i],e[i]=function(config,r,u,e,o){var s=f&&f(config,r,u,e,o);return s!==!0&&t["_"+i](config,r,u,e,o),s}),t     }({         instrumentationKey:"**********************************"     });             window.appInsights=appInsights;     appInsights.trackPageView();

To start with, copy this code and insert to HTML code of the web page that you want to track. Upload/redeploy your application and load the page few times to collect instrumentation data.

To view the metrics, go to Azure portal. Select the Application Insights resource. Use the “Add tiles” option  and drag the “Usage Timeline” and “Overview Timeline” charts from the default list



You can see the page views, sessions and users statistics.


Let us analyze this further. By default, you have an entry which tracks the page views.



If you want to track a custom event in your client page, you can use

(Javascript Syntax)


where the entry “MyEvent” stands for the custom event which can be tracked in the AI resource.

How to view and analyze custom events

As we did in the previous step, you can add default chart for “Custom Event” using the Add Tiles option or you can search for the event and add a custom chart.



So this will get you started. Some of the common APIs are listed below.

  • TrackPageView
  • TrackEvent
  • TrackMetric
  • TrackException
  • TrackRequest
  • TrackTrace
  • TrackDependency

There are various options to add custom tracking based on whether you are working on server side or client side code. The code syntax for doing the same in other languages are :


var tc = new TelemetryClient();


TelemetryClient tc = new TelemetryClient();


var AppInsights = require('applicationinsights');
var appInsights = new AppInsights({instrumentationKey: "<my instrumentation key>"});
appInsights.trackEvent("My event", { custom: "properties" });

Adding Application Insigts to your Azure Web Application

Having deployed an application to Azure, you would want to track how the application is performing, how are they used and know the appliation issues. Microsoft Azure’s Application Insights allows you to monitor both the health and usage of your web application. So we have usage analysis, monitor availability and performance tracking. This article focus on how to enable your application with Aplication Insights.

There are several ways to integrate Application Insigts to your application. In this article, we will look the in-built way of enabling it from Visual Studio (requires re-publishing your application to Windows Azure for existing applications)

(1) A Windows Azure account
(2) Visual Studio 2013 or 2015
(3) This article also assumes that you have an application that is already deployed or ready to deploy to Windows Azure.


Create an Application Insights resource in your Azure account.

Go to Azure portal. Add new resource and select ‘Application Insights’. Choose application type as ASP.NET in the configuration window.



Once created, you can find the ‘Instrumentation Key’ generated for the AI resource. We will discuss about the use of it in a while.

Add Application Insights SDK to your Web Application using Visual Studio

Scenario -1 : If you are creating a new project, the options for integrating the ‘application insights’ are available in the ‘New Project’ dialog as below.


Note that, since I have logged in to my Azure account, I am able to select the exising AI resource that I created in the previous step. Nevertheless, you can create a new one for your application if you wish to and it gets created in your Azure Account.

Scenario -2 : If you you have an existing project and you want to enable Application Instigts and deploy to Azure, right click the project and choose ‘Configure Application Insights’ as shown below.


Log in to your Azure account and it provides you same options to choose or create Application Insights resource.


The required resources will be added to your project; let us look into the added resources:







  • This is where we customize the telemetry components such as dependency tracking, performance counters etc. This configuration file gets added and note that your instrumentation key has been automatically pulled from Azure and added to this configuration file.


Publish Your Application to Azure

This is straightforward. Publish your application to Azure and your AI configurations along with your application will be deployed to Azure and ready to collect the instrumentation data.

When it is time to pull some metrics, go to  your Application Insights resource in Azure portal, select the resource and view ‘Performance’


Another example below; reviewing the failures.



Windows Azure now supports Red Hat Enterprise Linux

Few years back a news like Linux support in Microsoft platform would have surprised many. But in the context of the Windows Azure platform, this really makes sense and offers flexibility for customers.

Windows Azure had official offerings of Linux distributions such as Ubuntu, CentOS, SUSE Linux Enterprise etc, and as per Microsoft’s data, more than 20% of their VMs in cloud platform runs Linux. However Red Hat Linux wasn’t offered until last month. 

Finally RHEL is officially supported in Windows Azure from 18th Feb.  Microsoft has partnered with Red Hat that lets Azure customers move on-premise RHEL subscriptions to Azure and provide enterprise class support. 

The screen capture below shows the default RHEL VM offerings currently available in Azure.