The Latest Time Saving Tips for Your SharePoint Deployment

Corey Roth

Subscribe to Corey Roth: eMailAlertsEmail Alerts
Get Corey Roth: homepageHomepage mobileMobile rssRSS facebookFacebook twitterTwitter linkedinLinkedIn

Related Topics: SharePoint Archiving Journal, Microsoft Developer

Blog Feed Post

Office 365 How to: Build and Deploy a Web Part with SharePoint Online

With Office 365, your development scenario involves sandboxed solutions

You know by now that the cloud is hot and Microsoft says “we’re all in.”  That being said, there has never been a better time to push all of those chips forward and  jump on the bandwagon.  It’s time to get some experience with SharePoint Online / Office 365.  I know most people don’t have access to the Office 365 beta yet, but when it opens up, you should sign up for the public beta and start getting familiar with it.  If you haven’t seen SharePoint Online yet, check our my previous article which gives a quick tour of it.  I plan to write more about SharePoint Online in the future, so I figured the best place to start is with an introductory development article on building and deploying a web part.  My past series on building and deploying web parts to 2010 and 2007 are still the most popular articles on  Let’s take what we learned there and see how we deploy web parts to the cloud.

Before we get started, let’s reiterate what we’re working with. With Office 365, your development scenario involves sandboxed solutions. As you know, these solutions are deployed to the site collection level and offer a restricted subset of the SharePoint API.  If you are already confortable working with sandboxed solutions, you are in great shape to begin SharePoint Online development.

What does the development environment look like?  Well, you know that SharePoint 2010 VM you already have?  You’re looking at it.  Just like Azure, SharePoint Online development also used the “Over the fence” development methodology.  Meaning, you develop your code locally and then throw it over the fence and hope it works.  This may sound bad, but it’s really not a big deal and the Azure people have been doing it for a while.  AppFabric is close to Azure, but there is always a possibility of differences when you get it in the cloud.  As long as you build a sandboxed solution and don’t make use of unsupported features (i.e.: PerformancePoint, BCS, etc), more than likely your code will work when it gets to the cloud.  There may be things that you can do in a Sandboxed solution in SharePoint 2010 compared to SharePoint Online, but it’s far too early to tell at this point.  To get started developing web parts in the cloud, you pretty much need a copy of SharePoint 2010 (or SharePoint Foundation) installed somewhere locally.  This could be native on your Windows 7 machine or inside a virtual machine.  Wherever it is, you will obviously need Internet access to get your code to the cloud.

To get started developing in the cloud, the first step is to build the web part on your local SharePoint environment.  I won’t go through all the steps here, because most of them are the same from my article on 2010 Web Part Development.  However, I will go through the important steps.  The first step is to create a new Empty SharePoint 2010 Project in Visual Studio 2010.  Specify the URL to a local site on your SharePoint server.  Don’t use the address of your SharePoint Online site.  It won’t work.  When prompted for the solution type, choose Sandboxed Solution.


At this point, you have a regular SharePoint project in Visual Studio.  Add a web part to the project just like you would in SharePoint 2010.  Sticking with the Hello World type example, we put some code like the following in our web part.

using System;

using System.ComponentModel;

using System.Web;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Web.UI.WebControls.WebParts;

using Microsoft.SharePoint;

using Microsoft.SharePoint.WebControls;


namespace SharePointOnlineProject3.HelloCloudWebPart



public class HelloCloudWebPart : WebPart


protected override void CreateChildControls()


Controls.Add(new Label() { Text = "Hello, Cloud!" });




At this point, we can test our code locally on our SharePoint server.  Build and deploy the project and then add your web part to a test page on your site.  Again, if you aren’t familiar with these steps, take a look at my Building and Deploying Web Parts with SharePoint 2010 post. If the code, works you should see a similar page like the one below.


Now, we’re ready to send our web part “to the cloud!”.  How do we do that?  Start by using the Package menu to build a SharePoint package (.wsp file).


This creates a .wsp file located in the bin folder of the project.  We’ll use this file to deploy our web part to the cloud.  It’s now time to open up a browser and connect to your instance of SharePoint Online.  Once you get there, we deploy a sandboxed solution just like we would on-premises.  Go to Site Settings –> Solutions to view the Solutions Gallery.  Click on the Solutions button in the ribbon, and then click Upload Solution.  Browse to the bin folder of your Visual Studio project and select the file ending in .wsp.  Once it uploads, be sure and click the Activate button.


Now, you just need to ensure the feature is activated by going to Site Settings –> Site Collection Features.  If it is not activated, click the activate button.


Your web part has now been thrown over the fence and deployed to the cloud!  Test it out by going to any page on the site and adding the web part to the page.  You’ll find your web part in the Custom section by default.  If all goes well, your web part should work here too.


Congratulations, you have now deployed code to the cloud!  It’s really not that hard is it?  Now, you might be wondering if you can debug your solution.  Unfortunately, the answer is no.  If you have an issue, you have to step through it locally on your on-premises SharePoint server.  That’s all there is to getting started with SharePoint Online development.  As you can see it’s very familiar to sandboxed solutions development with your on-premises server.

Read the original blog entry...

More Stories By Corey Roth

Corey Roth, a SharePoint Server MVP, is an independent consultant specializing in Cloud technologies such as Azure and Office 365. He also specializes in mobile development. Corey serves as the product manager for two cloud-first mobile app platforms: BrewZap and HappenZap.