Scaling Down with Windows Azure

Awhile back, Neil Kidd created a great blog post on scaling down in Windows Azure.  The concept is to multithread your Azure worker roles (and web roles, too) – even if you have a single core (small instance) VM, most workloads are network IO blocked, not CPU blocked, so creating a lightweight framework for supporting multiple workers in a single role not only saves money, but makes sense architecturally.  In this screencast, I updated Neil’s concept a bit, and bring it forward to work with the latest Azure SDK: Download the sample project (Visual Studio 2010) used in this screencast here.

Register To Attend A Windows Azure Virtual Hands-On Workshop

@HOME WITH WINDOWS AZURE I’m really excited to announce a project my colleagues Jim, John and I have been working on.  We wanted to come up with a project that would: 1) be fun for users to learn Azure, 2) help illustrate scale, 3) do something useful, and 4) be fun to develop (from our end).  I think we got it!  Here is a rundown: Elevate your skills with Windows Azure in this hands-on workshop! In this event we’ll guide you through the process of building and deploying a large scale Azure application. Forget about “hello world”! In less than two hours we’ll build and deploy a real cloud app that leverages the Azure data center and helps make a difference in the world. Yes, in addition to building an application that will leave you with a rock-solid understanding of the Azure platform, the solution you deploy will contribute back to Stanford’s Folding@home distributed computing project. There’s no cost to you to participate in this session; each attendee will receive a temporary, self-expiring, full-access account to work with Azure for a period of 2-weeks. Visit the project home page at For this briefing you will: Receive a temporary, self-expiring full-access account to work with Azure for a period of 2-weeks at no cost - accounts will be emailed to all registered attendees 24-48 hours in advance of each event. Build and deploy a real cloud app that leverages the Azure data center Who should attend? Open to developers with an interest in exploring Windows Azure through a short, hands-on workshop AGENDA 15 min WELCOME and STUDENT PREP The goal of today’s event is to help attendees build a local instance of a Windows Azure application and deploy it to an Azure data center. So, are you ready to participate in this hands-on workshop? Did you review the pre-requisites*? We hope so, but just in case you didn’t, we’ll take a few minutes to review them with you now so you’re ready to begin building your app. 15 min AZURE 101 To make sure everyone starts off with a common understanding of Microsoft’s cloud computing platform we’ll cover basic concepts for all attendees new to Azure. We’ll then provide an overview of the project, what “folding” is, and how the application is modeled. 75 min HANDS-ON WORKSHOP We’ll guide you through creating a Windows Azure cloud application in Visual Studio, leveraging both web roles (as a front end for your application) and worker roles (that will carry out the core processing).   Your application will make use of Azure Table Storage as well as Azure local storage for reading/writing files.  Finally, we’ll show you how to deploy your application to the cloud (using accounts provided by Microsoft) and illustrate how to use Windows Azure Diagnostics to monitor the health of the application. 15 min NEXT STEPS and WRAP-UP You’ve got two weeks of no-cost access to Windows Azure before your account expires. Where do you turn next? How can you learn more? In this segment we’ll review a host of online training resources available to you today. And, we’ll explain Microsoft’s Azure offerings for MSDN subscribers, partners, and customers. For instance, did you know an MSDN Premium subscriber receives 6000 hours of Azure compute time at no additional cost? We’ll cover this and more to make sure you leave with the knowledge necessary to take Azure to the next level. *PREREQUISITES The prerequisites are pretty straight forward and we ask that you come prepared to participate in this event by installing the required software in advance of the Live Meeting event. Visual Studio 2008 or Visual Studio 2010 Azure Tools For Visual Studio, Feb 2010 REGISTER TODAY - 9 Events to Choose from! Register By Phone or Online: Click on the Event ID to register today or call 877-673-8368 and reference the Event ID below Wednesday April 28 11:00 AM – 01:00 PM 1032450746 Tuesday May 04 07:00 PM – 09:00 PM 1032450869 Wednesday May 12 11:00 AM – 01:00 PM 1032450870 Wednesday May 19 04:00 PM – 06:00 PM 1032450871 Wednesday May 26 11:00 AM – 01:00 PM 1032450872 Tuesday June 01 11:00 AM – 01:00 PM 1032450876 Wednesday June 09 04:00 PM – 06:00 PM 1032450881 Wednesday June 16 11:00 AM – 01:00 PM 1032450882 Wednesday June 23 07:00 PM – 09:00 PM 1032450883 Presenters: Brian Hitney, Developer Evangelist, Microsoft Jim O’Neil, Developer Evangelist, Microsoft John McClelland, Partner Evangelist, Microsoft

Marquee Lives!

I’m helping to organize some East Region Azure Boot Camps ( – stay tuned for more info! – and had a humorous moment while surfing the various reg pages we have in place. Our Click To Attend registration site is using … I can’t believe it … a marquee tag!  See for yourself, but it’s short lived for maintenance.  Now, this is 100% Click to Attend and nothing to do with the event on the page.  The event, by the way, is the Ft. Lauderdale Azure Boot Camp!  Awesome full day event (cramming 2 days into 1!) … if you want to learn more about Azure and are in the Ft Lauderdale area, be sure to check it out! More ABC’s coming to Atlanta, Charlotte, and more areas soon!

Azure Miniseries #4: Monitoring Applications

In this screencast, we'll take a look at monitoring Azure applications by capturing event logs and performance counters. We'll also look at using PowerShell to deploy and configure applications using the management API. Finally, we'll take a sneak peek at Azure Diagnostics Manager, a tool from Cerebrata that allows you explore event logs and look at performance counters visually. Here are some links from the screencast: Windows Azure Cmdlets Cerebrata (Cloud Storage Studio and Azure Diagnostics Monitor) Finally, let’s get into some code snippets! Watch for wrap on the PowerShell lines, and note the single quote ` character as the line continuation: Creating a self-signed certificate command:
makecert -r -pe -a sha1 -n "CN=Azure Service Test" -ss My -len 2048 -sp "Microsoft Enhanced RSA and AES Cryptographic Provider" -sy 24 AzureServiceTest.cer
Uploading a new deployment to the staging slot, and starting it (requires Azure CmdLets):
$cert = Get-Item cert:\CurrentUser\My\{thumbprint} $sub = "{subscription GUID}" $servicename = "{service name}" $package = "CloudApp.cspkg" $config = "ServiceConfiguration.cscfg" [DateTime]$datelabel = Get-Date $lbl = $datelabel.ToString("MM-dd-yyyy-HH:mm") Write-Host "Label for deployment: " $lbl Add-PSSnapin AzureManagementToolsSnapIn Get-HostedService $servicename -Certificate $cert -SubscriptionId $sub | New-Deployment -Slot Staging $package $config -Label $lbl | Get-OperationStatus -WaitToComplete Get-Deployment staging -serviceName $servicename -SubscriptionId $sub -Certificate $cert | Set-DeploymentStatus running | Get-OperationStatus -WaitToComplete
Increasing the number of instances:
Add-PSSnapin AzureManagementToolsSnapIn $cert = Get-Item cert:\CurrentUser\My\{thumbprint} $sub = "{subscription GUID}" $servicename = "{service name}" $storage = "{storage name}" #get storage account name and key $key = (Get-StorageKeys -ServiceName $storage -Certificate $cert -SubscriptionId $sub).Primary $deployId = (Get-HostedService $servicename -SubscriptionId $sub -Certificate $cert | Get-Deployment Production).DeploymentId        Get-HostedService $servicename -Certificate $cert -SubscriptionId $sub |     Get-Deployment -Slot Staging |     Set-DeploymentConfiguration {$_.RolesConfiguration["WebRole1"].InstanceCount += 1}
Updating the performance counters – specifically, adding total processor time, ASP.NET req/sec, and memory usage to be polled every 30 seconds, and uploaded every 1 minute:
Add-PSSnapin AzureManagementToolsSnapIn $cert = Get-Item cert:\CurrentUser\My\{thumbprint} $sub = "{subscription GUID}" $servicename = "{service name}" $storage = "{storage name}" #get storage account name and key $key = (Get-StorageKeys -ServiceName $storage -Certificate $cert -SubscriptionId $sub).Primary $deployId = (Get-HostedService $servicename -SubscriptionId $sub -Certificate $cert | Get-Deployment Production).DeploymentId        # rate at which counters are polled $rate = [TimeSpan]::FromSeconds(30) Get-DiagnosticAwareRoles -StorageAccountName $storage -StorageAccountKey $key -DeploymentId $deployId | foreach {     $role = $_     write-host $role     Get-DiagnosticAwareRoleInstances $role -DeploymentId $deployId `         -StorageAccountName $storage -StorageAccountKey $key |     foreach {         $instance = $_         $config = Get-DiagnosticConfiguration -RoleName $role -InstanceId $_ -StorageAccountName $storage `              -StorageAccountKey $key -BufferName PerformanceCounters -DeploymentId $deployId                     $processorCounter = New-Object Microsoft.WindowsAzure.Diagnostics.PerformanceCounterConfiguration `                 -Property @{CounterSpecifier='\Processor(_Total)\% Processor Time'; SampleRate=$rate }         $memoryCounter = New-Object Microsoft.WindowsAzure.Diagnostics.PerformanceCounterConfiguration `                 -Property @{CounterSpecifier='\Memory\Available Mbytes'; SampleRate=$rate }         $requestsCounter = New-Object Microsoft.WindowsAzure.Diagnostics.PerformanceCounterConfiguration `                 -Property @{CounterSpecifier='\ASP.NET Applications(__Total__)\Requests/Sec'; SampleRate=$rate }         $config.DataSources.Clear()         $config.DataSources.Add($processorCounter)         $config.DataSources.Add($memoryCounter)         $config.DataSources.Add($requestsCounter)         Set-PerformanceCounter -PerformanceCounters $config.DataSources -RoleName $role `              -InstanceId $instance -DeploymentId $deployId `              -TransferPeriod 1 `              -StorageAccountName $storage -StorageAccountKey $key                          }   }
And finally, the webrole.cs class from the screencast:
public class WebRole : RoleEntryPoint     {         public override bool OnStart()         {             DiagnosticMonitorConfiguration diagConfig =                 DiagnosticMonitor.GetDefaultInitialConfiguration();             diagConfig.PerformanceCounters.DataSources.Add(                 new PerformanceCounterConfiguration()                 {                     CounterSpecifier = @"\Processor(_Total)\% Processor Time",                     SampleRate = TimeSpan.FromSeconds(5)                 });             diagConfig.PerformanceCounters.DataSources.Add(                 new PerformanceCounterConfiguration()                 {                     CounterSpecifier = @"\Memory\Available Mbytes",                     SampleRate = TimeSpan.FromSeconds(5)                 });             diagConfig.PerformanceCounters.ScheduledTransferPeriod =                 TimeSpan.FromMinutes(1);             diagConfig.Logs.ScheduledTransferLogLevelFilter = LogLevel.Information;             diagConfig.Logs.ScheduledTransferPeriod = TimeSpan.FromMinutes(1);             DiagnosticMonitor.Start("DiagnosticsConnectionString", diagConfig);             System.Diagnostics.Trace.TraceInformation("Done configuring diagnostics.");             // For information on handling configuration changes             // see the MSDN topic at             RoleEnvironment.Changing += RoleEnvironmentChanging;             return base.OnStart();         }         public override void OnStop()         {             System.Diagnostics.Trace.TraceWarning("Onstop called.");             base.OnStop();         }         private void RoleEnvironmentChanging(object sender, RoleEnvironmentChangingEventArgs e)         {             // If a configuration setting is changing             if (e.Changes.Any(change => change is RoleEnvironmentConfigurationSettingChange))             {                 // Set e.Cancel to true to restart this role instance                 e.Cancel = true;             }         }     }

Azure Miniseries #3: ServiceConfig vs web.config

One of the challenges developers will face when developing Windows Azure web applications is: where do I put my settings?  In the ServiceConfiguration file or the web.config? There isn’t one correct answer.  The challenge of keeping everything in the web.config is that it makes changes and deployment much more difficult.  Because the web.config is part of the deployment, any change to the file also requires a redeployment.  If you use a build system that targets your dev/stage/QA/prod environments automatically and can provide the correct settings in the web.config for you, this might mitigate the problem. The answer then is to migrate these settings to the ServiceConfiguration file as it requires no changes to our deployment package.  In this screencast I’ll show you some strategies for doing that for components that are more difficult to migrate, like the SqlMembershipProvider… Link to original post and download links.

Azure Miniseries #2: Deployment

In my first Azure Miniseries post, I showed setting up a new cloud service project and migrating an existing ASP.NET application into Azure.   Before I dive into other topics, I figured I’d jump to the end and discuss deployment – getting your Azure application into the cloud.   Link to original post with download links.

SQL Azure Logins

SQL Azure currently has fairly limited management capabilities.  When you create a database, you receive an administrator account that is tied to your login (you can change the SQL Azure password, though).  Because there is no GUI for user management, there’s a temptation to use this account in all your applications, but I highly recommend you create users for your application that have limited access.  If you limit access to only stored procedures, you need to specify execute permissions.  Assuming you want your connection to have execute permissions on all stored procedures, I recommend a new role that has execute permissions.  That way, you can simply add users to this role and as you add more stored procedures, it simply works.  To create this role, you can do something like this: CREATE ROLE db_executor GRANT EXECUTE TO db_executor Now in the master database (currently, you need to do this in a separate connection – just saying ‘use master’ won’t work) you can create your login for the database: CREATE LOGIN MyUserName WITH PASSWORD = 'Password'; In your application database, you need to create a user – in this case, we’ll just create a user with the same name as the login: CREATE USER MyUserName FOR LOGIN MyUserName; Next, we’ll specify the appropriate roles.  Depending on your needs, you may need only datareader.  I recommend db_owner only if necessary. -- read/write/execute permissions EXEC sp_addrolemember N'db_datareader', N'MyUserName' EXEC sp_addrolemember N'db_datawriter', N'MyUserName' EXEC sp_addrolemember N'db_executor', N'MyUserName' -- only if you need dbo access: EXEC sp_addrolemember N'db_owner', N'MyUserName' You can continue to customize as necessary, as long as you are familiar with the appropriate T-SQL. 

WCF in an Azure WorkerRole

The other day, a colleague got in touch with me looking for help in getting a WCF service working in an Azure WorkerRole.   It would work locally, but not deployed in the cloud.   This is a common problem I’ve run into – for example, calling Open() on a ServiceHost will work locally, but no in the cloud due to permissions. I wasn’t much help in getting John’s situation resolved, but he pinged me about it a couple days later with the solution.  The first is to make sure your service has the correct behavior to respond to any address: [ServiceBehavior(AddressFilterMode = AddressFilterMode.Any)] The next was to make sure you explicitly set the SecurityMode in the binding: NetTcpBinding binding = new NetTcpBinding(SecurityMode.None);  Webroles are different as they are hosted in IIS and limited to HTTP. Also, there are some good demos mentioned in this post on the MSDN forums that points to the Azure All-In-One demos on CodePlex. 

Azure Miniseries #1: Migration

I’m starting to put together some short form screencasts on Windows Azure related topics.  I’ll use my blog to dive into specifics or display code samples/downloads where appropriate – but first up is a quick look at getting a project setup and migrating existing applications into an Azure webrole.

MSDN Events and Roadshows Coming Soon…

Top line:  March 3rd, we’ll be in Raleigh, and March 5th, we’ll be in Charlotte for our next MSDN Event and Southern Fried Roadshow.  This time it’s a full day of Azure – if you have an interest in cloud computing, be sure to come out!  See you then! MSDN Events presents:  Take Your Applications Sky High with Cloud Computing and the Windows Azure Platform Join your local MSDN Events team as we take a deep dive into cloud computing and the Windows Azure Platform. We’ll start with a developer-focused overview of this new platform and the cloud computing services that can be used either together or independently to build highly scalable applications. As the day unfolds, we’ll explore data storage, SQL Azure, and the basics of deployment with Windows Azure. Register today for these free, live sessions in your local area. SESSION 1: Overview of Cloud Computing and Windows Azure The Windows Azure platform is a set of high-performance cloud computing services that can be used together or independently and enable developers to leverage existing skills and familiar tools to develop cloud applications. In this session, we’ll provide a developer-focused overview of this new online service computing platform. We’ll explore the components, key features and real day-to-day benefits of Windows Azure. SESSION 2: Survey of Windows Azure Platform Storage Options Durable data storage is a key component of any cloud computing offering. The Windows Azure Platform offers many options, which can be used alone or in combination. Windows Azure itself offers ready-to-use and lightweight storage in the form of tables, blobs, and queues. Another choice for storage is SQL Azure, a true relational database in the cloud. In this session, we’ll explore the highlights of these implementations and how to both create and use storage in each form. We’ll give you guidance on choosing the right forms of storage for your application scenarios. SESSION 3: Going Live with your Azure Solution Windows Azure features a powerful, yet simple deployment model. By focusing on your application and abstracting away the infrastructure details, you can deploy almost any app with minimal fuss. In this session, we’ll walk you through the basics of Windows Azure deployment, including site monitoring, diagnostics and performance issues.

My Apps

Dark Skies Astrophotography Journal Vol 1 Explore The Moon
Mars Explorer Moons of Jupiter Messier Object Explorer
Brew Finder Earthquake Explorer Venus Explorer  

My Worldmap

Month List