Upcoming Windows Phone 7 Events

by Brian Hitney 23. August 2010 13:13

Want to learn more about developing for Windows Phone 7?  Check out his event series coming soon!   The event is broken down into two parts:  the Firestarter event which runs all day, then an evening event called the Windows Phone Garage… learn more below, and the registration links for both events in all the cities is at the bottom of the post:

Morning Sessions:
· Introduction to Windows Phone Development and the WP7 platform
· Building Windows Phone 7 Applications with Silverlight
· Building Windows Phone 7 Applications using XNA

Lunch (included)
Afternoon Sessions:
· Monetizing Your Apps with Marketplace
· Windows Phone 7 Services
· Light Up Windows Phone 7

Windows Phone Garage| 6pm - 9pm

This evening event is the opportunity for you to get started on that next killer app for Windows Phone 7, or put the finishing touches on your masterpiece. The Windows Phone Garage for mobile application developers follows the daytime Firestarter event. As you are designing, writing & testing your apps onsite, we’ll provide Windows Phone 7 experts (both Microsoft and community) to help you get things right. These experts will also present “quick hit” talks throughout the evening, containing tips and tricks on their experiences writing Windows Phone apps. It's the perfect opportunity to design and implement that cool new app you've been dreaming about, so bring your ideas and get ready to code. To learn more about the Phone Garage event or to register, click on an event city near you. Hurry, space is limited!

For more information or to register,
visit > www.msdnevents.com/firestarter

OR CALL 1-877-MSEVENT

Windows Phone 7 Firestarter

Windows Phone 7 Garage

To register, select a city

To register, select a city

Atlanta, GA

8/24/2010

Atlanta,GA

8/24/2010

Waltham, MA

8/24/2010

Waltham, MA

8/24/2010

Birmingham, AL

8/26/2010

Birmingham, AL

8/26/2010

Tampa, FL

8/31/2010

Tampa, FL

8/31/2010

Ft. Lauderdale, FL

9/2/2010

Ft. Lauderdale, FL

9/2/2010

New York, NY

9/7/2010

New York, NY

9/7/2010

Raleigh, NC

9/8/2010

Raleigh, NC

9/8/2010

Chevy Chase, MD

9/21/2010

Chevy Chase, MD

9/21/2010

Charlotte, NC

9/21/2010

Charlotte, NC

9/21/2010

Philadelphia, PA

9/22/2010

Philadelphia, PA

9/22/2010

Pittsburgh, PA

9/28/2010

Pittsburgh, PA

9/28/2010

Farmington, CT

9/30/2010

Farmington, CT

9/30/2010

Tags: ,

Microsoft | Events | Windows Phone 7

Scaling Down – Text Version

by Brian Hitney 17. May 2010 19:42

I caught some Flak this weekend at the Charlotte Code Camp when Justin realized my recent Scale Down with Windows Azure post was principally a screencast (aside from the code sample).   So Justin, I’m documenting the screencast just for you! :)

First, a good place to start with this concept is on Neil Kidd’s blog post.   Go ahead and read that now … I’ll wait.  Most of this code is based off of his original sample, I’ve modified a few things and brought it forward to work with the latest SDK.

So, in a nutshell, a typical worker role template contains a Run() method in which we’d implement the logic to run our worker role.  In many cases, there are multiple tasks and multiple workers.  Unless the majority of the work you are doing is CPU bound (which is entirely possible, as is the case with our Azure-based distributed Folding project), the resources of the VM can be better utilized by multithreading the tasks and workers.

The trick is to do this correctly as writing multithreaded code is challenging.  In general, parallel extensions is likely not the right approach in this situation.  There are some exceptions – for example, if you are using a 4-core (large) VM and require lots of parallel processing, PFx might be the best approach.  But that’s not often the case in the cloud.  Instead, we need a lightweight framework that allows us to create a number of “processors” (using quotes here to avoid confusion with a CPU) that are responsible for doing their work independent of any other “processors” in the current instance.  Each “processor” can run on its own thread, but the worker role itself, instead of doing the work, simply monitors the health of all of the threads and restarts them as necessary.

The implementation is not terribly complex – but if you aren’t comfortable with threading or just don’t want to reinvent the wheel, check out the base project.  Feel free to add to or modify the project as necessary.  Let’s step through some of the concepts.

Download the sample project (Visual Studio 2010) here.

First, it doesn’t matter if you implement this in a webrole or a workerrole.  A webrole exposes the same Run() method that a workerrole does, and it doesn’t interfere with the operation of hosting a website – aside from the fact that there are limited resources per VM of course.

First up is the IProcessMessages interface.  This interface is simple, basically saying our processors need to define how long they need per work unit, and expose a Process() method to call.   Our health monitor keeps tabs on the processor, so it needs to know how long to wait before assuming the processor is hung:

image

A simple processor is then very easy to create.  We just implement the IProcessMessages interface, and code whatever logic we need our worker to do inside the Process() method.  We’re specifying that this processor needs only 20 seconds per work unit, so the health monitor will restart the worker in the event it doesn’t see progress when 20 seconds elapse.  SyncRoot isn’t needed unless you need to do some locking:

image

So far, pretty simple.  Our processor doesn’t need to be aware of threading, or handling/restarting itself.   The ProcessRecord class does this for us.  It won’t do the actual monitoring, but rather, implements the nuts and bolts of starting the thread for the current processor:

image

When the ProcessorRecord class is told to start the thread, it calls a single Run() method passing in the processor.  This method will essentially run forever, calling Process() each iteration.  Since we’re not getting notified of work, each processor is essentially polling for work.  Because of this, a traditional implementation is to say if there is work to do, keep calling Process() as frequently as possible, but if there’s no work to do, sleep for some amount of time:

image

The current implementation is simple – it doesn’t do exponential back off if there’s no work to do, it just sleeps for the amount of time specified in the ProcessorRecord.  That leaves us with one more task, and that’s defining our processors in the web/worker role Run() method.  The nice thing about this approach is that it’s quite easy to add multiple instances to scale up or down as needed:

image

In the case above, we’re creating 2 processors of the same type, giving them different names (helpful for the log files), the same thread priority, and a sleep time of 5 seconds per iteration if there’s no work to do.  In the Run() method, instead of doing any work, we’ll just monitor the health of all the processors.  Remember, the Run() method shouldn’t exit under normal conditions because it will cause the role to recycle:

image

It may look complicated, but it’s pretty simple.  Each iteration, we’ll look at each Processor.  The Timeout is calculated based on the last known “thread test” (when the thread was last known to be alive and well, plus any process time or sleep time adjustments.  If that time is exceeded, a warning is written to the log file and the Processor is reset.  Worldmaps has been using this approach for about 6 months now, and it’s been flawless.

Is this the most robust and complete framework for multithreading worker roles?  No.  It’s a prototype – a good starting place for a more robust solution.  But, the pattern you see here is the right starting point:  the role instance itself knows what processors it wants, but doesn’t concern itself with their implementation or threading details.  Each ProcessorRecord will execute its processor, and implements the threading logic, without regard to the other processors or the host.  The Processors don’t care about threading, other processors, or the host, it just does its work.  This separation of concerns makes it easy to expand or modify this concept as the application changes.

If you’re trying to get more performance out of your workers, try this approach and let me know if you have any comments.

Tags: ,

Azure | Development | Microsoft

Register To Attend A Windows Azure Virtual Hands-On Workshop

by Brian Hitney 22. April 2010 08:00

@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 http://distributed.cloudapp.net.

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.

  1. Visual Studio 2008 or Visual Studio 2010
  2. 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

image

Tags: , , , ,

Azure | Development | Microsoft | Events

MSDN Flash Forward …

by Brian Hitney 20. April 2010 05:03

Many of you reading this are already subscribed, but if you didn’t know about MSDN Flash, be sure to check it out!  Flash is a semi-weekly newsletter (delivered via email) with links to upcoming events, developer news, etc.  It’s a great way to stay connected to the development community.  (One note: be sure to enter your zip code when subscribing – it ensures we get the right events for your area!)

Here in the southeast, Glen Gordon and I partner up on contributing content to Flash, and writing the editorials.  Typically after Flash drops in your mailbox, registrations for events fill up.  The downside is: I get emails asking for help getting into events! 

So, what I thought I’d do is start a series of posts called “Flash Forward” … I’m going to do an early release of our “from the editor” section.  This will give you a chance to stay on top of upcoming events.  Now, we usually edit things a bit until the release so some things might change, but we try to call out some of the important events coming up.   And since this is a teaser for what’s in the MSDN Flash, this will hopefully get you on board if you already subscribed.

Without further ado, here’s a sneak peak at next week’s flash:

There is a whole lot going in the southeast, so listen up!

The first week of May, Carl Franklin and Richard Campbell of .NET Rocks will doing a Visual Studio 2010 Road Trip.   On Thursday, May 6th, the guys will be hitting the Raleigh-Durham area.   The guys will continue the trip to Atlanta on Friday, May 7th

The fun in Atlanta doesn’t end there – Saturday May 8th is ReMIX Atlanta!  You only have until April 27 to register for the early bird price. With 3 tracks, a vibrant community area, and awesome speakers from the community and from Microsoft, this is sure to be a great event!

The following Saturday, the Charlotte Enterprise Developers Guild is having their 2010 Code Camp – the great facilities at CPCC will ensure many hands-on sessions, so be sure to register for this event before space fills up.

And because we can’t get enough VS2010 content, we have a VS2010 launch event in Atlanta on May 20th, and we’ll be brining the best of the content to our roadshow in Raleigh on June 2 and Charlotte on June 3.

We’ll see you at the events!

Tags: , ,

Microsoft | Events

Marquee Lives!

by Brian Hitney 12. April 2010 15:59

I’m helping to organize some East Region Azure Boot Camps (www.azurebootcamp.com) – 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. 

image

image

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!

Tags: ,

Microsoft | Events | Azure

Slides from Azure Roadshow

by Brian Hitney 29. March 2010 04:50

I’ve had a number of requests for slides and resources for the recent Azure roadshow in NC and FL – here are the slides and resources.  The slides are for sessions 2 and 3:

Worldmaps application:  http://www.myworldmaps.net

Stumbler application (shown during breaks): http://www.myworldmaps.net/stumbler

SETI @ Home: http://setiathome.ssl.berkeley.edu/

Folding @ Home: http://folding.stanford.edu/

Tags: , ,

Microsoft | Events | Technology | Azure

Azure Miniseries #4: Monitoring Applications

by Brian Hitney 26. February 2010 03:58

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.

Get Microsoft Silverlight

Here are some links from the screencast:

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 http://go.microsoft.com/fwlink/?LinkId=166357.
            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;
            }
        }
    }

Tags: , , ,

Azure | Microsoft | Tech Tips

Azure Miniseries #3: ServiceConfig vs web.config

by Brian Hitney 22. February 2010 03:32

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…

Get Microsoft Silverlight

Link to original post and download links.

Tags: , ,

Azure | Microsoft | Tech Tips

Azure Miniseries #2: Deployment

by Brian Hitney 13. February 2010 13:39

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.  

Get Microsoft Silverlight

Link to original post with download links.

Tags: , ,

Azure | Microsoft | Technology

Azure Miniseries #1: Migration

by Brian Hitney 12. February 2010 03:54

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.

Get Microsoft Silverlight

Tags: ,

Azure | Microsoft | Technology

your host...

Brian Hitney
Developer Evangelist
Microsoft Corp.

About Me

My Worldmap