I wanted to let you know about an event I’ll be speaking at in early April. Along with my good friend and mentor Scott Hunter, “el master’o’ASP.NET,” I'll be presenting at the Web Camps in Dallas, Texas. I’d love to see you there.


Dallas isn’t the only stop for the Web Camps tour. Our other good buddy, Jon Galloway, has worked hard creating this year’s Web Camps content, and has been out on the road promoting all the awesome new stuff we’ve released with the ASP.NET framework and tools. Along with Mr. Hunter, I’ll be presenting demonstrations and content related to all of the awesome topics below:

  • Keynote: The ASP.NET Web Platform in Context
  • What’s new in ASP.NET 4.5 and Visual Studio 2012
  • Building and deploying websites with ASP.NET MVC 4
  • Creating HTML5 Applications with jQuery
  • Building a service layer with ASP.NET Web API
  • Leveraging your ASP.NET development skills to build apps for Office
  • Building and leveraging social web apps in ASP.NET
  • Building for the mobile web
  • Real-time communications with SignalR
  • Leveraging Windows Azure and Windows Azure Web Sites


So if you’re an ASP.NET developer, or you’ve been thinking about learning more about the new stuff available in the ASP.NET stack, come on out and join Scott Hunter and I on Friday, April 5 in Dallas, TX. We’ve got a whole series of these events lined up lots of other places, so check out the other areas where we’ll be heading and join us at one of those great events, too. 


Jon, myself, and the rest of the team welcome you to this great series of events. We hope to see you there!


I’ve been asked a lot of great questions about Windows Azure Web Sites since the feature launched in June. Things like on-premise integration, connecting to service bus, and having multiple environments (like staging, production, etc), are all great questions that arise on a pretty regular cadence. With this post, I’m going to kick off a series on solving real-world problems for web site and PaaS owners that will try to address a lot of these questions and concerns. I’ve got a few blog posts in the hopper that will address some of these questions, rather than just cover how certain things are done. Those posts are great and all (and a lot of fun to write), but they don’t answer some real-world, practical questions I’ve been asked this year. Stay tuned to this area of my site, as I’ll be posting these articles over the next few weeks and probably into the new year. As I post each of these solutions I’ll update this post so you have a one-stop shop to go to when you need to solve one of these problems.

Posts in this Series

Multiple Environments with Windows Azure Web Sites
In this post I demonstrate how to have production and staging sites set up for your web site so that you can test your changes in a sandbox site before pushing your production site and potentially causing damage to it (and your reputation). If you’ve wondered how to gate your deployments using Windows Azure Web Sites, this is a good place to start. You’ll learn how to use Windows Azure Web Sites with a GitHub.com repository and some creative branching strategies to maintain multiple environments for a site.

Managing Multiple Windows Azure Web Site Environments using Visual Studio Publishing Profiles
This post takes the same sort of scenario as presented in the first article. Rather than use GitHub.com as a means to executing a series of gated environment deployments it focuses on the awesome features within Visual Studio for web publishing. Specifically, you’ll see how to use publishing profiles to deploy to multiple Windows Azure Web Sites, so that a team of peers responsible for releasing a site can do so without ever needing to leave Visual Studio.

This post also takes a look at the idea of release management and how this solution answers the question of doing proper release management with a cloud-hosted web site. If you’ve wondered how your SDLC could fit in the idea of continuously maintaining a series of environments for gating your releases using Visual Studio’s super-simple publishing features, this is a great place to start.

Connecting Windows Azure Web Sites to On-Premises Databases Using Windows Azure Service Bus
This post introduces the idea creating a hybrid cloud setup using a Windows Azure Web Site and the Windows Azure Service Bus, to demonstrate how a web site hosted in Windows Azure can connect to your on-premises enterprise database. If you’ve been wondering how to save data from your Windows Azure Web Site into your local database but didn’t know how to do it, or if you’re thinking of taking baby steps in your move toward cloud computing, this post could provide some good guidance on how to get started.

Continuous Delivery to Windows Azure Web Sites using TeamCity
My good friend Magnus put together a very extensive and informative blog post on using Windows Azure Web Sites with TeamCity. If you're a CI user, or a TeamCity user, you'll want to check this out, as it is a great recipe for implementing your CI builds against Windows Azure Web Sites. Magnus worked really hard on this blog post and started working on it for his Windows AzureConf talk, and I'm proud to see how it came together for him.

Jim O'Neil's Blog Series on Integrating Windows Azure Web Sites and Notifications
Jim's blog series - part 1, part 2, and part 3 - are great if you're looking into implementing instant messaging with your Windows Azure Web Site. This series is great, and I feel it shows off some amazing potential and adds a whole new dimension to what's possible on the platform. Take a look at these posts, they're quite inspiring.

G. Andrew Duthie’s Series on Back-end Data Services with Windows 8 Applications
The @devhammer himself has created an awesome series on putting your data in the cloud, so your Windows 8 applications have a common place from which to pull the data. In this series, he discusses how to use Windows Azure Web Sites to create an API that can be called by a Windows 8 application. If you’re delving into Windows 8 development and have been wondering how you could use Web Sites to create the APIs you’ll be calling, this series is a must-read.

Maarten Balliauw on Configuring IIS Methods for ASP.NET Web API with Windows Azure Web Sites
My good friend and dedicated MVP Maarten just wrote up a great post on configuring IIS within Windows Azure Web Sites to support additional HTTP methods like HEAD and PATCH using configuration files. If you’re trying to do some deeper Web API functionality and have struggled with getting these types of HTTP methods supported, this could solve your problem.

Branches, Team Foundation Services, and Windows Azure Web Sites
Wouter de Kort covers how to achieve the multiple-environment approach using Team Foundation Services online. If you're using TFS and you want to set up multiple branches that deploy to a variety of web sites, this article will help you get going. This is a great introduction to using TFS for multiple branches with Windows Azure Web Sites. 


This week we announced support for nopCommerce in the Windows Azure Web Sites application gallery. Using the Windows Azure portal and with requiring zero lines of code, you can set up nopCommerce on Web Sites and get your online store up in minutes. You’ll have your very own products database, shopping cart, order history – the works. On the nopCommerce web site you can learn a lot more about the features nopCommerce offers. In this blog post, I’ll show you how to get your own store up and running on Windows Azure Web Sites.

I walked through this process today. As with other entries in the Web Sites application gallery, you really do have to do very little digging to figure out where to go to get started. It’s pretty much “start, new site, from gallery,” as you’ll see from the picture below. It shows you exactly which menu item to click in the Windows Azure portal to get started.


The next step should be pretty self-explanatory. Select nopCommerce from the list of available applications.


The next step will ask you for some database connection information. This is what will be set in your nopCommerce installation once the process is complete. I’m going to create a new database solely for use with my nopCommerce site I’m creating for this demonstration.


The next screen is one that appears in a few other application gallery entries, too. It’s the “where do you want to store your data today?” screen. I’m creating a new SQL Server database in this screen so I need to provide the database name, specify a new server’s creation, and provide the database username and password. Don’t bother writing this down, there’s an app screen for that later in this post.


Once I click OK here, my site is created. First, the portal tells me it’s creating the site:


Once the site is up and running, Windows Azure lets me know:


If I select my nopCommerce site and click the “Browse” button in the Windows Azure portal, the site will open up in a new browser instance and allow me the capability of specifying the database connection string it’ll use.


Now, I’ll go back to the Windows Azure portal’s dashboard for my nopCommerce demo site. In that dashboard page I’ll click the link labeled “View connection strings,” and a dialog will open. In that dialog I’ll see the connection string for my database. I can copy that from the dialog…


… and paste it into the nopCommerce setup window.


Of course, I’ve blocked out my site’s real connection string in this picture, but the idea is – it doesn’t get much easier. Once I click the “Install” button in the nopCommerce setup page, the site and database schema, as well as some sample data points, will be installed automatically and the site configured to access the database. Once the setup process is complete, I’ll be redirected to my very own store site.


In the navigation bar I’ll click on the “My Account” link, login, and then, at the very tip-top of my browser I’ll see a link to get to the Administration panel of my new nopCommerce store site.


The administration portal for the nopCommerce product promises to give me just about everything I’d need to sell some stuff, know how my sales are doing, and so on. I can pretty much do whatever I need to do using their rich, extensive administration functionality.


If you’ve been thinking of setting up a store, with a shopping cart, online, or you’ve been asked to do so and are more interested in getting it up and running quickly than you are with re-inventing the wheel by writing custom code, check out nopCommerce. Get your free Windows Azure trialwhich comes with 10 free web sites for free – right here, then set up your own nopCommerce site and have your products selling in your store.


Next week I’ll be speaking at the Web Camps events in India. The web camps series, put together by my trusty teammate Jon Galloway, offers web developers a glimpse into all the new web-related stuff the ASP.NET and Visual Studio teams have been cooking. I’m looking forward to the trip, as I’ve never been further East than Sweden. My team has this habit of coming up with nifty out-of-office emails so I decided to make a map, originally thinking I’d jam the map into an email. The image ending up being pretty huge so I’m sparing the team the extra room in their mailboxes by sharing it here instead.


This should be a pretty neat trip. I’m thankful for the opportunities I get like this to talk about and demonstrate the awesome work the engineers do here. They make that part of the job easy. When you love a product as much as I’ve loved ASP.NET and Visual Studio for this long, the idea of showing folks how to use it and to give them some new tricks is cake. This sort of thing – talking about how awesome our products are and about the awesomer people involved in their creation – is the best part of my job. 

What makes that part of job difficult is the missing-of-family while I’m on the road. My wife the most supportive woman you could have the luck to know and I’m the luckiest guy in the world for having her there to support me. My sons always miss me, so that’s the saddest part of every trip, but they know how it works so they’re usually pretty forgiving, as the code below demonstrates. Coming home to this familiar program is without a doubt the icing on the cake.


So tomorrow I’ll start my first trip to the other side of the globe. Wish me luck, and if you’re in the area, come on out to learn some great stuff about ASP.NET, Windows Azure and Visual Studio!


The third post in the Solving Real-world Problems with Windows Azure Web Sites blog series I’ll demonstrate one manner in which a web site can be connected to an on-premises enterprise. A common use-case for a web site is to collect data for storage in a database in an enterprise environment. Likewise, the first thing most customers want to move into the cloud is their web site. Ironically, the idea of moving a whole enterprise architecture into the cloud can appear to be a daunting task. So, if one wants to host their site in the cloud but keep their data in their enterprise, what’s the solution? This post will address that question and point out how the Windows Azure Service Bus between a Windows Azure Web Site and an on-premises database can be a great glue between your web site and your enterprise.

We have this application that’d be great as a cloud-based web application, but we’re not ready to move the database into the cloud. We have a few other applications that talk to the database into which our web application will need to save data, but we’re not ready to move everything yet. Is there any way we could get the site running in Windows Azure Web Sites but have it save data back to our enterprise? Or do we have to move everything or nothing works?

I get this question quite frequently when showing off Windows Azure Web Sites. People know the depth of what’s possible with Windows Azure,  but they don’t want to have to know everything there is to know about Windows Azure just to have a web site online. More importantly, most of these folks have learned that Windows Azure Web Sites makes it dirt simple to get their ASP.NET, PHP, Node.js, or Python web site hosted into Windows Azure. Windows Azure Web Sites provides a great starting point for most web applications, but the block on adoption comes when the first few options are laid out, similar to these:

  • It is costing us increased money and time to manage our web sites so we’re considering moving them into Windows Azure Web Sites
  • It will it cost us a lot of money to move our database into the cloud
  • We don’t have the money to rework all the applications that use that database if moving it to the cloud means those applications have to change.
  • We can’t lose any data, and the enterprise data must be as secure as it already was, at the very least.
  • Our web sites need to scale and we can’t get them what we need unless we go to Windows Azure Web Sites.

This is a common plight and question whenever I attend conferences. So, I chose to take one of these conversations as a starting point. I invented a customer situation, but one that emulates the above problem statement and prioritizations associated with the project we have on the table.

Solving the Problem using Windows Azure Service Bus

The first thing I needed to think about when I was brought this problem would be the sample scenario. I needed to come up with something realistic, a problem I had seen customers already experiencing. Here’s a high-level diagram of the idea in place. There’s not much to it, really, just a few simple steps.


In this diagram I point out how my web site will send data over to the Service Bus. Below the service bus layer is a Console EXE application that subscribes to the Service Bus Topic the web application will be publishing into the enterprise for persistence. That console EXE will then use Entity Framework to persist the incoming objects – Customer class instances, in fact – into a SQL Server database.

The subscription internal process is also exploded in this diagram. The Console EXE waits for any instance of a customer being thrown in, and it wakes up any process that’s supposed to handle the incoming instance of that object.

The Console EXE that runs allows the program to subscribe to the Service Bus Topic. When customers land on the topics from other applications, the app wakes up and knows what to do to process those customers. In this first case, the handler component basically persists the data to a SQL Server installation on their enterprise.

Code Summary and Walk-through

This example code consists of three projects, and is all available for your perusal as a GitHub.com repository. The first of these projects is a simple MVC web site, the second is console application. The final project is a core project that gives these two projects a common language via a domain object and a few helper classes. Realistically, the solution could be divided into 4 projects; the core project could be divided into 2 projects, one being the service bus utilities and the other being the on-premises data access code. For the purposes of this demonstration, though, the common core project approach was good enough. The diagram below shows how these projects are organized and how they depend on one another.


The overall idea is simple -  build a web site that collects customer information in a form hosted in a Windows Azure Web Site, then ship that data off to the on-premises database via the Windows Azure Service Bus for storage. The first thing I created was a domain object to represent the customers the site will need to save. This domain object serves as a contract between both sides of the application, and will be used by an Entity Framework context class structure in the on-premises environment to save data to a SQL Server database.

With the domain language represented by the Customer class I’ll need some Entity Framework classes running in my enterprise to save customer instances to the SQL database. The classes that perform this functionality are below. They’re not too rich in terms of functionality or business logic implementation, they’re just in the application’s architecture to perform CRUD operations via Entity Framework, given a particular domain object (the Customer class, in this case).

This next class is sort of the most complicated spot in the application if you’ve never done much with the Windows Azure Service Bus. The good thing is, if you don’t want to learn how to do a lot with the internals of Service Bus, this class could be reused in your own application code to provide a quick-and-dirty first step towards using Service Bus.

The ServiceBusHelper class below basically provides a utilitarian method of allowing for both the publishing and subscribing features of Service Bus. I’ll use this class on the web site side to publish Customer instances into the Service Bus, and I’ll also use it in my enterprise application code to subscribe to and read messages from the Service Bus whenever they come in. The code in this utility class is far from perfect, but it should give me a good starting point for publishing and subscribing to the Service Bus to connect the dots.

Now that the Service Bus helper is there to deal with both ends of the conversation I can tie the two ends together pretty easily. The web site’s code won’t be too complicated. I’ll create a view that site users can use to input their customer data. Obviously, this is a short form for demonstration purposes, but it could be any shape or size you want (within reason, of course, but you’ve got ample room if you’re just working with serialized objects).

If I’ve got an MVC view, chances are I’ll need an MVC action method to drive that view. The code for the HomeController class is below. Note, the Index action is repeated – one to display the form to the user, the second to handle the form’s posting. The data is collected via the second Index action method, and then passed into the Service Bus.

The final piece of code to get this all working is to write the console application that runs in my enterprise environment. The code below is all that’s needed to do this; when the application starts up it subscribes to the Service Bus topic and starts listening for incoming objects. Whenever they come in, the code then makes use of the Entity Framework classes to persist the Customer instance to the SQL Server database.

Now that the code’s all written, I’ll walk you through the process of creating your Service Bus topic using the Windows Azure portal. A few configuration changes will need to be made to the web site and the on-premise console application, too, but the hard part is definitely over.

Create the Service Bus Topic

Creating a Service Bus topic using the Windows Azure portal is relatively painless. The first step is to use the New menu in the portal to create the actual Service Bus topic. The screen shot below, from the portal, demonstrates the single step I need to take to create my own namespace in the Windows Azure Service Bus.


Once I click the Create a New Topic button, the Windows Azure portal will run off and create my very own area within the Service Bus. The process won’t take long, but while the Service Bus namespace is being created, the portal will make sure I know it hasn’t forgotten about me.

service- bus-getting-created

After a few seconds, the namespace will be visible in the Windows Azure portal. If I select the new namespace and click the button at the bottom of the portal labeled Access Key, a dialog will open that shows me the connection string I’ll need to use to connect to the Service Bus.


I’ll copy that connection string out of the dialog. Then, I’ll paste that connection string into the appropriate place in the Web.config file of the web application. The screen shot below shows the Web.config file from the project, with the appropriate appSettings node highlighted.


A similar node also needs to be configured in the console application’s App.config file, as shown below.


In all, there are only two *.config files that need to be edited in the solution to get this working – the console application’s App.config file and the web application’s Web.config file. Both of these files are highlighted in the solution explorer view of the solution included with this blog post.


With the applications configured properly and the service bus namespace created, I can now run the application to see how things work.

Running the Code

Since I’ll be using Entity Framework to scaffold the SQL Server database on the fly, all I’ll need to do to set up my local enterprise environment is to create a new database. The screen shot below shows my new SQL database before running the console application on my machine. Note, there are no tables or objects in the database yet.


The first thing I’ll do to get running is to debug the console application in Visual Studio. I could just hit F5, but I’ll be running the web application in debug mode next. The idea here is to go ahead and fire up the console application so that it can create the database objects and prepare my enterprise for incoming messages.


The  console application will open up, but will display no messages until it begins processing Customer objects that land on the Service Bus. To send it some messages, I’ll now debug the web application, while leaving the console application running locally.


When the web site fires up and opens in my web browser, I’ll be presented the simple form used to collect customer data. If I fill out that form and click the Save button, the data will be sent into the Service Bus.


By leaving the console application running as I submit the form, I can see the data coming into my enterprise environment.


Going back into SQL Server Management Studio and refreshing the list of tables I can see that the Entity Framework migrations ran  perfectly, and created the table into which the data will be saved. If I select the data out of that table using a SQL query, I can verify that indeed, the data was persisted into my on-premises database.


At this point, I’ve successfully pushed data from my Windows Azure Web Site up into the Service Bus, and then back down again into my local enterprise database.


One of the big questions I’ve gotten from the community since the introduction of Windows Azure Web Sites to the Windows Azure platform is on how to connect these sites to an enterprise environment. Many customers aren’t ready to move their whole enterprise into Windows Azure, but they want to take some steps towards getting their applications into the cloud. This sort of hybrid cloud setup is one that’s perfect for Service Bus. As you’ve seen in this demonstration, the process of connecting a Windows Azure Web Site to your on-premises enterprise isn’t difficult, and it allows you the option of moving individual pieces as you’re ready. Getting started is easy, cheap, and will allow for infinite scaling opportunities. Find out how easy Windows Azure can be for Web Sites, mobile applications, or hybrid situations such as this by getting a free trial account today. I’m sure you’ll see that pretty much anything’s possible with Windows Azure.