What’s in This Chapter?
This chapter helps you set up a development environment for Office 365. At the time of this writing, Microsoft does not provide Office 365 SDK as a single download. This means that you must do a bit more work to get everything set up and running before you kick-start the development. Separate sections cover SharePoint Online, Exchange Online, and Lync Online. Later in the chapter you learn about common challenges associated with Office 365 development and various resources that Microsoft makes available for Office 365 developers.
Before you start setting up your development environment, the first thing to do is to register for Office 365. For testing purposes you can create a trial account with Office 365, which is available free of charge for 30 days. If your business already has an existing Office 365 account, you can use this existing account. However its highly recommended that you set up a new account with Office 365 because Microsoft does not provide separate test environments, so any changes that you make to the existing one are against a production (or live) environment and are reflected immediately to business users.
Office 365 is offered through different plans targeting professionals, small businesses, midsize businesses, enterprises, and education. Table 2-1 describes various plans available to you.
Category | Description | Trial Availability |
Office 365 for professionals and small businesses (Plan P) | Supports up to 25 users | Yes |
Office 365 for midsize businesses and enterprises (Plan E1, E2, E3, E4) | Supports 25+ users | Only Plan E3 |
Microsoft Office 365 for education | Supports only academic and education institutions | No |
For most development scenarios, plan E3 is a good choice because it includes all the key features of Exchange Online, SharePoint Online, and Lync Online (except full enterprise voice capabilities with on-premises Lync Server). Not every plan is available for trial; however, in most cases as mentioned earlier, plan E3 is sufficient.
To register for Office 365 trial, visit www.microsoft.com/en-us/office365/free-office365-trial.aspx. You can choose to register either with Plan P or Plan E. For this exercise you will register with plan E3, but the registration process is identical for other plans.
Figure 2-1 shows the trial sign-up page for Plan E3 and mentions that the free trial period will expire in 30 days. To sign up for a trial, follow these steps:
When your trial expires, you have an additional 30 days to convert your account to the paid subscription after which your account will be completely deleted along with all content, customizations, configurations, and users. You can easily convert to a paid subscription by clicking the Purchase Now link, as shown in Figure 2-3. You can also do it any time during your trial period and additional 30 days of grace period.
Your trial account is now ready. In the next section, you see how to add a few users to it, so that you can later use them during development.
On the Admin Home Page, under the Management section on the left, click the Users link, as shown in Figure 2-4.
You have two options available for adding users: You can add them manually—one user at a time using the user interface, or add them in bulk by uploading a CSV file containing a list of users in an Office 365–preferred format. The advantage of the latter approach is an obvious gain in productivity; imagine hundreds of users and the time it takes to add them manually. However if you have only a few users, you can add them easily using the user interface. Now look at both of these approaches to add users.
To add users manually, follow these steps:
To add multiple new users in bulk, follow these steps:
In this section, you learn various approaches that you can use to build an Office 365 development environment. Later in this section, a step-by-step walkthrough is provided so you can set up the Office 365 environment.
Virtualization is a powerful technology, and in recent years it has become an integral part of any IT infrastructure. For developers, it provides flexibility and ease of development while providing them the ability to develop on multiple disparate environments and platforms hosted in the same physical workstation. In addition, by taking snapshots of the current state of the virtual machine, you can easily revert back to any earlier state at a later stage in case your changes do not work the way you intend them to. Also, it’s relatively easier to copy and move virtual machines around than physical ones, which gives you freedom to use different physical machines during the course of your development cycle.
Virtualization does have its shortcomings, and depending on your specific scenario, you should determine whether it’s feasible to use:
With Microsoft Windows 8 on the horizon, the good news is that it is scheduled to support the Hyper-V role even on the workstation version, which is a good reason for developers to adopt Windows 8 as early as possible.
In recent years, Microsoft has released virtual machines that have trial versions of various Microsoft products and technologies installed and configured on them, thus allowing you to save considerable time getting started with these products. This is especially true for server-side products such as Microsoft SharePoint Server 2010, which can take a while to set up because it requires you to install a set of prerequisites followed by a multi-stage process for the actual SharePoint Server 2010 product installation. To download these virtual machines, visit www.microsoft.com/download/en/details.aspx?id=27417.
For Office 365 development, you only need trial virtual machine “a.” Virtual machines “b” and “c” have Microsoft Exchange Server 2010 and Lync Server 2010, respectively, installed on them. Although you’ll use these technologies in this book, you need only certain APIs for programming against Lync Online and Exchange Online and they are downloaded separately. You learn more about them later in the chapter. Figure 2-14 shows a more detailed breakdown of what is available on each of these virtual machines.
After your download for the trial virtual machine “a” is complete, follow the instructions from the download center site to set up the virtual machine using Hyper-V.
Using the Microsoft trial virtual machine is often the easiest option to kick-start Office 365 development; however a few drawbacks exist with this approach:
Depending on your situation, you may want to use a physical machine for Office 365 development and may not have policy restrictions in your organization against doing so. This approach has certain benefits over a virtual machine running on your workstation. For example, you may not have sufficient physical memory and storage resources available to store and run a virtual machine. And even if you do manage to run the virtual machine with limited memory, the virtual machine performance is extremely poor and may hinder your development productivity. Another common limitation is licensing, which may require you (or your organization) to purchase separate licenses for the operating systems running on the virtual and the physical machines.
Regardless of the reason, it’s not always feasible to use a virtualized environment for development. The following sections discuss the pros and cons of using a physical machine for development.
The advantages of using a physical machine include:
The disadvantages of using a physical machine include:
The previous section covered various approaches available for hosting an Office 365 development environment. In this section, you put the boxing gloves on and build a fully-functional Office 365 development environment. It’s recommended that you choose the virtualization route and download Microsoft trial virtual machine “a,” as mentioned in the previous section.
Figure 2-15 captures the necessary software required for an Office 365 development environment. When you use the Microsoft trial virtual machine “a,” it already includes a number of the required components, so you need to install and configure only the additional software highlighted in the gray boxes; otherwise, you need to install and configure all of the software, which can take substantial effort on your part. For completeness, the following section covers all of them.
“Step 1: Installing Mandatory Software” walks through the installation of all the mandatory software. You should complete this step before continuing to “Step 2: Installing Service-Specific Software.”
Depending on your needs, you may want to skip the installation of service-specific software that you don’t require. However, if you start with Office 365 development and are not sure which services you want to use, install all the software.
If you use a Microsoft trial virtual machine (recommended), you need to install only the software listed in Step 2, as shown in Figure 2-15.
The following are the system requirements for an Office 365 development environment:
Before you begin the installation, make sure that the account used (preferably a domain account) has administrator rights on the system. Also, you need a reasonable Internet connection for downloading software from the Internet.
Your Office 365 development environment now has base software installed on it. If you opt for a virtual environment, you can take a snapshot and label it After - Office 365 Base Software Installed.
In this section, you will learn about specific software that you need to install for following Office 365 services:
To develop and test solutions for SharePoint 2010 Online, you must install and configure SharePoint Server 2010 locally on your development machine. Visual Studio 2010 Templates for SharePoint 2010 cannot be used with SharePoint Online or a remote SharePoint server web application. You need the following software for a SharePoint Online development environment:
The following are steps for installation. Please make sure that Step 1 is completed successfully before you move to next steps. Please note that these steps are optional:
At this point, you should have your machine equipped with the software required for SharePoint Online development.
The Exchange Online development requires Microsoft Exchange Web Services (EWS) Managed API 1.1. Download the 64-bit version (recommended) or the 32-bit version from www.microsoft.com/download/en/details.aspx?id=13480. The Managed API utilizes Exchange Web Services SOAP protocol and Autodiscover features. Also pay attention to the overview section on the download page, because Microsoft lists any KB articles that need be installed before/after the install of this software. The step-by-step installation instructions are available on the download page.
Lync Online development requires both the Lync 2010 client and Lync 2010 SDK to be installed on the development machine. You have already installed the Lync 2010 client as part of installing mandatory software in the section “Step 1: Installing Mandatory Software.” Download Lync 2010 SDK from www.microsoft.com/download/en/details.aspx?id=18898 and run the setup to install it. The Lync 2010 client is a prerequisite for Lync 2010 SDK, and if it is not already installed you must install it now before proceeding any further.
Also pay attention to the overview section on the download page, because Microsoft lists any KB articles that need be installed before/after the install of this software. The step-by-step installation instructions are available on the download page.
The following software is a great addition to your development tools; none is mandatory for Office 365, but all are highly recommended.
As a last step, restart the development machine. This ensures that any pending changes to the operating system are committed properly. If you use a virtual machine, wait for the operating system to restart; because you reach the login screen before you login, take the snapshot of the virtual machine. Label this snapshot Office 365 Development Ready or something similar.
With the development environment finally ready, you are all set to fire up Visual Studio 2010 and start building applications for Office 365. This section demonstrates how to build simple, yet fully functional, solutions for SharePoint Online, Exchange Online, and Lync Online. The section ends with a discussion of the development challenges you may encounter with Office 365. The idea is to give you a head start before you move to later chapters, which dive more deeply into each service offering of Office 365.
In this section, you will build a basic Hello World Web Part for SharePoint Online and then deploy it to the SharePoint Online site using a WSP file.
SharePoint Online is one of the most feature-enriched services among the whole stack of Office 365 service offerings. It provides a broad set of features ranging from collaboration, content management, business intelligence, workflows, and more. By developing custom solutions for SharePoint Online, developers can extend and add new features and functionally to SharePoint Online. Imagine the possibility of building a Recruitment or Supply Chain Management system that an entire organization can use and reuse. Even better, you can sell your custom solutions based on Office 365 offerings on the Microsoft Marketplace, which you learn more about later in the chapter.
If you already have development experience with the SharePoint 2010 on-premises version, there is a little learning curve involved. You must understand the few key differences as noted here.
In this section, you will develop a Visual Web Part that displays “Hello World” on the page where it is placed. Perhaps not the most impressive web part, but it gives you insight on how to develop and deploy a custom Sandbox Solution on SharePoint Online.
Also, unless explicitly mentioned, all the SharePoint solutions discussed throughout this book are Sandbox Solutions and targeted toward a SharePoint Online multitenant environment. The dedicated environment is available only to large organizations that have 5,000 or more users registered to them.
Listing 2-1: HelloWebPart.ascx
<%@ Assembly Name="$SharePoint.Project.AssemblyFullName$" %> <%@ Assembly Name="Microsoft.Web.CommandUI, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %> <%@ Register Tagprefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %> <%@ Register Tagprefix="Utilities" Namespace="Microsoft.SharePoint.Utilities" Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %> <%@ Import Namespace="Microsoft.SharePoint" %> <%@ Register Tagprefix="WebPartPages" Namespace="Microsoft.SharePoint.WebPartPages" Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %> <%@ Control Language="C#" AutoEventWireup="true" CodeBehind="HelloWebPart.ascx.cs" Inherits="HelloWorldSharePointOnline.HelloWebPart.HelloWebPart" %> <asp:Label ID="lblMsg" runat="server" Text=""> </asp:Label>
Listing 2-2: HelloWebPart.ascx.cs
using System; using System.ComponentModel; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using Microsoft.SharePoint; using Microsoft.SharePoint.WebControls; namespace HelloWorldSharePointOnline.HelloWebPart { [ToolboxItem(false)] public partial class HelloWebPart : System.Web.UI.WebControls.WebParts.WebPart { protected override void OnInit(EventArgs e) { base.OnInit(e); InitializeControl(); } protected void Page_Load(object sender, EventArgs e) { this.lblMsg.Text = String.Format("Hello World, the time on the server is {0}", DateTime.Now.ToShortTimeString()); } } }
Listing 2-3: HelloWebPart.webpart
<?xml version="1.0" encoding="utf-8"?> <webParts> <webPart xmlns="http://schemas.microsoft.com/WebPart/v3"> <metaData> <type name="HelloWorldSharePointOnline.HelloWebPart.HelloWebPart, $SharePoint.Project.AssemblyFullName$" /> <importErrorMessage>$Resources:core,ImportErrorMessage;</importErrorMessage> </metaData> <data> <properties> <property name="Title" type="string">Hello WebPart</property> <property name="Description" type="string"> This is my first sandboxed web part for SharePoint Online </property> </properties> </data> </webPart> </webParts>
To test the SharePoint Online solution that you developed in the previous section, perform the following steps:
In the previous section, you developed a simple HelloWebPart, which displays “Hello World” and shows the time on the server. You also built and deployed it locally on your development machine. This section shows you how to upload your solution to the SharePoint Online site and activate it for usage. However, before you do this, you must create a site collection on SharePoint Online. The following steps show how to create a new site collection and add and activate a solution on it. Finally, it shows how to add the web part on the newly created site collection home page.
You have successfully uploaded, deployed, and activated a Sandbox Solution containing a simple web part on your SharePoint Online site collection.
Microsoft provides the Exchange EWS Managed API (MA) 1.1 to build solutions for Exchange Online. Under the hood, the MA uses the Exchange Web Services to interact with the server, but you don’t need to worry about it, because it shields you from the details of this interaction and provides a higher-level API against which to work. One of the primary objectives of Managed API is to keep things simple for developers by exposing them to Exchange objects such as Inbox, Send Items, Attachments, and so on. You can easily perform CRUD operations for the following items using the Managed API:
One the biggest advantages of MA is that Autodiscovery MA uses this feature, so you don’t need to provide the URL of EWS for your target Exchange Online service. Autodiscovery can find the most efficient Client Access Server (CAS) available for a given mailbox. From a development prospective, this gives you great flexibility because you don’t need to hardcode the EWS URL.
You learn more about Exchange Online Development in Chapter 6. In this next section, you will create your first application targeting Exchange Online using MA 1.1. Your application is a simple Windows Console application that you can use as part of the IT support tools. It reads the list of the running process on your machine and e-mails it to a designated e-mail address; it also saves the copy of the e-mail to your Sent Items folder for future reference. Before you continue, make sure that you have more than one user account registered and activated on Office 365. User account creation is covered earlier in this chapter.
The following steps demonstrate how to develop a basic Exchange Online application using Visual Studio 2010.
Listing 2-4: Program.cs
using System; using System.Collections.Generic; using System.Configuration; using System.Linq; using System.Text; using Microsoft.Exchange.WebServices.Data; using System.Diagnostics; namespace ExchangeOnlineSample { class Program { static void Main(string[] args) { SendEmail("[USER1]@officeservices.onmicrosoft.com", "pwd", GetProcessesListing(), "List of running processes", "[USER2]@officeservices.onmicrosoft.com"); } private static string GetProcessesListing() { string processList = string.Empty; Process[] runningProcesses = Process.GetProcesses(); foreach (Process theprocess in runningProcesses) { processList += (string.Format("Process: {0} ID: {1}</br>", theprocess.ProcessName, theprocess.Id)); } return processList; } private static void SendEmail(string userID, string userPassword, string emailMsg, string emailSubject, string toAddress) { ExchangeService service; service = new ExchangeService(ExchangeVersion.Exchange2010_SP1); service.Credentials = new System.Net.NetworkCredential(userID, userPassword); service.AutodiscoverUrl(userID, UrlValidationCallback); EmailMessage msg = new EmailMessage(service); msg.ToRecipients.Add(new EmailAddress(toAddress)); msg.Subject = emailSubject; msg.Body = new MessageBody(BodyType.HTML, emailMsg); msg.SendAndSaveCopy(); } private static bool UrlValidationCallback(string redirectionUrl) { return true; } } }
Your application is now available for testing. To test it, follow these steps:
Microsoft provides developers with Lync SDK, which contains MA API targeting Lync 2010 Object Model (OM). You can use this SDK to build custom applications that leverage Lync 2010 features, such as Audio and Video conferencing, File Sharing, Desktop Sharing, and so on.
Microsoft has used Lync MA API to develop controls for the Lync 2010 client. You can also develop your custom Lync controls using the MA API, and these controls can integrate easily with the Lync 2010 client. Alternatively, you can use the Lync 2010 controls that Microsoft ships as part of SDK, because these controls are thoroughly tested, and you can reuse them easily without worrying about their performance and quality. Figure 2-45 shows the Lync Controls in Visual Studio 2010.
One important point to remember while working with the MA API is that it requires running an instance of a Lync 2010 client on the same machine where you plan your application to run.
Now, create a simple WPF application that places an audio call for you. The call is made to an account that you specify in the code. This user must be available on Office 365 and, to receive the call, must be signed in to Lync 2010 client.
In this section, you will create a simple Lync Online application that will place an audio call to a specific Microsoft Online User account. The following steps demonstrate how to build a Lync Online application using Visual Studio 2010.
Listing 2-5: Window1.xaml
<Window x:Class="LyncOnlineAudioCall.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:controls= "clr-namespace:Microsoft.Lync.Controls;assembly=Microsoft.Lync.Controls" Title="Home" Height="79" Width="153"> <Grid> <StackPanel Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center"> </StackPanel> <Button Content="Start Audio Call" Height="35" HorizontalAlignment="Left" Margin="8,2,0,0" Name="btnStartAudioCall" VerticalAlignment="Top" Width="114" Click="btnSendIM_Click" /> </Grid> </Window>
Listing 2-6: Making an Audio Call Using Lync Online API (Window1.xaml.cs)
using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; using System.Diagnostics; using Microsoft.Lync.Model.Extensibility; namespace LyncOnlineAudioCall { public partial class Window1 : Window { public Window1() { InitializeComponent(); } private void btnSendIM_Click(object sender, RoutedEventArgs e) { List<string> participants = new List<string>(); participants.Add("[email protected]"); Automation automation = Microsoft.Lync.Model.LyncClient.GetAutomation(); automation.BeginStartConversation( AutomationModalities.Audio, participants, null, null, automation); } } }
To test your Lync online application, follow these steps:
This section discusses a few common challenges that you may encounter while developing Office 365 solutions. It’s better to take them into consideration earlier rather than later in your development life cycle.
Office 365 provides little support when it comes to working with the error logs. If you get an error, you must rely on the technical support for troubleshooting. This makes troubleshooting for developers, especially regarding SharePoint Online, challenging. Office 365 does not provide you any way to access the SharePoint Online logs, which are located on the server file system. This restriction exists because you share hardware and software with other tenants, and logs are not separated based on tenancy. As error logs may contain business-critical or users’ personal information, providing access to a log file may lead to serious legal consequences. The dedicated version of the SharePoint Online has the same limitation on accessing error logs.
Lync and Exchange Online products impose the same restrictions as SharePoint Online and do not allow access to error logs. However, this is less of an issue because you won’t be deploying custom server-side solutions to either Lync Online or Exchange Online in an Office 365 environment.
You can access Office 365 through the Internet. Having a high bandwidth and low latency connection is extremely important to get consistent performance from custom solutions that consume Office 365 services. You should test your solutions under different bandwidths and network latencies. For example, users with a cable Internet connection usually have latencies of less than 100 ms; on the other hand, users with satellite Internet connection experience latencies of 500 ms or more. Your solutions should be responsive and function correctly under different bandwidths and network latencies.
While developing custom web-based solutions for Office 365, you should consider cross-browser support as a high priority. Office 365 supports a wide range of browsers, from Microsoft Internet Explorer to Google Chrome. Determine browser support for your solutions before you begin development. You should also develop your solutions to degrade gracefully when users access them with an unsupported browser. Users may simply assume that your web solution supports all the browsers that Office 365 supports, especially if they are available through the Office 365 Marketplace. It’s always a good idea to provide details to your users about which browsers are supported and which are not.
This section discusses Office 365 resources available to developers including wikis, forums, learning resources, and so on.
The following section provides details to help you quickly start development for Office 365.
You can minimize your learning curve for Office 365 development by leveraging technical skillsets that you already possess. For example, if you already have an ASP.NET development background, developing custom web-based solutions for Office 365 will be easier than developing a WPF application. Office 365 service offerings are based on already-released products from Microsoft, so if you have experience with either one of them, you can leverage that development experience because it’s highly likely that you will pick up the differences rather quickly.
When compared to on-premises solutions, developing cloud-based solutions does require a certain discipline. A good example of this is when you build sandbox solutions for SharePoint Online. When you develop SharePoint solutions on-premise, sandbox solutions only expose a subset of the available APIs. In addition, every piece of code that you execute in the sandbox counts toward the resource threshold that SharePoint administration allocates. If your code consumes more resources than what SharePoint administration allocates, your code will be penalized. For example, a web part on the home page of your corporate portal may suddenly stop working because it consumes too many resources. In short, good coding practices are mandatory when you build applications for the cloud services, and this may add to the learning curve for developers.
You can also use learning resources provided by Microsoft, as listed in Table 2-2; these resources are available online and free of charge. Microsoft performs frequent updates to these resources as changes are made to Office 365.
Title | Description | URL |
Office 365 Developer Training Course | Developer-focused presentations, self-paced labs, and links to key resources to help you build solutions that leverage SharePoint Online, Exchange Online, and Lync Online | http://msdn.microsoft.com/en-us/Office365TrainingCourse |
Exchange Online Development Center | Developer Center for Microsoft Exchange Online as part of Microsoft Office 365 | http://msdn.microsoft.com/exchange/gg490662 |
SharePoint Online Developer Resource Center | Developer Center for Microsoft SharePoint Online as part of Microsoft Office 365 | http://msdn.microsoft.com/sharepoint/gg153540 |
Exploring the Office Developer Story in Microsoft Office 365 | Session recording from TechEd 2011 covering topics such as client-side add-ins accessing Microsoft SharePoint data, client object model, cloud programmability with Microsoft Excel, and Visio Services | http://channel9.msdn.com/Events/TechEd/NorthAmerica/2011/OSP206 |
Microsoft has established a proactive community for Office 365. The community is built around consumers of Office 365, including developers, IT professionals, end users, project managers, and others. Table 2-3 provides details about the Office 365 forums, blog, and wikis.
Title | Description | URL |
Forums | Forums where your platform can post questions and start discussions about topics related to Office 365 | http://community.office365.com/en-us/f/default.aspx |
Blogs | Office 365 engineering team blog | http://community.office365.com/en-us/b/office_365_technical_blog/default.aspx |
Wiki | Office 365 team wiki | http://community.office365.com/en-us/w/default.aspx |
Office 365 Marketplace is a platform that enables Office 365 consumers to locate applications, professional services, and subject-matter experts for Microsoft Office 365. To enroll your application or professional services with Office 365 Marketplace, you must meet certain requirements. You can get more details on requirements and how to apply them from http://office365.pinpoint.microsoft.com/.
Office 365 Marketplace is mostly directed toward business users that usually have a different set of needs and expectations. For example, developing an Angry Birds game as a SharePoint Online solution may not give the same return on investment as it does on the Windows Phone Marketplace.
This chapter provides the foundation to start developing applications for Office 365. It starts by providing the walkthrough of the Office 365 registration process. It then discusses the two major approaches available to you for building development environments. It also explains the pros and cons of using a virtualized development environment versus physical machines. The walkthrough later in the chapter demonstrates how to build a development environment for Office 365 and add software to it as required. The sections on SharePoint Online, Exchange Online, and Lync Online development demonstrate how to quickly build and test your application using Visual Studio 2010. You also learn how to provision a new Site Collection on SharePoint Online and upload and activate you custom solution on it. Later in the chapter, you learn about a few common development challenges associated with Office 365 development and some important Office 365 community and learning resources available to you.