Wednesday, November 12, 2008

Windows Azure: How I deployed an existing Silverlight application in 30 minutes

image Almost two weeks ago I posted about my first experiment with Amazon EC2, and how I was able to get an existing application (our Sproodle SaaS offering) up and running on EC2 in a couple of hours. That was the same day as Microsoft announced Windows Azure, and of course I wanted to try the same application to run on Azure as well. Two days later I finally got my Azure account, and to my delight I was able to get our application up and running on Azure in about 30 minutes. Which in my mind seriously rocked. In this post I will explain the steps I went through to deploy an existing application to Azure, and talk a bit about how Azure compares to EC2.

Oh, and I’m pretty sure this was the first real (real as in real application, not a Hello World sample) Windows Azure deployment from Finland (on the 29th of October) :).

Deploying an existing application to EC2

There are a bunch of Hello World-examples for how to create a small app and deploy it to Azure, but when I first did this deployment I couldn’t find a sample that showed how to take an existing application and deploy it. However, the mechanism behind deploying to Azure is pretty simple, and essentially what you need is a deployment project. In Visual Studio you can’t add just the deployment project to an existing solution, you always get a new web application as well. This may not seem that useful at first glance, but it’s actually not that hard to change it to deploy whatever project you want. Below you can find out how. I’m using a sample app for this article, since the project I actually used when I did this at PDC is a pretty large and complex beast.

Step 1. In your existing Silverlight application solution, add a new Cloud Service project

image

My sample application solution contains two projects. The first is the Silverlight application, which in this case just writes “I like clouds! on a blue background. The other project is a web application that shows the Silverlight app. No changes has been made to this project, it’s just straight out of the box.

Now, to add cloud goodness we have to cheat a bit. Currently (as far as I know) Visual Studio won’t let you add a Cloud Service project (which is needed for deploying to Azure) and have that deploy an existing web application. It always wants to create a new application for you. So what you can do is to add a new “Web Cloud Service” to your solution. Let’s call it “CloudService”.

 

 

 

Step 2. Get rid of the generated WebRole-project

imageWhen you add a new “Web Cloud Service”-project Visual Studio actually creates two projects for you. One is the deployment project (“CloudService” in this example), and the other is a web application (“CloudService_WebRole”). As far as I can tell the second one is just a regular web application.

The deployment project is set up to deploy the CloudService_WebRole-project, and I haven’t found a way to change which project it tries to deploy through the Visual Studio UI. So we need to wire it up to deploy our existing  “SilverlightCloudApplication.Web” instead.

 

 

 

Step 3. Use notepad to edit the project file.

This is the scary part. If you’ve poked around in the Visual Studio project files before you know that they are just XML files, and note even very complex ones at that. It turned out that all we need to do in order to make “CloudService” deploy any web project we want is just change which project its deployment point refer to.

So what we first need to figure out is the ID for our “SilverlightCloudApplication.Web”-project. First close Visual Studio. Then open the file “SilverlightCloudApplication.Web.csproj” in notepad (or your favorite text editor). Look for an XML element called “ProjectGuid”, and copy the contents of that element. In my sample project here it was “{61CADBB5-24ED-4F11-848B-7754877F7A06}”, but it will be something different for you project.

Next open the project file for the “CloudService”-project. Look for an XML element called “ItemGroup”, and another called “ProjectReference” below that. You need to edit three things in there. First, change the “Include”-attribute of the “ProjectReference”-element to be the path to the project of the web application you want to deploy. Next, change the contents of the “Name”-element to be the name of your web application. And finally, change the contents of the “Project”-element to be the guid you copied from the web application project file earlier.

Below you can see a screenshot that gives you an idea of what the results of your edits should look like.

image

image Save the file, and restart Visual Studio. When you open the solution you will see that the CloudService now refers to your web application (in this case “SilverlightCloudApplication.Web"). At this point you can safely delete the “CloudService_WebRole”-project, as it is no longer needed.

 

Now you should be able to build and publish your application to Azure. Happy cloud computing.

 

 

 

Comparing Azure to Amazon EC2

A lot of people have asked me which is better, Azure or Amazon EC2? First I want to point out that this is a bit of an apples to oranges-comparison. Sure, they both are part of that fuzzy bag of stuff called “cloud services”, but from a (service) perspective they are quite different. What Amazon does is give you virtual servers that you can use to run whatever you want on, and what Azure does is give you the ability to deploy web applications to the cloud. The difference is primarily that with Amazon you still have to operate and maintain the environment your application runs in, and with Azure Microsoft is taking care of all of that for you. And they seem to do it in a very impressive way. Their environment even takes care of staging for you, so that you can test your new deployment before you switch out the currently live one.

So which one do I prefer? I really like Windows Azure. I also like Amazon EC2. I think there’s room for them both. Currently I think Azure is the better choice if what you want to do is run a web application in the cloud. Most software developers do not want to have to operate the environment, for many reasons (cost being one of the most popular ones).

If you need full control over the environment your application runs in, you probably cant use Azure (at least not in its current state). For example, I have to admit that I ended up cheating a bit when I deployed Sproodle to Azure. Because it has a database and a bunch of WCF services on top of that database I couldn’t deploy those to Azure, since it doesn’t supply you with a SQL Server. I would have had to re-architect the services so that they can run in Azure on top of SQL Services (which is a completely different animal from SQL Server). My kung fu may be strong, but not strong enough to do that in half an hour. :) So what I did was keep the services in the EC2-environment I’d set up a couple of days earlier, and set up my Silverlight app to call them from there instead. So I ended up being double-clouded, the front end running on Azure and the back-end on EC2. Not ideal, but hey, it worked! :)

Tuesday, November 11, 2008

The only way to predict the future is to invent it

Ok, so that was a slight paraphrasing of Alan Kay.

I just listened to Miha Kralj talk about how IT will change over the next 10 years, and why we should care about this. It was a refreshingly un-TechEd:y session, focusing more on global issues shaping our industry, and on trends that will be as disruptive as the move from mainframes was a few decades ago. I found the session to be very insightful, and I enjoyed it thoroughly. It’s great that the TechEd organizers see that it is important to make us developer types aware of what’s going on around as, and what the bigger picture is.

I won’t repeat the whole talk here, but there were a few topics that resounded with me which I want to comment a bit on.

  1. How will the mySpace and facebook-generation accept the current rules of the corporate environments our generation and the one before it have created? Obviously they will not. This is something I’ve talked to several of our customers about, and I suspect it’s something that will keep us IT people very busy in the next few years. The next generation (which is actually now entering the workforce) will have demands we can’t meet, and we will have to find a way to supply it. The only problem I see is that we’ll have to meet it fast, and shipping things fast isn’t something our industry has traditionally been that good at. As an industry we need to improve greatly in order to keep our future users happy.
  2. Utility computing and IT as a service. Ok, I’m sure everyone agrees that obviously this is a major disruptor. Hardware is becoming less and less interesting (count the number of hardware vendors exhibiting at TechEd if you want proof of that), and being green requires that the number of data and hosting centers in the world is reduced (and located in places where it makes sense).
  3. How we interact with computers will and needs to change. One of my favorite quotes from the presentation was “Mouse and keyboards are so nineties”. I couldn’t agree more. Having used an iPhone for a few months now I wouldn’t want to go back to a non-touch enabled phone. It’s just so much faster, easier and more intuitive to use. And Windows 7, with its touch-enabled interface is something I’m really looking forward to. Let’s hope the hardware vendors get with the program quickly enough, so that there actually are good devices out there when version 7 ships.
  4. Social computing is here to stay. It helps fulfill our basic human needs for interaction with others, and to be perceived by others in a way that we find fulfilling. And it is entering the workplace. The issues raised in point one of this list will make sure of that.

All of these (and the rest of the stuff in the presentation) are signs that our industry is maturing. In certain areas (hardware and hosting being one of them), gone will be the snake oil-peddlers and the tinkerers and the garage operations. Overall we will have to accept that we and those who came before us built our current computer-oriented world, but we weren’t born into it. The generations after us, the “digital natives”, will be the ones that define the rules, and the rest of us, the “digital immigrants”, will be left by the wayside, unless we make an effort both to enable our future world and to make sure we stay part of it. Otherwise this time the natives will kick out the immigrants.

Oh, and on a not-so-connected point, Miha is one of that rare breed of speakers who actually knows how to present well and how to construct the information you are presenting. Great and simple slides, balancing verbal, visual and aural communication. Please all of you who do presentations, read the book Beyond Bullet Points, and have a look at PresentationZen. You need it, seriously.

Saturday, November 08, 2008

Going to TechEd EMEA 2008

Tomorrow I’m flying to Barcelona to take part in TechEd EMEA 2008 for some more technical insights and some networking. I just barely got my PDC-luggage emptied and did the laundry and almost got rid of the jetlag, so I can’t really say I’m too excited about the travelling part of this trip. But TechEd is always fun and interesting, so in the end I’m happy I’m going. Barcelona is a great city, and I’m happy to get some more sun before the Finnish winter sets in properly (ok, as properly as it does in Helsinki).

I’ve got a couple of blog posts brewing that I hope to get done during the week, and of course I’ll try to post about any new and interesting stuff I come across.

Monday, November 06, 2006

SharePoint 2007 (MOSS) went RTM

Apparently Microsoft Office SharePoint Server 2007 was released to manufacturing half an hour ago! Yay!

Now, if it only would appear on MSDN Downloads...

SharePoint as a development platform

Today I participated in the TechEd preconf-session, and one of the really key takeaways from the presentation was that SharePoint 2007  is not about collaboration, at least not anymore.

Early on in the preconf today Ted Pattison asked what SharePoint is really about. The obvious and incorrect answer was "collaboration". I would probably have given that answer as well, even though I know that you can do so much more with version 2007 than before. However, the correct answer according to Ted was that it is about "provisioning sites". That got me thinking about how I perceive SharePoint at this point (heh), and how this has changed as SharePoint has developed.

As of Microsoft Office SharePoint Server 2007 (Microsoft Windows SharePoint Services 3.0) we should really think of SharePoint as a platform for application development. Of course, at this point people will be saying "Yeah, but we've had that with Notes since the nineties!". Sure, but with SharePoint the development happens with the same tools and frameworks as the rest of your .NET development and in Visual Studio. With the new version customization in SharePoint has finally reached a point where you can extend it properly yourself, and in addition make it look the way you want (applications will no longer have that typical SharePoint-look).

I've blogged about SharePoint before, but not about how my view of the product has changed over the years, and perhaps why I've come to love it. We've been using SharePoint 2007 (or SharePoint Services V3) for a few months at work now, and that has given me a really positive feeling about the product.

I first looked at SharePoint about 4 years ago, and the version that was then available was version 2001. We had some customers that were interested in document management systems, and we were interested in figuring out if SharePoint could help them. It couldn't. SharePoint 2001 always felt very half-baked to me, and it had some horrible restrictions in it relating to access management, and it was horrible to try and modify the visuals of SharePoint, for example if you wanted to brand it according to the customer's visual image. At that point we decided to not work with SharePoint 2001, as version 2003 was not far away.

With version 2003 things changed a bit. Access rights were improved, and modifying it became easier. The words "document management" had also fallen out of favor in the meantime; the current trend was "collaboration". I've always had problems with the word "collaboration". It is too close to "collaborator", which at least in Swedish has quite a negative connotation. It's also one of those word who are difficult to explain to customers; they can understand what document management is about but since collaboration can be so much more it also becomes much more difficult to comprehend. For most people (at least IT departments who were purchasing document management systems) collaboration sounded difficult, what they needed was a way to store documents.

Anyway, we've done a bunch of projects with SharePoint 2003, but what we've always run into is that once you want to bring the customization of it beyond a certain point you really get stuck in the mud. And with limited support for .NET and almost no integration with Visual Studio development was quite cumbersome. And you could only dream of decent debugging.

After looking at SharePoint Server 2007 at previous TechEds and at PDC I was getting pretty excited about it. The really major thing that got me exited was the fact that it had been re-implemented using ASP.NET 2.0, and that things from .NET 3.0 (namely Windows Workflow) was going to be included in it.

At the same time the Document Management vs. Collaboration discussion had taken a bit of a turn, since the whole concept of what a document is had changed. Instead of thinking in terms of a document being something you created in your Office applications you instead had to start thinking in terms of a document being a way to package business information for communicating with someone around it. Essentially Microsoft had started talking about "Information Management", and was highlighting how you could use InfoPath and Smart Documents (and other features in Office 2003) to work on information from Line of Business applications, using XML and Web Services.

And this was where the pieces fell into place with regards to SharePoint. Just being able to through a web page upload documents to a central storage has given way to being able to providing you with a framework for building information-centric business process-enabling applications, and having these work within the ecosystem that is Office 2007 and published across you Intranet or Extranet. One proof for this is that Microsoft themselves are putting SharePoint into most of their applications that require some kind of sites, especially if they are intended for usage within an Intranet.

There's a lot of need in today's enterprises for information-intense applications that need to interact with LoB applications and people. We do these kinds of application regularly. The problem is that creating document handling and workflows between people is quite time consuming. SharePoint seems perfectly positioned to help with this. Instead of writing our own ASP.NET apps that do all the work we can use all the great document and information-management stuff in SharePoint, and on top of that build the thing that will give our customers business value. And certainly more quickly than if we had to develop all of it ourselves. In addition, we get great interoperability with the rest of the Office tools. I like!

Saturday, November 04, 2006

TechEd 2006 in Barcelona

I'm getting ready for the TechEd Developers conference in Barcelona. As always I'm pretty excited about the prospect of getting to spend a week focusing on all the great new stuff from Microsoft. Having a chance to get away from the daily work stuff and just immerse oneself in new technology does wonders for my creativity.

Since Vista and Office 2007 are just around the corner there will be a lot of stuff about those at TechEd. But the local.live.com-team is also up to something, they will apparently be making some kind announcement next week as well, on the 7th of November. Even though I've yet to find a real business case for using maps in our solutions I'm still quite interested in the possibilities. We've done some concepts using MSCRM and maps, which is something that potential customers find cool, even if they don't have a real business need for it.

Anyway, more on TechEd once the conference gets started.