Chapter 1

Getting Started with SharePoint and the Cloud

What's in This Chapter?

  • Understanding the cloud and its importance
  • Integrating the cloud with SharePoint
  • Setting up your development environment
  • Creating your first SharePoint and cloud application

In this first chapter, you'll learn about what the cloud is and why it's important. You'll also learn about the set of cloud technologies that this book uses to integrate with SharePoint: Windows Azure, Web 2.0, Bing Maps, and Microsoft Dynamics CRM. To get started with your development, you'll walk through how to get your development environment up and running, using one of two options: a native installation or a prepped virtual machine. Once your development environment is up and running, you'll finish the chapter by creating your first cloud-based application for SharePoint.

Overview of the Cloud

Increasingly, “the cloud” is being discussed as a major inflection point for the next generation of IT. In fact, depending on what you read, “inflection point” might be an understatement; research institutions like Gartner and Forrester are characterizing the cloud as a “disruptive shift.” This is because of the shift from the traditional software development and deployment process (which predominantly lives in an on-premises data center or lab) is evolving more towards a services-driven approach in which software lives in the cloud.

Regardless of how we characterize the cloud, though, we must answer a common set of baseline questions before we can even think about building our first cloud application. For example, what is the cloud? How can you engage with it? How will it affect you and your business? And, critical to this book, how will it impact (or augment) your SharePoint practice and solutions?

While these seem like fairly basic questions, in reality the answers are not necessarily simple ones. For example, a recent InfoWorld article stated “… the problem is that … everyone seems to have a different definition” of the cloud and cloud computing (www.infoworld.com/d/cloud-computing/what-cloud-computing-really-means-031). As the article points out, often the cloud is a metaphor for the Web — itself a vastly connected set of resources — which begs the question of where the cloud, or cloud computing, starts and where it ends. Despite the many definitions of the cloud and cloud computing, we should agree for the purposes of this book that the cloud does indeed represent a metaphor for the Web and that cloud computing represents using the Web as a connected set of resources to build and deploy your software.

Deploying your software to the Web represents a model for ubiquitous application development and deployment. Among the advantages that it provides are the following:

  • Services
  • Shared computing resources and storage
  • Quick provisioning of hardware and software
  • Minimal management of IT infrastructure and software
  • Reduced overhead and improved cost optimization

The goals of cloud computing include increasing your application's speed to market; avoiding the hurdles that current IT departments currently face with ordering and managing hardware, deploying and managing software; and increasing or decreasing capacity based on real-time application demand. In essence, software deployment and management are moving off premises to data centers throughout the world.

Today, you can find many examples of cloud computing, including technologies such as Microsoft Dynamics CRM, Microsoft Office 365, Hotmail, SkyDrive, SalesForce.com, Google Apps, Amazon AWS, and Windows Azure. However, how are these cloud-based technologies different from what you're managing on-premises today? For example, consider Figure 1.1. The leftmost column shows a typical representation of what a business manages within its on-premises data centers or labs: You run the applications, the staff, and the resources to manage the software and hardware; you have people building and deploying software into that environment; and so on. However, as you move right across the diagram, various services can handle some of these management needs.

IaaS (Infrastructure as a Service) provides you with virtualization capabilities, such as a virtual machine (VM) instance that enables you to host machines in the cloud. Amazon AWS and Windows Azure offer this type of cloud solution. In this scenario, you are beginning to manage fewer on-premise tasks, moving some of your computing into the cloud. PaaS (Platform as a Service) enables you to deploy code or data to the cloud. Windows Azure offers this type of service, as does Google. Here again, you're moving more of your computing and data into the cloud.

Finally, SaaS (Software as a Service) provides you with everything you need, so you don't have to manage any on-premise IT infrastructure. This is a compelling option for many companies because you can choose to have everything managed for you or you can do it through browser-based applications that are directly tied to your cloud offering. Microsoft Office 365 and SalesForce.com are examples of this type of cloud offering.

The key takeaway here is that cloud computing provides you with different ways to build and deploy an application or solution and manage it over time within the cloud.

In this book, we want to explore this practice of deploying code to the cloud against integrating that code with an on-premises (or cloud-based) instance of SharePoint. Specifically, we want to discuss how a number of popular cloud technologies integrate with SharePoint Server 2010; therefore, a range of different cloud services are discussed. Of the cloud models just described, we'll focus predominantly on PaaS; that is, we'll either consume existing services, resources or data that already live in the cloud or create new services or data structures and deploy them to the cloud. These cloud technologies will cut across Windows Azure, Web 2.0, Bing Services, and Microsoft Dynamics CRM. The cloud technologies will then be tied back into SharePoint to demonstrate how you can extend your on-premise SharePoint solutions into the cloud.

Windows Azure

Windows Azure, Microsoft's cloud-computing platform, offers all the standard service types discussed earlier: IaaS, PaaS, and SaaS. Windows Azure is a flexible cloud-computing platform that provides services for virtualizing VMs, managing resources, data, and services, and building cloud-based applications and websites. As Microsoft's key cloud strategy, Windows Azure enables you to provision and scale resources to the cloud without having to worry about chasing and managing your on-premise hardware. When you use Windows Azure, for example, you not only get application scale (hardware needs expanding as your data and application needs grow), but you also get patching and operating-system management (your cloud-hosted environment is always up to date), and a 99.9% uptime guarantee. As a developer, you'll also have a developer portal, which you can use to manage your applications.

Windows Azure currently comprises three main constituent parts:

  • Windows Azure — Windows Azure offers a core set of service-management capabilities, developer tools, and a portal through which you can configure your applications, data and services, and different types of storage (table, BLOB and queue) for nonrelational data. In addition, the Windows Azure Marketplace DataMarket enables you to integrate directly with subscription-based data that can be consumed programmatically or via the Marketplace browser UI.
  • SQL Azure — You can think of SQL Azure as SQL Server's sister product for the cloud. SQL Azure represents relational data storage for the cloud. Using SQL Azure, you can migrate or build relational databases that provide rich and queryable data sources for your cloud-based or hybrid applications. You can also synchronize your on-premise data with that which lives in SQL Azure and use the same skills you know today to integrate SQL Azure data with SharePoint.
  • Windows Azure AppFabric — Windows Azure AppFabric offers a broad set of middleware services that help you manage security and identity (Access Control Service), service-based applications, workflow, and more. This set of middleware services provides a compelling way to connect on-premise data to your cloud-based solutions. One example of the power of these services is surfacing line-of-business (LOB) data that lives in your data centers or in your SharePoint instances to Office 365 or remote devices through the Windows Azure AppFabric service bus.

Together, these three parts provide a rich and deep set of technologies that enable you to manage your application development and deployment needs.

You'll be using Windows Azure in a number of chapters in the book, so you'll want to create an account for yourself. To do this, visit https://windows.azure.com/default.aspx. After you've created an account, you'll have access to the Windows Azure portal. Download the Windows Azure SDK and Visual Studio tools. At the time of writing, you can find the SDK and tools at www.microsoft.com/download/en/details.aspx?id=15658.

Web 2.0

Web 2.0 technologies are all about the social Web, and it's likely that many of you who are reading this book are already participating in Web 2.0. (In fact, some of you have likely seen articles on Web 3.0, or what is more commonly called the semantic Web.) Examples of Web 2.0 technologies include Facebook, LinkedIn, Twitter, and Google+. These technologies, and many others, are typically browser based (although many companies are building device-specific or rich-client applications that leverage Web 2.0 APIs), and they provide places for people to commune and collaborate across different contexts on the Web. For example, LinkedIn is a professional Web 2.0 site that lends itself well to people connecting and collaborating through their professional expertise. Conversely, Facebook is more personal, although many companies have built Facebook sites to introduce their products and services into the virtual conscience. Twitter provides 140-character “tweets” that enable members to quickly communicate news, gossip, events, and so on. According to the company, more than 60 million tweets are sent every day.

While many Web 2.0 sites can operate in and of themselves, they typically have functionality that can be accessed programmatically and then integrated within SharePoint. For example, consider the huge volume of messages that are sent through Twitter; tweets are valuable data for many companies because they represent a collective, virtual conscience that can be measured both qualitatively and quantitatively. You can build small apps as part of a wider portal to view trending for specific topics. In addition, you might want to integrate LinkedIn profiles with your in-company profiles. Because many Web 2.0 applications and sites have open APIs, it's entirely possible to build interesting integrations with SharePoint, given its collaborative nature.

In this book, you'll build applications that live in SharePoint but integrate with LinkedIn and Twitter as two examples of leveraging Web 2.0.

Bing Services

While Windows Azure provides you with a platform to build and deploy your own custom services, Bing provides a set of services that are ready to consume. Because we're living in an age in which we're saturated with information, having ways to navigate that information, or even provide more context for the information we have, is increasingly important.

Bing offers a broad array of services, ranging from search to geo-mapping services. The Bing services used in this book predominantly revolve around the mapping and geo-location services. To access their services, Bing provides a rich set of APIs that you can use to programmatically integrate Bing functionality into your applications. For example, imagine that you have a list of customers and contact information in SharePoint but you want to be able to map those customers and then provide auto-generated driving directions for your customer visits. You can integrate Bing and SharePoint to provide this integrated experience with the native services provided by Bing, which are often provided in both REST-based and SOAP-based services.

As mentioned earlier, Bing provides a broad array of services (some of which are browser-based and some of which can be accessed programmatically) such as images and search services (which Bing is commonly known for), news, related search (search-filtering capabilities), translation, video, and flight status. The flight status service is another one of the Bing services that can be accessed programmatically. For example, if you have a list of the trips your employees are taking, you can build a small application that checks the status of the flight service, and then integrate it with SharePoint. Some of these services are being launched and managed through the Windows Azure Marketplace DataMarket as an additional way to subscribe to and use these increasingly important and data-driven services.

Before you can develop applications for Bing, you need to obtain a developer key. You can do so by visiting the developer portal, at www.microsoft.com/maps/developers/web.aspx. You'll also find key links to SDK documents and code samples.

Microsoft Dynamics CRM

Microsoft Dynamics CRM is a multilingual customer relationship management (CRM) software package that is deployable both on-premise and in the cloud. CRM is a little misleading because Dynamics CRM can manage many different types of data, not just sales and marketing data. In fact, CRM is an excellent data-driven application for many types of data. With the latest release (2011), Microsoft has significantly enhanced the capabilities of Dynamics CRM to include both out-of-the-box functionality in the cloud and the capability to extend it with custom solutions through the XRM platform.

What makes CRM powerful is not just the capability to quickly create “entities” that represent your customer data, but also the fact that Dynamics CRM has a rich set of web services that enable you to programmatically access this data from other applications. This enables you to use Dynamics CRM for what it's intended, data-driven and business-process applications, but still consume the data in collaborative environments like SharePoint.

You can access the Microsoft Dynamics CRM web services using a number of different methods in SharePoint. For example, you could consume the web services in common SharePoint artifacts, such as web parts and event receivers; or, if you want to deploy cloud-based applications, you could use JavaScript, jQuery, or Silverlight.

Understanding the Importance of the Cloud

So far, you've been introduced to the concept of the cloud and cloud computing and some of the technologies we'll be discussing within this book. Let's spend a few minutes talking about why the cloud is so important.

One of the key benefits of the cloud is cost; it is less expensive than running your on-premise infrastructure. For example, in the case of Windows Azure, you're paying for usage, as opposed to hardware and support costs, so you don't wind up paying a cost rate of 100% for something you're only using 20% of the time. This makes the cloud model very compelling for companies of all sizes, as any business wants to reduce IT costs but still maintain the capability to deploy and service applications.

Another key benefit that the cloud offers is speed and agility. That is, you can create and deploy applications much more quickly now than in the past. For example, with the quick provisioning of a web role in Windows Azure, you can have a complete web application deployed in a matter of a few minutes. For many subscription services, such as Facebook or SalesForce.com, you can also have accounts up and running and be using the software within a few minutes. For internal, departmental applications, speed and agility is great; it enables you to free up IT resources for all those projects that are triaged below the waterline. However, for external applications that end up in a marketplace, speed and agility suddenly become super-important; they are the difference between getting first or late to the market with either a new software product or updates to your existing products. Thus, the cloud offers a competitive advantage by enabling companies to get their software to users quicker and, in many cases, in a way that can be monetized through a marketplace.

Reuse is another benefit of the cloud. For example, suppose you have an application that you've deployed internally and that you want to expose as an offering to your partners. The cloud is a viable method for sharing that application. Furthermore, with the ever-growing need to support multiple devices, reusability is an imperative — at least with the core application code. The cloud offers a place to deploy applications that can then be accessed by many different devices and form factors — both on-premise and cloud-based.

Another benefit is the capability to tap into a lot of the Web's ongoing creativity. Developers of all ages and backgrounds are engaging in software development, making some very compelling applications and services that are increasingly available for subscription use. These applications are often made available to you via services (such as REST-based or WCF services), so integration with your existing applications is easy to provision (through either a free or paid subscription license, for example) and you don't need to maintain any code (although you do need to track these third-party updates to ensure that your integrations don't break).

While there are many benefits to the cloud, it poses some challenges as well. For example, managing identity in the cloud can be more of an art than a science. With advances in, and increased adoption of, technologies such as OAuth and OpenID, an increasing number of developers and applications are using open standards. Furthermore, with ADFS 2.0, Windows Identity Federation (WIF), and Windows Azure's Access Control Service, you have a wide variety of options for managing your identity needs — a very important aspect of interacting with the cloud.

Working hand-in-glove with identity is security, and this cuts across many different fronts. Every organization has core datasets to protect; we're all aware of cases in which information such as credit card data is being hacked and used for nefarious purposes. Companies also need to protect employee data, sales data, prospect data, and other types of sensitive information. By putting this data in the cloud, companies must implement what are an evolving set of security measures and controls.

Security may be one pivot, but regulation and policy can also prohibit companies from putting their data in the cloud. Many different efforts are underway around the world to understand how regulation prohibits where data can be stored and how companies can work within regulation and policy to manage their resources within the paradigm of cloud computing. What's interesting is that while many organizations are regulated via either policy or law regarding where data resides, they are simultaneously looking for ways to surface views of the data so they have reporting mechanisms in the cloud. Thus, they can store their data on-premise but comply with regulations and laws by only surfacing sliced views of that on-premise data.

These challenges notwithstanding, there is significant cloud momentum. Companies are moving quickly to the cloud, which in turn is speeding development. Therefore, if you're not actively evaluating what the cloud can do for your organization in a broad sense, you may want to start. If you're unsure how to get started (especially in the context of SharePoint), that is what this book is about: introducing you to how to integrate SharePoint with the cloud. By reading this book, you're beginning this process in the context of SharePoint.

Integrating the Cloud with SharePoint

Our assumption is that before picking up this book, you knew something about SharePoint. This book discusses how to build a short list of sample solutions that integrate in some way with the cloud — using the cloud technologies discussed in the previous section. At this point, you are likely wondering what the points of integration are. Because you're somewhat familiar with SharePoint, you already know that the answer to this question is wide and deep. However, let's try to whittle it down a little.

At a high level, you can integrate the cloud with many different SharePoint artifacts. For example, if you take the most common artifact, the web part, you can build custom web parts that provide some level of interactivity with the cloud. This could be a custom Twitter trends report, customer data driven from a CRM online system, or even be a profile viewer for sites like LinkedIn. What makes this development straightforward is that Visual Studio 2010 (and the community tools that are increasingly being released by the developer community) provides a rich set of web part templates for quick development, debugging, and deployment.

While the web part is one point of integration, it's not the only one. You can also use event receivers or workflows to reach out and query cloud-based services or applications and leverage that data from an application deployed to SharePoint. An example of this might be deploying custom services, such as a sales tracker, to Windows Azure. When events or workflow activities reach out to the service to query a specific sales figure, this can subsequently trigger actions in other parts of SharePoint. For example, a follow-up task may be created in SharePoint with a specific retail store when sales figures drop below a certain point. Nintex Live is a real-world example of this; it queries cloud-based services and then moves a workflow activity in a particular direction based on the information returned from that service.

This book provides numerous different examples that demonstrate how you can integrate the cloud with SharePoint. For example, you'll learn how you can use SQL Azure to build business intelligence solutions, and Windows Azure to build custom service scenarios that use Excel Services to service on-premise financial data. You'll also see examples that demonstrate how you can integrate Bing Maps with SharePoint to provide location information on data coming from a SharePoint list; how to integrate LinkedIn profile information with SharePoint and build Twitter trend reports; and how you can leverage ADFS to federate security to Windows Azure to seamlessly pass claims and authenticate users both on-premise and in the cloud. In short, each chapter serves as an introduction to how you can integrate different aspects of the cloud — be it customer information from Dynamics CRM or federated security — and walk through easy-to-follow solutions that illustrate an integrated pattern. Each chapter leverages a different aspect of SharePoint in some way, including security, web parts, and client-side applications such as Silverlight or JavaScript.

Setting Up Your Development Environment

You can set up your development environment in two ways. The first way is to download a virtual machine (called the Information Worker Virtual Machine, or IW VM) with everything installed on it. Microsoft has created this for you to use when you start developing for SharePoint; it is by far the easiest and the most fail-safe way to set up your development environment. (You will need Windows Server 2008 R2 to run the VM.) Although you may prefer the performance of your development efforts on a native installation, working within a VM for your development enables you to apply and revert to snapshots at any time you want. You'll realize that this one feature is very useful.

The second option is to install all the software you need locally on your machine (or natively, as we'll sometimes refer to it). The baseline software you're going to need to set up your development environment is as follows:

  • A Windows 64-bit compliant operating system (e.g., Windows Server 2008 R2 or Windows 7)
  • SharePoint Foundation 2010 and/or SharePoint Server 2010
  • SharePoint Designer 2010
  • Microsoft Office (Professional Plus) 2010
  • Visual Studio 2010
  • .NET Framework 4.0
  • Microsoft Expression Blend (optional but recommended for Silverlight programming)
  • SQL Server (Express) 2008

Having the preceding components will enable you to follow along with the coding examples throughout this book, and these are the baseline requirements to get up and running for SharePoint 2010 development in your organization. Note that in some cases you will also need to install (or sign up for) other software in each of the chapters to complete the exercises.

note All the aforementioned software is preloaded onto the IW VM that you can download free and use for the 180-day trial period.

Let's first talk a bit more about setting up the virtualized environment and then discuss how you can set up a native installation on your local machine.

Setting Up a Virtualized Environment

In Windows 2008 R2 (64-bit), you can use the Hyper-V technologies to manage your VMs. The environment is a role that you set up when configuring your Windows operating system. For example, after you install Windows Server 2008 R2, you can add the Hyper-V role through the Server Manager. Figure 1.2 shows an example of the Add Roles Wizard at the Server Roles step in the wizard. When you invoke the wizard, you can click the checkbox beside the Hyper-V role and Windows will install it for you. Note that I've already added the Hyper-V role to my machine.

Installing Hyper-V

Assuming you already have your Windows operating system in place, use the following steps to install Hyper-V.

1. Click Start ⇒ Administrative Tools ⇒ Server Manager.

2. In the Server Manager, scroll to the Roles Summary and then click Add Roles and select Hyper-V from the list.

3. Server Manager takes you through a number of steps. Accept the default options and click Next until the Install button is enabled.

4. Click Install to complete the Hyper-V installation. Note that Windows will prompt you for a system restart. Restart your computer to complete the Hyper-V installation.

5. After you have Hyper-V installed, you can then add a Hyper-V-compliant .vhd file if your team has already prepared one, or you can go about creating one from scratch.

6. To add an existing image, open the Hyper-V snap-in by clicking Start ⇒ Administrative Tools ⇒ Hyper-V Manager.

7. Under Actions, click New ⇒ Virtual Machine, and then specify a Name and Location for the image and click Next.

8. You'll then need to assign a level of RAM to the image — specify 6,500 MB or more.

9. Accept the default option for Configure Networking and click Next.

10. Click the radio button beside Use an Existing Hard Disk, and then browse to that disk and click Finish.

Setting Up a Native Environment

If you want to install the prerequisite software on your local machine, you can do that as well. There are a couple of ways to do this. The first way is to get all the software mentioned earlier and install that on your local machine. The second way is to use the SharePoint 2010 Easy Setup Script, which installs trial versions of all the prerequisite software onto your local machine. You can download the script from www.microsoft.com/download/en/details.aspx?id=23415. Once you download the script, you can start it and go get a coffee (or two), as it takes a while to install everything on your machine. It is, however, a streamlined way to install all the software in the proper sequence, and it saves you the effort of gathering all the software yourself.

note Chris Johnson provides a good blog post on how to use the Easy Setup Script here: http://blogs.msdn.com/b/cjohnson/archive/2010/10/28/announcing-sharepoint-easy-setup-for-developers.aspx.

If you choose to install the software manually, you can install a standalone SharePoint 2010 instance to use as a trial environment, as shown in the following steps. (Because you'll be creating small solutions in this book, you won't need to set up a multi-server farm; this is more for a production environment.)

1. Click the Setup.exe file on your SharePoint 2010 installation DVD (or from your installation location).

2. You'll be prompted to Agree to the License Terms. Click the “I accept the terms of this agreement” checkbox, and then click Continue.

3. Next, you have the option to select different installation options. Click the Standalone button to invoke the Standalone installation. SharePoint will then begin the installation process (which includes a software installation process and a configuration process).

4. When the initial software installation process has completed, you will be prompted with a dialog where you can choose to run the configuration wizard, which configures things like the services, content database, and so on for first-time use (see Figure 1.3). Click the “Run the SharePoint Products and Technologies Configuration Wizard now” checkbox, and then click Close. The configuration wizard will be automatically invoked upon closing this dialog.

SharePoint works through a series of ten configuration steps to complete the configuration process.

5. When the configuration process has completed, you will be prompted with a Configuration Successful dialog. Click Finish.

6. SharePoint should automatically prompt you with the standalone SharePoint instance you created and, upon first opening, ask you to select a type of site and have you set permissions for the site. Explore the different site templates that are available, but choose Team Site and click OK, and then verify and set the security options. Here you can leave the default options and click OK. Your site will then be created and will open at the default landing page (see Figure 1.4).

At this point, your SharePoint environment should be set up and ready to go. However, because you're developing for the cloud, you'll find that you often need to obtain a developer key or create an account to begin using a specific cloud technology. For example, you will need to create a LinkedIn or Twitter account, obtain a Bing Maps developer key, create a Windows Azure account, or create a Dynamics CRM account. As mentioned earlier, subsequent chapters provide the information you need to sign up for each of these as a part of the exercises.

Creating Your First SharePoint Cloud Application

What better way to get your feet wet than to build a cloud-based application in the first chapter! Don't worry, we won't throw you into the deep end; this will be a simple application (we'll call it Map Me!) that shows how to integrate SharePoint and Bing Maps.

Before you start this exercise, you'll need to get a developer account key — a simple and quick step. First, sign into the Bing Maps portal, at www.bingmapsportal.com. As shown in Figure 1.5, you can sign in using your Live ID as an existing user (if you already have a Bing account) or click Create to create a new developer account.

If you click Create, you'll sign in with your Live ID and then walk through a wizard to add an account name and email address, and then you'll be asked to agree to the Bing Maps agreement. Click Save to save your account details. Once your account is provisioned, you need to obtain a developer key for your application. In the main portal, click “Create or view keys.” You can create a key by entering an application name and selecting a specific type of application (see Figure 1.6).

After you click Submit, you'll be provided with a developer key that you'll use in your Bing Maps application.

With your developer key in hand, complete the following steps to create your first cloud application for SharePoint:

1. Open Visual Studio 2010 and click File ⇒ New Project.

2. Under Installed Templates, select Other Project Types ⇒ Visual Studio Solutions ⇒ Blank Solution.

3. Provide a name for your project (e.g., MyFirstCloudApplication) and then click OK.

4. After Visual Studio creates the solution, right-click the new project and select Add ⇒ New Project.

5. In the Add New Project template, select Silverlight Application. Provide a name for the application (e.g., SimpleBingMap) and click OK.

6. When prompted, check the “Host the Silverlight application in a new or existing Web site in the solution” checkbox, and click OK.

7. Right-click the Silverlight application and select Add Reference. In the Add Reference dialog, click Browse.

8. Browse to the Microsoft.Maps.MapControl.dll library on your local machine, select it, and click OK.

9. Right-click the MainPage.xaml file and select View Designer.

10. Add the following bolded code to the XAML view of your Silverlight application:

<UserControl x:Class="SimpleBingMap.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:m="clr-namespace:Microsoft.Maps.MapControl;assembly=Microsoft.Maps.MapControl"
    mc:Ignorable="d"
    d:DesignHeight="414" d:DesignWidth="888">

    <Grid x:Name="LayoutRoot" Background="White" HorizontalAlignment="Stretch"
     VerticalAlignment="Stretch" Height="394" Width="888">
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="888*" />
            <ColumnDefinition Width="314*" />
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="auto" />
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>
        <StackPanel Grid.ColumnSpan="2">
            <TextBlock Text="Map Me!" FontWeight="Bold" FontSize="14" Width="888" />
            <StackPanel Orientation="Horizontal" HorizontalAlignment="Stretch"
             Margin="12,0,12,0">
                <TextBox x:Name="txtbxLatitude"
                         Width="322"
                         Text="Type your latitude here, e.g. 47.7656"
                         FontSize="10"/>
            </StackPanel>
            <StackPanel Orientation="Horizontal" HorizontalAlignment="Stretch"
             Margin="12,0,12,0">
                <TextBox x:Name="txtbxLongitude"
                         Width="322"
                         Text="Type your longitude here, e.g. -122.9957 "
                         FontSize="10"/>
            </StackPanel>
            <StackPanel Orientation="Horizontal" HorizontalAlignment="Stretch"
             Margin="12,0,12,0">
                <Button x:Name="btnFindMe" Content="Map It!" Width="65"
                 Click="btnFindMe_Click" />
            </StackPanel>
        </StackPanel>
        <m:Map CredentialsProvider="Your Developer Key Here."
               x:Name="MyMap" Grid.Row="1" Mode="AerialWithLabels"
               HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="0,14,0,0"
               Grid.ColumnSpan="2">
            <m:Map.Children>
                <m:MapLayer x:Name="PushPinLayer"/>
            </m:Map.Children>
        </m:Map>
    </Grid>
</UserControl>

Your application should now look something like Figure 1.7.

11. Double-click the button (btnFindMe) and add the following bolded code to the MainPage.xaml.cs file:

download
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Maps.MapControl;

namespace SimpleBingMap
{
    public partial class MainPage : UserControl
    {

        public MainPage()
        {
            InitializeComponent();
        }

        private void btnFindMe_Click(object sender, RoutedEventArgs e)
        {
            //Create a new location comprising latitude and longitude.
            Location myLocation = new Location();
            myLocation.Latitude = Double.Parse(txtbxLatitude.Text);
            myLocation.Longitude = Double.Parse(txtbxLongitude.Text);

            //Create a new pushpin to add to the map.
            Pushpin myPPin = new Pushpin();
            myPPin.Width = 7;
            myPPin.Height = 10;
            myPPin.Location = myLocation;
            PushPinLayer.AddChild(myPPin, myLocation, PositionOrigin.Center);

            //Set the main view of the map using the location with a zoom level.
            MyMap.SetView(myLocation, 10);
        }
    }
}

code snippet 076576 Ch01_Code.zip/SimpleBingMap.cs

The code here is fairly straightforward; you're using the Bing Maps API (Microsoft.Maps.MapControl) to create a Location object. The Location object has a Latitude property and Longitude property, which you set and then assign to the PushPin object. You also set some additional properties to the PushPin object, which is then added to the PushPinLayer using the AddChild method.

12. Click F5 to build and debug the application in your default browser.

13. You should now see something similar to Figure 1.8. Enter a latitude and longitude into the two text boxes, and then click the Map It! button.

14. After you've successfully built the Silverlight application, right-click the project and select Open in Windows Explorer. Navigate to where the XAP file (e.g., SimpleBingMap.xap) is located and copy the folder path to the clipboard.

15. Open your SharePoint site and create a new document library called XAPS. Once it's created, click Add document, click the Browse button, and then paste the folder path into the Choose File to Upload dialog.

16. After the file has been uploaded into the new SharePoint document library, right-click the link to the XAP file and select Copy Shortcut.

17. Navigate to the top level of the SharePoint site that was created when you installed and configured SharePoint. Click Site Actions and Edit Page.

18. Click the Insert tab and then click the Web Part button in the ribbon. In the Categories, select Media and Content, and then click the Silverlight Web Part.

19. Click Add, and then paste the shortcut to the XAP file that you uploaded into the XAPS document library. You will need to resize the web part, which you can do by clicking Edit web part and changing the Width to 900 and the Height to 400.

Congratulations! You've created your first cloud application that integrates with SharePoint. When loaded properly, the Map Me! application should look something like Figure 1.9. Admittedly, this was more of a Hello World application, but it gives you some idea of just what a simple cloud application can do. This application could absolutely be extended to interact with SharePoint lists, and you could tap into the extensive Bing Maps APIs (which you will do later in the book).

Summary

This chapter introduced you to the core concept of the cloud, reinforcing the idea that the cloud represents a significant opportunity to engage in software development in a new and compelling way. Cloud computing is an oft-disputed concept, but for this book we've defined the cloud as a metaphor for the Web and that cloud computing represents using the Web as a connected set of resources to build and deploy your software. This chapter also introduced a number of different cloud technologies, such as Windows Azure, Web 2.0, Bing Maps, and Microsoft Dynamics CRM. These are the core cloud technologies that we'll focus on throughout the course of this book. In fact, each subsequent chapter will in some way use one of these technologies as a point of integration with SharePoint to build cloud-based applications.

The cloud is a novel and exciting place for application development, and one that's full of potential. This potential is compounded when you begin to look at what you can do with SharePoint, as the cloud is certain to play a very important role in SharePoint's future. This can be seen in the short term with the growing popularity of Office 365. We hope this book helps you get started with both developing for the cloud and integrating your cloud-based solutions with SharePoint.

Additional References

Following are some additional references that you might find useful:

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset