Windows Azure - Viewing Deployment Machine Details

Many of you might be eager to know the deployment machine details like Operating System, Processes, and Hardware Configuration of the Azure application. In this article I am focusing on this deployment details display.

Where are the Roles executed?

We have to take a note that the web role and worker role are executed on a Virtual Machine. The VM role provides flexibility in deploying a configured Virtual Machine role.

Creating the Application

We can start with a web role and add the following code into the Page Load event.

protected void Page_Load(object sender, EventArgs e)
{
   
StringBuilder builder = new StringBuilder();

    // Show the Environment Information
    builder.AppendLine("<h2>Environment Information</h2>");
    builder.Append(
"<b>Machine Name: </b>" + Environment.MachineName + "<br>");
    builder.Append(
"<b>OS Version: </b>" + Environment.OSVersion + "<br>");
    builder.Append(
"<b>Is 64Bit Operating System: </b>" + Environment.Is64BitOperatingSystem + "<br>");
    builder.Append(
"<b>Processor Count: </b>" + Environment.ProcessorCount + "<br>");
    builder.Append(
"<b>User Name: </b>" + Environment.UserName + "<br>");
    builder.Append(
"<b>Is Debugger Attached: </b>" + Debugger.IsAttached + "<br>");

    // Show the Process Information
    builder.AppendLine("<h2>Processes Information</h2>");
   
foreach (Process process in Process.GetProcesses())
        builder.AppendLine(process.ProcessName +
"</br>");

    // Show the RoleEnvironment Information
    builder.AppendLine("<h2>Role Environment Information</h2>");
    builder.Append(
"<b>Curent Role Instance Name: </b>" + RoleEnvironment.CurrentRoleInstance.Role.Name + "<br>");
    builder.Append(
"<b>Deployment Id: </b>" + RoleEnvironment.DeploymentId + "<br>");
    builder.Append(
"<b>Is Emulated: </b>" + RoleEnvironment.IsEmulated + "<br>");

    // Display the Resutls
    InfoLabel.Text = builder.ToString();
}

The code does the following activities.

  • Use the Environment class to list the Operating System Name, Version, Procesor Count etc.

  • Use the Process class to list the current active processes in the machine

  • Use the RoleEnvironment class to get the Role Name, Deployment Id, Is Emulated properties.

The following are the important properties we are accessing:

Environment Class

Get the machine name: Environment.MachineName
Get the operating system version: Environment.OSVersion
Get the number of processors in the machine: Environment.ProcessorCount

Process Class

Get the active processes: Process.GetProcesses()

RoleEnvironment Class

Get the role name: RoleEnvironment.CurrentRoleInstance.Role.Name
Get the deployment id: RoleEnvironment.DeploymentId
Check whether emulator mode: RoleEnvironment.IsEmulated

Executing the application

On executing the application in the development environment the following results are retrieved.

WinAzr1.gif

Executing on the Cloud

Now we can deploy the application to the cloud and view the results. You can refer to the packaging and deploying steps here.

After the deployment status is ready in the cloud, we can execute the application.

WinAzr2.gif

The execution result is shown below:

WinAzr3.gif

From the above result we can see the Operating system version. Together with that Debugger.IsAttached and RoleEnvironment.IsEmulated properties are returning false inside the cloud execution.

Summary

In this article we have seen the deployment details of the Azure application. We have executed the application in the local development machine and in the online Cloud platform. The attached source code contains the above described application. 

Up Next
    Ebook Download
    View all
    Learn
    View all