Silverlight Hack

Silverlight & related .NET technologies

About Me

Welcome to Silverlighthack.com.  This is a site where you can find many articles on Silverlight, Windows Phone 7 and .NET related technologies.  

My name is Bart Czernicki.  I have been working with computers since 1988 and have over 12 professional years in the IT field focusing on architecture, technology strategy and product management.  I currently work as a Sr. Software Architect at a large software development company.

Below is the cover of my new book that shows how Silverlight's unique RIA features can be applied to create next-generation business intelligence (BI 2.0) applications.

Silverlight 4 Business Intelligence Soft 

Contact: bartczernicki@gmail.com

View Bart Czernickis profile on LinkedIn

NONE of the comments or opinions expressed here should be considered ofmy past or current employer(s).  The code provided is as-is without anyguarantees or warranties.

Getting started with Visual Studio 11 Developer Preview with ASP.NET MVC4

Visual Studio 11 Developer Preview was released a couple weeks ago at the Microsoft BUILD 2011 conference.  I have installed it side-by-side with Visual Studio 2010 Ultimate on two workstations and have had no problems.  My biggest interest in Visual Studio 11 was the new web development features specifically HTML5 support, ASP.NET MVC 4 and the new Page Inspector (you can run the HTML5 support and ASP.NET MVC4 in Visual Studio 2010 BTW, but the Page Inspector is a real nice productivity boost).  If you haven't seen it in action yet, Phil Haack has a great presentation from the BUILD Conference (Progressively enable the mobile web with ASP.NET MVC 4, HTML5, and jQuery Mobile)

There are some steps needed to get a complete ASP.NET MVC4 development environment up beyond downloading and installing the Visual Studio 2011 Developer Preview MSI.

1) Download and install the Visual Studio 11 Developer Preview

2) Install ASP.NET MVC4 with the Web Platform Installer

3) Install the Page Inspector via the Web Platform Installer

Note: If you get an error trying to to create a new ASP.NET MVC4 project stating that you need to install NuGet.  Follow these instructions here. NuGet is a dependency for ASP.NET MVC4.

Now you should be on your way to more productive development now in ASP.NET MVC.  It always annoyed me that I had to code-> build -> debug/inspect -> repeat..now the Page Inspector provides a nice IDE for manipulating HTML/CSS/Controller Code and get immediate feedback without the whole debug step and waiting for Visual Studio to launch my browser in IIS Express.  Here is a link of a full write-up of the Page Inspector and how to enable it once you are ready to start coding.

Posted: Oct 01 2011, 13:15 by Bart Czernicki | Comments (0) RSS comment feed |
  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Filed under:
Tags:
Social Bookmarks: E-mail | Kick it! | DZone it! | del.icio.us

Office 365 - Using Silverlight in SharePoint Online

Abstract: One of the core features of Office 365 is "SharePoint Online" essentially it is SharePoint 2010 Server in the "cloud" (it does not include a lot of the SharePoint 2010 Enterprise features).  In my Silverlight 4 Business Intelligence book I dedicate a chapter to integrating Silverlight into SharePoint 2010 and I have blogged about it on this site as well.  However, in this blog article I want to show how the same Silverlight integration concepts apply to Office 365 - SharePoint Online.

Background Info: Microsoft launched Office 365 June 28th 2011 as a SaaS BPOS (Business Productivity Online Suite) which offers some great features including: SharePoint, Exchange Online, Lync Server and Office Web Apps.  These services can are completely online delivered in a SaaS model requiring no local infrastructure (think of it as Microsoft Small Business Server in the cloud).

In SharePoint Online you get a basic SharePoint 2010 team site that you can begin adding content.  The most basic way to add content is to upload documents, pictures etc.  and use the SharePoint Online team site as a document library.  Even though SharePoint Online doesn't include all the advanced enterprise SharePoint 2010 Server features, it does have some very powerful integration features such as web parts (which you can develop using SharePoint Online Sandbox Solutions).

Web Parts have been the modular components used as building blocks since SharePoint 2003.  There are some web parts that are provided out of the box in SharePoint that allow you to add content in them or you can create your own.  Creating your own custom web parts even in SharePoint 2010 is not a trivial task (the web part API created in .NET 2.0 has been not updated and creating Ajax-like web parts, that communicate and maintain state is NOT trivial).  This is where Silverlight web part integration in SharePoint 2010 really shines.  SharePoint 2010 and SharePoint Online both include a Silverlight web part, which allows you to host any Silverlight application (XAP file) inside the team site.

Instructions to add a Silverlight Application (internet URL of a XAP file) to Office 365 SharePoint Online:

  1. Log into your SharePoint Team Site
    • You can add a new page or edit the existing one
  2. From the top left menu select "Site Actions" -> "Edit Page"

     

    • This will put the page in edit mode where you can add aditional content
  3. From the Ribbon menu select "Insert" -> "More Web Parts"

     

     

    • A dialog will appear listing all the avaiable web parts.  Select the "Silverlight Web Part"
    •  

       

    • Click the "Add" button located on the top right
  4. You should have an empty Silverlight Web Part located on a SharePoint page.  Now you need to add a Silverlight application (XAP file) to surface on the Silverlight Web Part.
    • With the web part click the "open the tool pane" link
    • On right-hand side click the "Configure..." button
    • Enter a URL location of the Silverlight XAP file (this can be a remote URL or URL of the XAP file within SharePoint Online Document library).  Click OK after entering a valid URL
      • I used a XAP file from my web site: http://www.silverlightbusinessintelligence.com/Content/SilverlightXAPs/SilverlightBusinessIntelligenceSite.xap
    • Apply a specific height and width for the web part (otherwise the configuration pane will not let you proceed)
    •  

       

    • Click Apply and then save the page (save diskette icon on the top left) and the Silverlight Web Part should render your Silverlight Application.

What is the big deal with Silverlight and SharePoint Online integration?

  • Silverlight applications you do not have to write custom ASP.NET web parts (which gets complicated real quick mixing Ajax, state, communication, security and deployment).  Silverlight applications are much easier to write since you do not have to learn the web part framework or use the SharePoint Online Sandbox Solutions.
  • Existing Silverlight applications just work with minimal "SharePoint or Web Part" coding required.
  • Silverlight gives you client-side web part communication out of the box.  Web part communication is not trivial in custom web parts and even then you get "old school" post backs if you use the provided web part communication model.  With Silverlight web parts you can use the messaging API or Javascript HTML bridge to communicate between non-Silverlight web parts.

In summary, SharePoint Online is one of the places that Silverlight integration really shines (even over the oncoming HTML5 wave).  Existing Silverlight applications can be easily added to a SharePoint Online team site.  Furthermore, Silverlight allows the easy creation of new web part components that can be hosted externally and connected to other web services (using SharePoint, OData or other).

Posted: Jul 19 2011, 20:40 by Bart Czernicki | Comments (0) RSS comment feed |
  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Filed under:
Tags:
Social Bookmarks: E-mail | Kick it! | DZone it! | del.icio.us

Lower the cost of Azure pricing through Tools, Promotions and Technology Decisions

Abstract: In this article I will show some techniques to lower the costs of using the Windows Azure Platform.  We will look at three different methods of lowering the cost of Azure: via tools, promotions and technology architecture decisions that can dramatically impact costs of using the Azure cloud platform.

Tools: Azure Platform Pricing Calculator

The first step in understanding your costs and how to lower them in Azure is to forecast the costs of the services in Azure.  Until recently this was largely a manual effort and an architect or technical business owner would have to sift through pricing grids (like this one) and tally the numbers yourself.

Microsoft has released the Azure Platform Pricing Calculator that allows you to easily select the services you need and determine their costs very easily.  This not only allows you to make planning easier, but it also can dramatically lower your costs by showing you cheaper options available (i.e. promotions or smaller instances of Compute).  The Azure Platform Pricing Calculator can also show you the different costs associated with architectural options (i.e. having a 100gig SQL Server database is about $1,000/month versus table storage of the same size is $15/month + minimal costs with storage transactions).

 
 
Promotions & AzureOffers: Look at All the different Microsoft Azure options
 
Microsoft is really pushing Windows Azure.  A lot of their core evangelists, program managers and sales teams are pushing the platform to the enterprise. Furthermore, there are a lot of deals to attract business owners, consultants, developer hobbyists as well.  Make sure you shop around for the BEST deal.
Free Trials:
 
These will probably change, but there are several different FREE trials available to try Azure and lower your costs. 
  • Microsoft offers a no credit card required 30-day trial of Windows Azure Platform trial here.
  • Microsoft offers a credit card required offer until September 30th, 2011 FREE trial here.
MSDN Subscriptions:
 
MSDN Subscribers have the ability to get components and Azure services for FREE at a certain limit for FREE as well.  The higher level of your MSDN Subscription, the more is alotted to you (for example a MSDN Ultimate Subscription has 1,500 hours/month of a compute instance available). 
 
Other Business & Partner Agreements: 
 
If you are a large customer from Microsoft, you can obviously negotiate better enterprise pricing for Azure ("You can negotiate?...yes").  However, if you are a small business or a startup you can also participate in either the "Cloud Essentials" Microsoft partner program or the Microsoft BizSpark program, which allows you to take advantage of the Windows Azure platform at lower costs as well.
 
 
You can compare all of the offers from Microsoft in a nice grid here:
 
 
 
 
Technology Architecture Considerations:
 
SQL Azure Alternatives
 
SQL Azure is EXPENSIVE (especially for very large sites).  Even for a small site like mine, which has a read-only SQL Server database...I did not want to pay $10/month ($120/year for a 1 gig database).  Here are some alternatives: 
  • Use SQL Server CE 4.  It is a new embedded database that can be deployed to the web role in Azure.  The nice thing is that you will not have to pay for storage or transactions, because it is part of the web role.  The downside is that you will have to be responsible for your own disaster recovery.  This would not work great for mission critical or very transactional databases.  However, small databases with read-only historical data (i.e. baseball stats), aggregate caching databases (i.e. map reduce business intelligence) or low transaction databases (i.e. a blog) would be great candidates and save you a lot of money.
  • Combine Data Content Data Sources. If you have multiple data sources...look for ways to combine them into a single data source.  For example, if you have a small blog and a membership of ASP.NET..instead of paying $9.99/month x 2 for two databases...why not combine them into a single database and pay $9.99/month?  In those cases, proper naming conventions in SQL will save you and allow you to do this.
  • Use NOSQL Databases. Not every single web site needs a relational database behind the scenes.  Sites like Google, Facebook or Reddit use NOSQL storage almost exclusively to power their entire platforms.  For example, a .NET Lucene library port for Azure exists, which uses local caching heavily as well as Azure Blob storage which is significantly cheaper than SQL Azure.  Using the Azure infrastructure/SDK you can even run NOSQL databases like MongoDB on Azure as well.  Azure Table storage is another "NOSQL like" alternative in the Azure platform that is much cheaper than SQL Azure.
  • Use cheaper cloud storage databases.  If you are a .NET developer or prefer working with the Microsoft cloud tools nothing is stopping you from using different cloud content alternatives.  For example, you can host your database on Amazon EC2 and have the front-end or compute instances deployed to Windows Azure.
  • Sometimes SQL Azure is not a good choice (costs-wise).  For example, if I have a large data warehouse (50-75 gig), I would strongly reconsider surfacing that content in Azure directly in SQL Server...the costs per month would be astronomical.  I would consider a NOSQL database or not move the data warehouse to the cloud.
 
Caching
 
I know this might be an obvious one, but remember you are not only paying for storing your content in the cloud...you also pay a very small amount each time someone access it.  On a very busy site with lots of images, icons, scripts etc. this can add up very quickly.  Having the content pulled from the web compute role will drastically lower the costs of accessing other storage mechanisms such as BLOB or Queue storage.
 
Two types of caching:
  • Server content caching:  This content is cached on the server, therefore the content does not have to be retrieved from a SQL Azure, BLOB Storage or from another remote location that is not on the local server.    For example, caching the same results in memory instead of performing the same SQL Server t-sql query will save costs because you are mitigating the number of transations from the SQL Server to the web server.
  • Client HTTP Caching: The core architecture of the web is primarily powered by the HTTP protocol.  An HTTP client (i.e. a web browser) can cache certain static content on the local client workstation with the cost of the same roundtrips to the server.  For example, a user that frequents gmail.com does not need to download the same Google logo or JavaScripts each time they visit the page to check their email.  This saves costs dramatically of the bandwidth from the server.  More info can be found here.
 
Use the Enterprise CDNs for Scripts (i.e. jQuery, Ajax)
 
(I am not talking about the Azure CDN, which is a different topic).  Microsoft and Google both provide hosted access to things like jQuery.  Instead of having that script downloaded from your Azure web role, the client browser or mobile device downloads it from Microsoft or Google directly.  This saves you both transactional and bandwidth costs.  Here is a good article describing the pros/cons of both. Putting those scripts on Microsoft's or Google's network will decrecy the network latency of the calls and also allow your pages to load faster (since client browsers can only make a limited amount of requests to the same domain). The main benefits are described in this article here.
 
 
Use the RIGHT VM Sizes
 
Azure includes several different VMs you can use to deploy your web or worker roles.  Ensure that you pick the right one for the job.  For example, Microsoft positions the "Extra Small" VM as a way to test code and not really meant for production.  However, that role is perfectly OK for running a blog, small corporate site, a restaurant site etc with no problems.  I am running my www.silverlightbusinessintelligence.com site on the Extra Small instance and it works really well and have no need to pay for a more expensive VM. 
  • Note: Remember that the defaults and best practices Microsoft perscribes are not necessarily what is needed for you and there are lower options available. You can always quickly scale higher as you need more horsepower.  There are techniques to poll every minute your CPU/Memory utilization to determine if you need a better cloud VM infrastructure.
 
Multiple Web Sites Per Web Role 
 
In the Azure 1.3 SDK update, now you can host multiple web sites per single web role.  For example, if you have a Medium VM you might be able to put on 3 or 4 different web sites per single web role.  This will obviously cut down costs as you are not paying for 4 different VMs just one.  The Windows Azure Platform has detailed instructions on how to support this here.
  • Note: Architecturally you can also stagger different sites for traffic reasons (according to year/time of day/week etc). For example, if you had an tax website (high traffic beginning of the year) and place that with a web sites for NFL Football (popular towards the end of the year). 
 
Use IIS 7.x HTTP Compression (dynamic and static content)
 
In Azure, you have a choice to deploy to either an Windows 2008 SP1 or Windows 2008 R2 Server.  Both servers use IIS 7.x as the web server, which makes configuring things like static compression or even dynamic compression pretty easy.  This will save you a lot of money on larger sites, since most of the web traffic is string based that can be compressed with dramatic ratios.
  • Note: It appears in either the new Azure SDK or the new VM image, IIS compression is turned on by default for dynamic content.  For example, in order to have my web site (silverlightbusinessintelligence.com) to take advantage of IIS 7.x compression..I did not have to do anything.  However, keep in mind that if you take full control of your serialization, media formats or APIs etc. you will have to configure IIS Compression.
 
Summary
 
In this article I showed you different tools, promotions and technology architecture choices you can use to lower the costs of using the Azure Cloud.  Remember that every service you choose to use from Azure has a cost associated with it.  
  • Plan using the Azure Platform Pricing Calculator
  • Look at the available promotions and offers.
    • An offer may not include everything, but it can dramatically subsidize the costs of doing business in Azure
  • Architectural decisions can end up costing you a lot of money 
Posted: May 26 2011, 11:13 by Bart Czernicki | Comments (0) RSS comment feed |
  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Filed under: Azure
Tags:
Social Bookmarks: E-mail | Kick it! | DZone it! | del.icio.us

Azure Service Deployment Package Inefficiency (Bug) - Content Size Added Twice

I spent this past week migrating my companion site for my book www.silverlightbusinessintelligence.com to the Azure cloud (http://slbusinessintelligence.cloudapp.net/).  The site has a lot of demos and source code associated with it, therefore the Azure Service deployment package (cspkg file) was pretty big.  

Problem: I actually ended up running into the maximum allowed size for an Azure service package, which is 600 megs (which I find odd, since you can easily get around that limitation by adding static content to the web role by remoting in or doing a web deploy afterwards). I deployed to an "Extra Small" instance, which is all I really need to a simple site like this and you get a lot of storage (shown below).  The reason Microsoft caps the deployment at 600 megs is that your deploying to the E:\ logical drive, which has only 1 gig of space.  However, as you can see there is PLENTY of space on both the d:\ logical drive.  I know space is required for the OS, future patches and changes etc. but this limitation struck me as odd.

My three logical drives on the Azure Web Role:  

 

Solution:  One of the obvious solutions was the move the three source code zip files (which are over 100 megs) to the Azure blob storage (which costs extra) and server the links from there.  I have my static source code zip files on the Azure blob storage for example: http://bartczernickiblogs.blob.core.windows.net/sourcecode/SilverlightBI_SourceCode_Version1.zip.  

The other nice benefit of moving your static content to blob storage (and enabling public read access) is that your content loads faster since it is coming from a different domain in a browser.  For example, if you had a lot of images to load on a web site.

 

Azure Deployment Package Inefficiency: After doing this I thought it was curious that the Azure service package size was so high as I didn't think I had over 600 megs of code, XAP filess or content.  Granted my three different versions of the source code are 137 megs in total and the total Azure service package is: 630 megs.  However, after I removed the three source code zip files (figuring it would make the package 137 megs less) it made the newer package a total of 351 megs almost 279 megs smaller!  So it looks like Azure deployment packaging is adding the content twice!?

Digging in....an Azure Service Deployment package (cspkg file) is just a zip file.  Inside it you can find the main content file, which is stored inside a file with the csnsx extension.  The csnsx file is just another zip file that is encrypted.  In order to decrypt it, add the _CSPACK_FORCE_NOENCRYPT_ environment variable and set it to true (follow this blogpost in detail).  I decrypted my package and low and behold the entire site is replicated basically twice in two folders both APPROOT and SITEROOT (shown below):

AppRoot source code files of the Azure Deployment package: 

SiteRoot source code files of the Azure Deployment package: 

 
There obviously is a technical reason this was done this way, by having the same files duplicated  in both APPROOT and SITEROOT folders.  However, I look at this as a big optimization opportunity for the next version of the Azure SDK.  For example, Microsoft could derive the APPROOT or SITEROOT from each other after it is deployed to the web role (?).  In my opinion, if Microsoft is going to limit the Azure deployment package size to 600 megs, static content should not be added twice!  

My example is not very common, but there are reasons why to make this faster:

  • Bandwidth costs:  If you count the amount of content uploaded to Azure, having content double package sizes costs the Azure user and Microsoft both money.  Also for large packages like this, with the new world of bandwidth caps this costs me money too.
  • Deployment time: Uploading large packages like this takes time.  It almost took 45 minutes from upload to instantiation of the package.  Making the packages smaller and more efficient will speed up the deployment process.  One of the biggest selling points of AppHarbor (which is .NET cloud on Amazon EC2) is how much faster it is to deploy to the cloud....and it is by factors of 10x or more!).
 
Posted: May 22 2011, 13:34 by Bart Czernicki | Comments (0) RSS comment feed |
  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Filed under: Azure
Tags:
Social Bookmarks: E-mail | Kick it! | DZone it! | del.icio.us