Monday, February 8, 2010

Visual Studio 2010 side-by-side with Visual Studio 2008

Well, BETA2 of Visual Studio 2010 was announced with GO LIVE license, upgrade capability to RTM and side-by-side working with existing VS2008 installations.

Well, maybe if you are using Visual Studio to compile and run your “Hello World” Console or Web Application you will have no issues running side-by-side.

However, if you really want to explore all the new technologies, while still keeping “old” projects running, you simply can’t use both Visual Studios side-by-side. And here is one particular case in which you simply have to choose whether to stay on VS2008 or go for VS2010 and migrate your projects to 2010, because they will not be supported on VS2008. The special case is called:

WCF RIA Services

RIA Services is designed to make our Silverlight life easier, but instead it brings only troubles (when using side-by-side). And why? Because WCF RIA Services works either with VS 2010 and SL4 OR VS2008 SP1 and SL3. There is no side-by-side! If you have existing project(s) on VS 2008 SP1 with WCF RIA Services, you simply can’t go and explore VS2010 SL4 and WCF RIA Services within VS 2010.

Although you might want to say it is limitation for WCF RIA – yes, it is. But I can use both VS2010 and VS2008SP1 for Windows Azure projects. And for me – side-by-side, means “side-by-side” without any “but”.

So for me so far – no side-by-side.

Sunday, February 7, 2010

MySQL hosted on Windows Azure

People are often asking whether MySQL is supported on Windows Azure. The simple answer is YES, you can run a MySQL on Windows Azure! Great!

But is it worth? I would say NO! And here are my thoughts on that.

First, take a sneak peak at the presentation of Mohit Srivastava and Tushar Shanbhag from PDC’09: Developing PHP and MySQL Applications with Windows Azure. Or download the slides and take a quick look of “OK, you can run MySQL on Windows Azure”. After one hour of amazing talk we will be almost convinced that we definitely can run MySQL on Windows Azure.

BUT…

I would question the value of bringing a MySQL to Azure!

What is Windows Azure? Here are just a couple of quotes from Introducing the Windows Azure platform and Introducing Windows Azure white papers:

Windows Azure is designed to support applications that scale out, running multiple copies of the same code across many commodity servers.

The intrinsic support for scale-out applications and scale-out data that Windows Azure provides can handle much larger loads than more conventional Web technologies.

The answer grows out of the primary Windows Azure goal of supporting massively scalable applications. Traditional relational databases can scale up, handling more and more users by running the DBMS on ever-larger machines. But to support truly large numbers of simultaneous users, storage needs to scale out, not up.

In resume – the goal of Windows Azure is to be highly scalable, highly reliable, highly available, elastic, etc. cloud system. And these white papers describe how is that scalability and reliability achieved.

Now, a quick sneak peak over the SLA (Service Level Agreement) that will assure our business for system up-time and availability. What we are most interested of using MySQL on Windows Azure is the Windows Azure Compute SLA. And the abstract of it sais:

For compute, we guarantee that when you deploy two or more role instances in different fault and upgrade domains your Internet facing roles will have external connectivity at least 99.95% of the time.

Additionally, we will monitor all of your individual role instances and guarantee that 99.9% of the time we will detect within two minutes when a role instance’s process is not running and initiate corrective action.

What does that mean to you, when are running MySQL? Rewind back to the Developing PHP and MySQL Applications with Windows Azure. What did they do? They have deployed a single instanced Worker Role that runs MySQL! Now I do have a couple of questions for you, if you are still going to host your MySQL in windows Azure:

  • 1. Will you have SLA for your MySQL deployment (which is the purpose of using Windows Azure)?
    • NO! And no, because your MySQL will be running on a single instanced role. You simply can’t run MySQL on multiple instances! Well you can, but you can’t really work with it.
  • 2. Will your MySQL be easily scalable (which is the purpose of using Windows Azure)?
    • NO! Because scaling out in Windows Azure is achieved by just increasing the number of instances that are running within your role. And if you want to “scale-out” a MySQL in Windows Azure, you will have to deploy entirely new worker role with single instance.

For me, there is just no worth of bothering with running MySQL on Windows Azure. You are going to loose all the strengths of Windows Azure and will utilize it just as virtual server hosting. Just give up on MySQL if you want to go with Windows Azure and refactor your PHP code to use SQL Azure!

And by the way … there will be almost the same issue with running PHP. However, this is easier to handle. Couple of important things you need to know in order to avoid hours of debugging a php code that is not debuggable – use a DataBase to store your sessions! If you want to scale out on Azure, do not ever use default sessions with PHP – move them to database. And let this database be SQL Azure. Well, moving sessions to database is the easier. You could also move the session to Windows Azure Tables.

If you want to write files on a “hard drive” – use Windows Azure Drive or go directly to Windows Azure Blob.

Monday, January 25, 2010

Jason Beres to speak in Sofia on Visual Studio 2010 and .NET 4

Next week we will be a host for an amazing session. It will be held on 2nd of February 2010 at Elieff Center for Education and Culture, 1 University Park str., Studentski grad 1700, Sofia.

“Building Better Experiences using Visual Studio 2010 and .NET 4”

As Visual Studio 2010 is right around the corner, and it's a completely new IDE based on WPF, chock full of exciting new features and productivity enhancers. So now is a great time to figure out the answers to these 2 key questions:
  • What's in Visual Studio 2010 and .NET 4 for me?
  • What is going to take to learn all of this?
In this talk, Jason will answer those questions. You'll get an understanding of the full run down of new features in Visual Studio 2010, including the new testing and debugging features, new data options, new deployment scenarios, new code editor features and many other new time savers and coding enhancers. You'll also get an understanding of new language features in Visual Basic and C#, as well as the new support for the F# language and the new project support for Silverlight 4, Windows Azure, SharePoint and Microsoft Office applications. At the conclusion of this talk, you'll know exactly why you need Visual Studio 2010 and .NET 4, and how they will improve your coding experience and capabilities to build even better software in 2010 and beyond!
Jason Beres is the VP of Product Management for Infragistics, the world leader in user interface development tools and experts in the User Experience (UX) market. Jason is a founder of Florida .NET User Groups, he is the founder of the Central New Jersey .NET User Group, he is a Microsoft MVP, and he is on the INETA Speakers Bureau. Jason is the author of several books on .NET development, including the recently published Silverlight 3 Programmers Reference from Wrox Press and the upcoming Silverlight 4 Professional from Wrox Press. Jason is a national and international conference speaker; he is a frequent columnist for several .NET publications, and keeps very active in the .NET community.
Expected duration of the lecture is about 1.5 hours and there will be catering party, excellent for networking after it.
See you there!

Sunday, December 13, 2009

Another common reason for Windows Azure role to stuck in Initializing/Busy/Stopping

There is another common reason that will cause your role to stuck into that loop when you deploy it on Windows Azure. And it is common for Web and Worker Roles.

You will most probably encounter this error if you are using latest Windows Azure Tools (as you should to) and you are creating a new project (rather than upgrading your existing one).

The new project template comes with enabled and started DiagnosticsMonitor. In order for this Monitor to work properly and collect and store data it needs a Windows Azure Storage account. The account configuration is saved as Role Configuration Entry in the .CSCFG file. The default “Connection string” is this one:

    1 <Setting name="DiagnosticsConnectionString" value="UseDevelopmentStorage=true" />

Note the “UseDevelopmentStorage=true” in the value for our DiagnosticsConnectionString. If you just make a “Hello World” Web Role and you upload it to Azure environment, that role will never start. It will go a Initializing/Busy/Stopping/Stopped loop. You need to either stop the DiagnosticsMonitor or change the connection string.

Lest first see how the connection string should look like:

    7       <Setting name="StorageClientAccount"

    8                value="DefaultEndpointsProtocol=[https|http];AccountName=[your_account_name];AccountKey=[your_account_key]" />

In this “Connection string” setting for Diagnostics monitor you need to provide:

  • DefaultEndpointsProtocol – http or https
  • AccountName – your storage account name (endpoints are automatically built up)
  • AccountKey – the authentication key that is generated at Storage management part of the portal.

Without specifying these settings your role will not run on Azure environment.

How about disabling DiagnosticsMonitor? Sure you can do so. If you have a WebRole there will be a single file defining a Class (usually called WebRole.cs) that derives from RoleEntryPoint. This class looks something like this:

   24 public class WebRole : RoleEntryPoint

   25 {

   26     public override bool OnStart()

   27     {

   28         DiagnosticMonitor.Start("DiagnosticsConnectionString");

   29 

   30         // For information on handling configuration changes

   31         // see the MSDN topic at http://go.microsoft.com/fwlink/?LinkId=166357.

   32         RoleEnvironment.Changing += RoleEnvironmentChanging;

   33         ...

It is important to note line 28, on which there is a call: DiagnosticMonitor.Start("DiagnosticsConnectionString");

If want to remove the DiagnosticsMonitor just strip the entire OnStart() method. However I suggest not to do so, because you will loose all logging functionalities of Windows Azure.

I hope that this eliminates most common reasons for headaches of Windows Azure Role stuck in Initializing/Busy/Stopping/Stopped loops.

Thursday, December 10, 2009

Windows Azure role stuck in Initializing/Busy/Stopping

Recently I see a lot of questions with that description around Windows Azure Forums. There is one particular reason that appears to be causing this behaviour in most of the cases. I want to describe it with respect to Web Role and Worker Role

Web Role

If you have a web role prepared for Windows Azure deployment be sure that you double check that you have set “Copy Local” attribute to TRUE for any third party assemblies that you reference in your project. These are all assemblies that are not part of Microsoft .NET Framework 3.5 SP1. Such as Microsoft ReportViewer, Microsoft MVC, Microsoft WCF RIA Services, Unity, nHibernate, SandCastle. Any.

RefernceAssemblyCopyLocal

Worker Role

While requirements for referenced assemblies in Worker roles are same as requirements for these in Web Roles, there is another important point to observe. And this is that your Run() method should never end. If it ends, than Windows Azure Fabric thinks there is something wrong are recycles your role. That’s why you initial Run method will look like this:

    1         public override void Run()

    2         {

    3             // This is a sample worker implementation. Replace with your logic.

    4             Trace.WriteLine("WorkerRole2 entry point called", "Information");

    5 

    6             while (true)

    7             {

    8                 Thread.Sleep(10000);

    9                 Trace.WriteLine("Working", "Information");

   10             }

   11         }

It is important to not remove the while (true) cycle as it it the “lifecycle” of our worker role. If we remove it,our worker role will enter an endless loop of:

[runtime] Role entrypoint . COMPLETED OnStart()
[runtime] Role entrypoint . CALLING   Run()
Information: Worker Process entry point called
[runtime] Role entrypoint . COMPLETED Run() ==> ROLE RECYCLING INITIATED
[runtime] Role instance recycling is starting
Information: ...
Information: ...
[fabric] Role state Recycle
[fabric] Role state Stopping
[fabric] Role state Stopped
[fabric] Role state Stopping
[fabric] Role state Stopped
[fabric] Role state Suspended
[fabric] Role state Aborted
[fabric] Role state Teardown
[fabric] Role state Destroyed
[fabric] Role state Created
[fabric] Role state Suspended

Why is it so is well described by Steve Marx as answer to my question on MSDN Forums:

The model is that you're expected to never return from Run().  (If you do, we think something went wrong and restart you.)
If you have other threads doing work, you can just go into an infinite sleep at the bottom of Run().  (Thread.Sleep(Timeout.Infinite))

http://social.msdn.microsoft.com/Forums/en-US/windowsazure/thread/2ce85358-b7e2-4b2b-bfbd-952b65e31fa2

I really hope that this post will save you lot of time and frustration using Windows Azure.