Tuesday, April 27, 2010

RockNUG April 2010 Materials: Silverlight 4

On April 14th, I presented an introduction to Silverlight 4 and its new user interface enhancements. Here is the source code from the talk.


Some takeaways we discussed:

Out-of-browser support

Silverlight 4 now offers more capabilities when applications are installed out-of-browser. To enable this feature, look at the Silverlight project’s Properties. You’ll then see an option for enabling out-of-browser, follow
After selecting this option, view the out-of-browser settings:
Here, you can customize the shortcut name and window title, as well as a description that pops up when you float the mouse over your desktop shortcut. In our demo app, I also set the window size, based on our MainPage user control. Going further, notice the checked box highlighted. This grants elevated privileges to our application when running out-of-browser, which offers some extra features (such as using the native network stack instead of the browser’s network stack).

As an example of elevated network privileges, this app can communicate with the Klout social networking service (see www.klout.com for more details). When running out-of-browser, the app can retrieve a twitter user’s social relevance score. For example:


Note that this feature is disabled when running from the browser. Also note that Klout requires an API key. Simply visit http://developer.klout.com/ to request an API key. Then simply open MainPageViewModel.cs and search for kloutKey. Now just place your key here and you should be up and running.

Another cool out-of-browser feature is the Notification Window, similar to something you see in Microsoft Outlook in the bottom-right corner of your desktop when new mail arrives.  In the demo, drop a picture onto the drop target, and you’ll see a window pop up.  If you look at the code-behind, you’ll see two samples for setting up the notification window’s content. Note: you won’t see the pop-up window if you’re running in the browser.

Debugging out-of-browser apps

While we didn’t look at this during the demo, here’s how to debug an out-of-browser app with Visual Studio 2010. First, set the Silverlight project as the startup project. Then run it, and install it out-of-browser. Now shut down the app, view the Silverlight project’s properties, and choose the Debug tab. Then simply choose the “Out-of-browser application” radio button:


That’s it. Now when you hit F5, your out-of-browser app should load, and your breakpoints will be hit as you’d expect.

Update checks

Ok, this was around in Silverlight 3, but since I attempted to show this and it refused to work, I thought I’d explain why, and how to make it work for you. For auto-update to work, the web app needs to be the startup project, not the Silverlight app. Once you set the correct startup project, the application update-check works just fine.

Media support

You now have access to all of your audio and video devices. When I demo’d this, we had two webcams to choose from. The first time you select a video device, you’ll see the Silverlight warning box. After you agree to allow the app to use the webcam, you won’t see the warning box again. There’s also an option to remember your preference so you won’t be prompted again when re-running the application. I added a Stop button, which returns the video rectangle to a green background.

Improved mouse support

Silverlight 4 now has events for right-click actions, as well as mouse scroll wheel support. I demo’d right-click support by adding a popup window when right-clicking the drop-target button.

Drag-n-drop support

You can now drag files from your desktop or file folders to a user interface element. I showed this by setting up a button as a drop-target. This button accepts image files such as png and jpg.

Visual Studio improvements

While this isn’t specifically related to Silverlight 4, Visual Studio 2010 now has a built-in XAML Visualizer. This means you no longer need to open Expression Blend simply to layout your user controls. Blend still has a considerable feature set beyond that of Visual Studio, especially when managing visual states and animations. For general layout, the built-in visualizer should be fine.


I showed just how easy it is to create printable output by instantiating a new PrintDocument object, setting the PageVisual property to a part of the visual tree (such as the photo button, or the entire page), and executing the Print method.

Implicit Styles

In Silverlight 3, you were required to specify a style that targeted a specific control type and give the style a name. Then, any control of that type would need to specify a style explicitly. For example, if you had 20 buttons, you’d first need to create a new button style and then reference that style from each button.

In Silverlight 4, you can create an unnamed style (again targeting a specific control type). Now, for all controls of that type, they will automatically get styled with the unnamed “implicit” style you created. Don’t worry – you can still created explicitly-named styles, and controls specifying these named styles will override the implicit styling. Take a look at App.xml to see both an explicit and implicit style:


Then look at the two buttons in the demo app:


Lots more!

There are many more features in Silverlight 4, such as the new COM Interop support. For a more complete list, check out Tim Heuer’s post, where he provides descriptions or samples for each of the new features. Note that he Tim has a follow-up link to updates that were introduced in the Release Candidate. All of this applies to the official Silverlight 4 Release-To-Web (RTW) that shipped on April 15.

To get started, visit the Silverlight 4 developer page to grab the latest SDK and Silverlight developer runtime. You’ll also need Visual Studio 2010, which is available from MSDN. There’s also an Express version freely available for download.

Monday, April 26, 2010

Azure Blogs and Team Voting Sites

I recently compiled a list of all blog sites used by the Azure team, as well as voting sites for future features. The entire post can be found here.

Azure team blogs and voting sites

The Azure team has several blogs announcing new features, Azure sites, integration tools, customer stories, and general platform updates:
  • Windows Azure blog – visit this blog to see the latest platform updates, as well as OS updates and tools for platform integration
  • SQL Azure blog – this blog is dedicated to the Azure-specific version of SQL Server.
  • Azure AppFabric blog – this blog is specific to AppFabric features such as access control, service bus, and experimental features, called AppFabric LABS.
  • Azure Storage blog – this blog is dedicated to Azure Storage (blobs, tables, queues, and related SDK support), including code samples and useful tools.
  • Codename Dallas blog – this blog covers the latest information about the new Azure data-provider service.
Aside from blogs, the Azure team is soliciting feedback for future features. You can cast your votes and be heard here:

Friday, April 23, 2010

May 12 – Launching and Monitoring your First Azure App

Join me online May 12 at 4pm Eastern, when I present at the Azure User Group, hosted in LiveMeeting. During this talk, we’ll go over the basic building blocks of an Azure application. We’ll then create our first Azure app and see how to deploy it into the cloud. We’ll also see how to monitor an app once it’s deployed.

Please register here if you’d like to attend.

For more information about the Azure User Group, visit the LinkedIn group page or follow AzureUG on twitter.

Tuesday, April 13, 2010

Azure: Staging and Compute-Hour Metering

In this post, I talked about how web and worker roles are considered live the moment they are deployed, whether stopped or running. I received a few follow-up questions about billing when using the Staging area, as well as clarification on how compute-hours are measured.


Production and Staging

When deploying to Azure, you have a choice between Production and Staging:


This comes in handy when upgrading your application. Let’s say you have an application already in Production, and you now have a new version you’d like to upgrade to. You can deploy that new version to a separate Staging area, which provides you with a separate “test URL” as well as any worker and web roles your application needs. You can run this app just like you’d run your production app. When you’re done testing, swap staging and production. This is effectively a Virtual IP address swap, so your end-users simply see an upgraded application as soon as you choose to execute the swap.

This is a terrific feature, allowing you to test an application without service disruption. It also allows you to quickly swap back to the previously-deployed version if something go wrong after deploying your new version to production.

Once you’re sure your new version is working ok, consider deleting your service from Staging. Be aware that your staging area is also consuming virtual machine instances. Staging instances and Production instances are equivalent: Each instance is a Virtual machine; Staging instances are billed just like Production instances. If you leave your service deployed to both Production and Staging, you will be accruing Compute-Hour charges for both. Just keep this in mind when estimating your monthly Azure costs.


How the hour is metered

As each application is deployed, its virtual machines are created. The moment those virtual machines are in place, metering begins. This includes stopped services. For instance: assuming we clicked Deploy on the Production area of our service, and uploaded an application comprising one worker role and one web role, we’d then see our deployment in a stopped state:


At this moment, the billing clock begins for each of the instances, and billing is based on a 60-minute window: If you deploy at 4:16pm, your 60-minute window is from 4:16pm to 5:16pm (it’s not 4pm-5pm). In this example, I have two roles, with a combined consumption of 2 compute-hours per clock-hour.
If I decide to stop either of these roles before the entire hour is consumed, it’s still metered for the full hour.


Multiple Deployments in a Clock-Hour

Let’s say I delete my deployment after only 5 minutes. And then I decide to deploy again to Production. At this moment, the clock starts again for my new deployment. Using our sample app above, with one worker role and one web role:
  • Deploy to Production at 4:16pm, delete deployment at 4:21pm. Compute-hours billed: 2
  • Deploy again to Production at 4:25pm, delete deployment at 4:30pm. Compute-hours billed: 2
  • Total clock time: 14 minutes. Total compute-hours: 4
I realize this is a contrived example, but I want to emphasize the fine details of compute-hours:
  • Each instance is metered from the moment it comes to life in a Virtual Machine.
  • Compute-hours are rounded up to the nearest hour. So a service is metered at 1 compute-hour, whether it runs for only 5 minutes or 59 minutes.
  • Services deployed within the same clock-hour are completely unrelated, billing-wise. If you stop and delete your application and then deploy it again, all within the same clock-hour, you will still be billed separately for each deployment.

Wednesday, April 7, 2010

April 14: Silverlight 4 Talk at RockNUG

On Wednesday, April 14, I'll be giving a Silverlight 4 talk at the Rockville .NET User Group.

Silverlight 4 was first introduced at PDC in November, and has some really cool new enhancements. I'll be showing a bunch of these, and I’ll make my demo code available for you to download and try out on your own.

Now for the even-cooler cool part: Silverlight 4 officially ships April 13, only one day prior to this talk! So this will be one of the first user group demos where you’ll see the officially-official Silverlight 4 in action!

The fun starts at 6:30, when Kevin Jones shows off debugging in Windows 7 and XP at the same time. Then we chow down on pizza and guzzle delicious carbonated beverages. And then it’s time for some Silverlight Goodness!

Oh… did I mention door prizes???

See you there!

Friday, April 2, 2010

My New Shortlink

I'm really enjoying the benefits of link-tracking, and I make use of http://bit.ly on a daily basis. Recently I applied for a bit.ly Pro account, which I received today. In honor of the occasion, I registered a new short-name for all my new short links: http://dmak.us.

What’s really cool: Now that I have my new shortlink, all my old http://bit.ly links work with http://dmak.us as well. For instance, both of these links go to http://www.davidmakogon.com:

Plus,  my statistics for older links remain unchanged.

Currently bit.ly Pro is in beta. Applications are being accepted here.

If you’re viewing this blog post, that means my new shortlink is working. Thanks for visiting!