Let’s suppose you have a working Silverlight app, how do I publish it to Windows Azure? well’ is indeed very easy (and this is good )
Once you have Azure 1.3 SDK installed, you can add a new Azure project to your solution:
Press Ok and you’ll be asked what template you want to add
since we already have a project and all we need is to host our Silverlight app inside an Azure WebRole, we just press Ok.
Right click the Role folder inside Azure project and select: Add-> Web Role Project in solution… then select the website you want to associate:
Now set Azure project as startup and press F5, you’ll see a new icon appearing on taskbar: is the Windows Azure Emulator that emulates the Azure environment locally.
You’ll also see your browser opening to you Silverlight application main page (have a look at browser uri too…)
Once you’ve tested your app inside Azure environment you’re ready to move it to the cloud, so right click the Azure project and selecting Publish:
Following dialog will appear:
| As you can see you can even publish your app straight from Visual Studio but since we don’t have any hosted service yet we just choose to create required publishing packages. |
If everything succeeded you’ll see a couple of files generated:
| The .cspkg is the publishing package while ServiceConfiguration.csfg contains application configuration. They’re separated so that you can change the configuration without re-publishing the entire app thus avoiding the role to be totally recreated (a long process indeed) |
What’s still missing? yes, the Azure account
Login into your account at http://windows.azure.com and add a new hosted service
Let’s configure our service:
| Enter both service name and public uri where your app will be reachable, choose the nearest region so that app will be deployed to the datacenter nearest to you and browse to publishing files generated by Visual Studio. Finally press Ok. You’ll get a warning indicating more or less that since we have a single webrole in case of failure the load balancer can’t redirect requests to another instance so your site will become unreachable. Since it’s just a test, we’ll run the risk… Now wait for your webrole to be created, initialized and your app published, you can monitor progress from Windows Azure Portal.
|
Once done, you can’t browse to publishing uri since app has been deployed to staging environment for further test on “real” Azure OS.
If you click you service inside Windows Azure Portal on the right you’ll see the temporary DNS name of your app:
Browsing to proposed uri (http://0663aab2c1814d0eae91b1d0ee899738.cloudapp.net/DemoSilverlightTestPage.html in our case…) should reveal your app.
Once staging testing is completed, you can finally upgrade it to promotion using the Swap VIP button within Azure portal.
Since this operation just swaps the virtual IPs of the webrole is way faster than initial deployment that required machine/environment tear up.
You can now advertise your app running at the uri choose before (e.g: http://corradodemoblog.cloudapp.net/DemoSilverlightTestPage.html)
This is not the only way to publish an application to the cloud, but just a demostration about how easy the procedure is and while we’ve used a Silverlight application nothing prevents you to follow the same steps for any ASP.NET application.