Enhance the Diagnosability of your Apps with Windows Azure

Hosted Software, Windows Azure No Comments »

Windows Azure logo bl In the last few posts, we have been discussing how running your application in Windows Azure allows you, with minimal incremental code, to cloud-enhance your application with capabilities such as elasticity, automation, and diagnostics.

My colleague, Sumit Mehrotra, dives into the diagnostics capabilities on his blog – describing how Windows Azure offers rich centralized diagnostic capabilities without making you change how your application does its logging (e.g. System.Diagnostics.Trace, IIS logs, application crash dumps, etc.).

Run and Enhance Client-Server Apps with Windows Azure

Hosted Software, Windows Azure 1 Comment »

In the previous post, we discussed that you can not only run some of your favorite technologies in Windows Azure but that you can easily cloud-enhance them with capabilities such as automation, elasticity, and diagnostics.

My recent post on the official Windows Azure blog introduces an example, describing how to run a client-server application (e.g. a relational database or distributed memory cache) in Windows Azure and then add elasticity to the server tier. Elasticity allows you to minimize your costs by dynamically adjusting capacity to meet demand. Let’s dig a bit deeper, diving into what the corresponding code would look like:

Service Definition

To get started, we need to define the server tier and declare an internal endpoint.

<WorkerRole name="MyServer" enableNativeCodeExecution="true">
    <!-- Defines an internal endpoint for inter-role communication that can be used to communicate between worker or Web role instances -->
    <InternalEndpoint name="MyEndpoint" protocol="tcp" />

Client Code

Note that only three lines of Windows Azure specific code, highlighted below, are needed to a) initialize the client and b) reinitialize the client when server instances are added or removed.

private MyClient InitializeClient() {
    var client = new MyClient();
    foreach (var inst in RoleEnvironment.Roles["MyServer"].Instances) {
        client.Add(inst.Id, inst.InstanceEndpoints["MyEndpoint"]);
    return client;

public void Go() {
    // Initialize the client
    var client = InitializeClient();

    // Reinitialize the client when there is a topology change
    RoleEnvironment.Changed += (sender, args) => {
        if (args.Changes.Any(chg => chg is RoleEnvironmentTopologyChange)) {
            client = InitializeClient();

    // Use the client as you would outside Windows Azure…

Server Code

Finally, we add one incremental line of code on the server tier, highlighted below, to discover the IP address and port to bind to.

// Discover the IP address and port assigned by Windows Azure
var ep = RoleEnvironment.CurrentRoleInstance.InstanceEndpoints["MyEndpoint"];

// Start the listener -- in this case another process -- passing in this info
var startInfo = new ProcessStartInfo
    FileName = @".\MyServer.exe",
    Arguments = "-l " + ep.Address + " -p " + ep.Port,
    UseShellExecute = false,
    CreateNoWindow = true

My PDC09 Talk, and Takeaways about Cloud-Enhancing Your Apps

Hosted Software, Windows Azure 2 Comments »

Windows Azure Logo I, along with Tushar Shanbhag, recently gave a talk @ PDC09 on using PHP, memcached, and MySQL to build applications with Windows Azure. The video and slides are now available.  We used the technologies in the talk to reinforce some key Windows Azure benefits, specifically how to:

  1. Easily get started with these (PHP and memcached/MySQL) and a variety of Windows Server-compatible technologies on Windows Azure.
  2. Maintain, scale, and more broadly cloud-enhance these technologies by leveraging platform primitives in Windows Azure.

Ray Ozzie, Microsoft’s Chief Software Architect, talked to similar points at a recent Financial Analyst and Investor Briefing this past Wednesday:

The way that we kind of think about it is, most people will do a move, extend, and then transform. They’ll move something to the cloud, then they’ll start to mess around with it, and understand what it’s like to be in the cloud. And then they’ll extend it by starting to take some aspect of it and take advantage of the cloud.

Having served as CTO of a startup where we leased our own rack and burned lots of time on both software- and hardware-related “I.T. stuff”, I get especially excited about the extend/cloud-enhance point. In addition, it reinforces that Windows Azure is much more than a hosting provider.

Here are just some of the ways you can cloud-enhance your applications with Windows Azure with minimal incremental code:

  1. Elasticity (Even for Client-Server Apps): As we demonstrated in our talk, you can continue to use client-server apps (i.e. memcached) as you do today. However, by leveraging Windows Azure’s new topology discovery API’s, you can add elasticity with just a few lines of code to automatically update your clients’ connection tables when server nodes are added or removed.
  2. Diagnostics: You continue to log and trace as you do today. However, with Windows Azure Diagnostics, you can choose to direct the output (from potentially multiple nodes) to a centralized location in Windows Azure Tables. By doing so, you get a durable and queryable way to detect & troubleshoot problems, measure performance, etc.
  3. Automation: You continue to use the configuration mechanisms (e.g. .ini file) you use today. However, by writing incremental code, you can have the ini file populated from a Windows Azure configuration setting. In doing so, this configuration, which could be living on 1000s of your nodes, is now updateable via a single change in the Windows Azure management portal.

Same Blog (Mostly), a New Name, and SEO

Hosted Software, Windows Azure 2 Comments »

Rebranding from This Hosted Life to Cloud MouthAs you may have noticed, I have rebranded this blog from This Hosted Life to Cloud Mouth. A few weekends ago, I decided I would like to start blogging again and with a greater emphasis on Windows Azure, the cloud services platform I am working on at Microsoft. So, I went to GoDaddy’s domain name search and decided not to get up until I found a domain name I liked. I sort of knew I wanted “cloud” in the name, and it eventually hit me that I could play off the fact that “cloud” rhymes with “loud”. Unfortunately, cloudmouth.com was unavailable. But, I was okay with a .net domain name instead, and thankfully cloudmouth.net was available!

SEO Implications

Having been through a rebranding before, I knew one of the most important next steps was to make sure every inbound link to the old site is 301 redirected to the new site. With this type of redirect, search engines (in theory at least) know to automatically transfer page rank from the old url (e.g. http://thishostedlife.com/about) to the new url (e.g. http://www.cloudmouth.net/about). This is not always the case with other forms of redirection.

You can do this with IIS or Windows Azure with the following set of rewrite rules that tell the Web server to 301 redirect all requests for anything other than http://www.cloudmouth.net/… to http://www.cloudmouth.net/….

    <rule name="Imported Rule 1" stopProcessing="true">
      <match url="(.*)" ignoreCase="false" />
      <conditions logicalGrouping="MatchAll">
        <add input="{HTTP_HOST}" pattern="" ignoreCase="false" />
        <add input="{HTTP_HOST}" negate="true" pattern="^www\.cloudmouth\.net" ignoreCase="false" />
      <action type="Redirect" url="http://www.cloudmouth.net/{R:1}" redirectType="Permanent" />

If you aleady have an equivalent set of rules for Apache, such as the ones below, these can be easily converted by Microsoft’s IIS Manager for consumption by IIS or Windows Azure.

<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} .
RewriteCond %{HTTP_HOST} !^www\.cloudmouth\.net
RewriteRule (.*) http://www.cloudmouth.net/$1 [R=301,L]

Finally, you can use a tool such as Web-Sniffer, one of my favorites, to confirm all your old pages return HTTP Status Code: 301 Moved Permanently and that your hard-earned page rank will be (hopefully!) retained.

Design by j david macor.com.Original WP Theme & Icons by N.Design Studio
Entries RSS Comments RSS Log in