37
Hands-On Lab Integrating SharePoint and Cloud Services in Windows Phone 7 Applications Lab version: 1.0.0 Last updated: 4/11/2022 Page | 1

Integrating SharePoint and Cloud Services in …az12722.vo.msecnd.net/.../Lab.docx · Web viewWindows Phone 7 applications that that use Windows Azure Services in addition to SharePoint

  • Upload
    others

  • View
    1

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Integrating SharePoint and Cloud Services in …az12722.vo.msecnd.net/.../Lab.docx · Web viewWindows Phone 7 applications that that use Windows Azure Services in addition to SharePoint

Hands-On LabIntegrating SharePoint and Cloud Services in Windows Phone 7 Applications

Lab version: 1.0.0

Last updated: 5/16/2023

Page | 1

Page 2: Integrating SharePoint and Cloud Services in …az12722.vo.msecnd.net/.../Lab.docx · Web viewWindows Phone 7 applications that that use Windows Azure Services in addition to SharePoint

CONTENTS

OVERVIEW................................................................................................................................................. 3Using dsinit to Configure Development Storage..................................................................................5

EXERCISE 1: CREATING A SHAREPOINT LIST DATA SOURCE...........................................................6Task 1 – Deploying the List Template to a SharePoint Site..................................................................6

Task 2 – Creating the Maintenance Requests List................................................................................7

EXERCISE 2: CREATING A WINDOWS AZURE WCF SERVICE IN THE LOCAL APPFABRIC.............9Task 1 – Beginning the Exercise...........................................................................................................9

Task 2 – Implementing and Configuring the WCF Service....................................................................9

EXERCISE 3: CREATING THE WINDOWS PHONE 7 APPLICATION...................................................10Task 1 – Beginning the Exercise.........................................................................................................11

Task 2 – Configuring Constants in the Windows Phone 7 Application...............................................11

Task 3 – Adding a Reference to the SharePoint Lists.asmx Web Service...........................................11

Task 4 – Retrieving Maintenance Requests from SharePoint............................................................12

Task 5 – Adding a Reference to the Windows Azure WCF Service.....................................................13

Task 6 – Retrieving Replacement Part Lead-Time from Azure...........................................................14

Task 7 – Modifying the web.config File to Support the Cookie Container Used with Forms BasedAuthentication.........................................................................................................................15

Task 8 – Testing the Application in the Local Azure AppFabric Simulation Environment...................16

EXERCISE 4: DEPLOYING AND TESTING IN THE CLOUD...................................................................19Task 1 – Packaging the WCF Service for Publishing to Windows Azure.............................................19

Task 2 – Uploading the Deployment Package and Configure the PartsService in Windows Azure....20

Task 3 – Configuring the Windows Phone 7 Application to Access the Service Deployed to Windows Azure.................................................................................................................................................25

Task 4 – Testing the Application with the PartsService Windows Azure WCF Service Deployed to the Cloud.................................................................................................................................................26

SUMMARY................................................................................................................................................ 29

Page | 2

Page 3: Integrating SharePoint and Cloud Services in …az12722.vo.msecnd.net/.../Lab.docx · Web viewWindows Phone 7 applications that that use Windows Azure Services in addition to SharePoint

Overview

Windows Phone 7 applications that that use Windows Azure Services in addition to SharePoint data enable integration between SharePoint data and services with external services hosted in the cloud. Visual Studio 2010 provides a rich development environment for creating, deploying, and integrating Windows Azure Service with Windows Phone 7 applications.

Objectives

In this hands-on lab, you will learn how to integrate SharePoint data with a Windows Azure Service in a Windows Phone 7 application. You will learn how to create and deploy a Windows Azure Service, and also how to call the Windows Azure Service from a Windows Phone 7 application. You will also learn how to use SharePoint data to supplement the functionality in the Windows Phone 7 application.

Learn how to integrate SharePoint data with a Windows Azure Service in a Windows Phone 7 application.

See how to create and deploy a Windows Azure Service.

See how to call the Windows Azure Service from a Windows Phone 7 application.

Learn how to use SharePoint data to supplement the functionality in the Windows Phone 7 application.

Prerequisites

The following is required to complete this hands-on lab:

Note: See Setting Up A SharePoint and Windows Phone 7 Development Environment Module for instructions that describe how to set up the SharePoint and Windows Phone 7 developer machine.

Windows 7 x64 installed with all Windows Updates installed, in one of the following scenarios.

◦ Installed on a physical machine

◦ Installed on a bootable VHD

SharePoint 2010 installed on the Windows 7 x64 developer machine configured with a site collection that uses Forms Based Authentication (FBA).

Windows Phone 7 Developer ToolsPage | 3

Page 4: Integrating SharePoint and Cloud Services in …az12722.vo.msecnd.net/.../Lab.docx · Web viewWindows Phone 7 applications that that use Windows Azure Services in addition to SharePoint

◦ http://download.microsoft.com/download/1/7/7/177D6AF8-17FA-40E7-AB53- 00B7CED31729/vm_web.exe

Windows Phone 7 Developer Tools - January 2011 Update

◦ http://download.microsoft.com/download/6/D/6/6D66958D-891B-4C0E-BC32- 2DFC41917B11/WindowsPhoneDeveloperResources_en-US_Patch1.msp

Windows Phone Developer Tools Fix

◦ http://download.microsoft.com/download/6/D/6/6D66958D-891B-4C0E-BC32- 2DFC41917B11/VS10-KB2486994-x86.exe

Note: The following prerequisites are not included in the Setting Up A SharePoint and Windows Phone 7 Development Environment Module installation instructions. If you are using a development machine built according to the Setting Up A SharePoint and Windows Phone 7 Development Environment Module instructions you must install these components.

Windows Azure SDK and Windows Azure Tools for Microsoft Visual Studio (March 2011)

◦ http://www.microsoft.com/downloads/en/details.aspx?FamilyID=7a1089b6-4050-4307- 86c4-9dadaa5ed018

Download and install the files indicated in the screenshot below.

Figure 1Required downloads

KB981002- WCF: Hotfix rollup in .NET 3.5 SP1 for Win 7 and Win 2k8 R2

◦ http://code.msdn.microsoft.com/KB981002

Access to a Windows Azure account.

◦ Go to http://windows.azure.net to create an account.

Page | 4

Page 5: Integrating SharePoint and Cloud Services in …az12722.vo.msecnd.net/.../Lab.docx · Web viewWindows Phone 7 applications that that use Windows Azure Services in addition to SharePoint

First-Time Configuration of the Windows Azure Simulation Environment

Note: The Windows Azure SDK (included in Windows Azure Tools for Visual Studio) installs a simulation environment on your development machine for testing Azure applications locally before deploying them to the cloud. The simulation environment consists of the development fabric to host web and worker roles, and the development storage which simulates cloud blob, table and queue storage locally.

Development storage uses SQL Server as its underlying storage mechanism, and by default the SDK will attempt to configure it to use SQL Server Express. If you do not have SQL Server Express installed before installing the SDK, or you wish to simply use an existing SQL Server instance to host the development storage database, you must run the dsinit command to select the SQL Server instance where the database will be created.

Please see instructions below for how to run dsinit.

Using dsinit to Configure Development Storage

If you already had SQL Server Express installed before installing the SDK, or you wish to simply use an existing SQL Server instance to host the development storage database follow these steps.

1. Open a command prompt.

2. Edit the following command line as appropriate for your environment, where [AzureSDKInstallDrive] is the drive where you installed the Azure SDK (or Windows Azure Tools for Visual Studio), and [YourSqlInstance] is the SqlServer where you want to create the development storage database.

[AzureSDKInstallDrive]\ Program Files\Windows Azure SDK\v1.4\bin\devstore\dsinit.exe /sqlinstance:[YourSqlInstance]

Example Command Line:“C:\Program Files\Windows Azure SDK\v1.4\bin\devstore\dsinit.exe” /sqlinstance:.

3. Note that the sample command line above uses the value “.” for the sqlinstance argument, which specifies that the local default SQL instance will be used for development storage.

Exercise 1: Creating a SharePoint List Data Source

Page | 5

Page 6: Integrating SharePoint and Cloud Services in …az12722.vo.msecnd.net/.../Lab.docx · Web viewWindows Phone 7 applications that that use Windows Azure Services in addition to SharePoint

In this exercise, you will deploy a list template to SharePoint and make a list based upon the template. The list template defines a list used to hold maintenance requests. In this scenario, the Windows Phone 7 application will read the maintenance requests from the SharePoint list and make calls to a Windows Azure Service to determine how long it will take to order the appropriate replacement parts associated with each maintenance request. The Windows Phone 7 application will present this information to help maintenance personnel complete maintenance requests.

Task 1 – Deploying the List Template to a SharePoint Site

In this task, you will deploy the maintenance requests list template to a SharePoint site. The list template contains sample data used in the lab.

1. Open Internet Explorer and navigate to the SharePoint Team Site configured for Forms Based Authentication.

example: http://fbawp7

2. Log into the site using site collection administrator credentials.

3. Click Site Actions, and select Site Settings.

4. In the Galleries section, click List templates.

5. In the Ribbon, click the Documents tab.

6. Click Upload Document.

7. Click Browse…

8. Browse to the Maintenance Requests.stp file located at C:\%TrainingKitPath%\Labs\IntegratingAzureCloudServices\Source\Before and select it.

9. Click Open.

10. Click OK.

11. Click Save.

12. Verify the Maintenance Requests list template appears in the List Templates Gallery.

Page | 6

Page 7: Integrating SharePoint and Cloud Services in …az12722.vo.msecnd.net/.../Lab.docx · Web viewWindows Phone 7 applications that that use Windows Azure Services in addition to SharePoint

Figure 2The Maintenance Request list template

Task 2 – Creating the Maintenance Requests List

In this task, you will use the maintenance requests list template to create the maintenance requests list.

1. Open Internet Explorer and navigate to the SharePoint Team Site configured for Forms Based Authentication.

example: http://fbawp7

2. Log into the site using site collection administrator credentials.

3. Click Site Actions and select More Options.

4. In the Filter By section, select List.

5. Select the Maintenance Requests list.

Figure 3The create list dialog

Page | 7

Page 8: Integrating SharePoint and Cloud Services in …az12722.vo.msecnd.net/.../Lab.docx · Web viewWindows Phone 7 applications that that use Windows Azure Services in addition to SharePoint

6. In the Name textbox enter Maintenance Requests.

7. Click Create.

8. Verify the Maintenance Requests list contains the following sample data.

Figure 4The new Maintenance Request list with data

Exercise 2: Creating a Windows Azure WCF Service in the Local AppFabric

In this exercise, you will create a Windows Azure Service in the local AppFabric. In this scenario, the Windows Phone 7 application calls the Windows Azure Service and passes in the product make and model. The Windows Azure Service returns the lead-time to order and receive the corresponding replacement part from a parts vendor.

Task 1 – Beginning the Exercise

In this task, you will open the lab solution in Visual Studio 2010.

1. Make sure that you have downloaded and installed the items listed in System Requirements above prior to beginning this exercise.

2. Launch Visual Studio 2010 as administrator and open the lab project by selecting File » Open » Project.

a. Browse to the WP7.Cloud.PartsService.sln file located at C:\%TrainingKitPath%\Labs\IntegratingAzureCloudServices\Source\Before and select it.

b. Click Open to open the solution.

Task 2 – Implementing and Configuring the WCF Service

In this task, you will implement a service operation in the PartService WCF service to return the ordering lead-time for a given part.

1. In the WCFServiceWebRole project, open the file PartService.svc.cs. Page | 8

Page 9: Integrating SharePoint and Cloud Services in …az12722.vo.msecnd.net/.../Lab.docx · Web viewWindows Phone 7 applications that that use Windows Azure Services in addition to SharePoint

2. Add the following code under the //TODO: 8.1.1 comment to define the GetPartLeadTime method:

C#

public int GetPartLeadTime(string manufacturer, string modelNumber){ //Simulate a call to a vendor to determine the leadtime //for part based on the part's manufacturer and model number. Random random = new Random(); return random.Next(1,12);}

The above code performs a simple calculation to simulate a call to a vendor system to determine the lead-time for a part based on the part’s manufacturer and model number.

3. In the Solution Explorer, right click the PartService.svc file and select Set As Start Page.

4. Press the F5 key to run the Azure Web Role in the local Azure AppFabric simulation environment. This causes the web roles to run on your local machine.

5. Verify the PartService.svc service is available when it opens in Internet Explorer.

6. Do not stop the WP7.Cloud.PartsService project. You will use the running instance of the service in upcoming steps.

Page | 9

Page 10: Integrating SharePoint and Cloud Services in …az12722.vo.msecnd.net/.../Lab.docx · Web viewWindows Phone 7 applications that that use Windows Azure Services in addition to SharePoint

Figure 5The Part Service page

Exercise 3: Creating the Windows Phone 7 Application

In this exercise, you will create a Windows Phone 7 application to query the maintenance tasks SharePoint list and the Windows Azure Service created in exercise 2. You will also test the application in the local Azure AppFabric simulation environment.

Task 1 – Beginning the Exercise

In this task, you will open the lab solution in Visual Studio 2010.

Page | 10

Page 11: Integrating SharePoint and Cloud Services in …az12722.vo.msecnd.net/.../Lab.docx · Web viewWindows Phone 7 applications that that use Windows Azure Services in addition to SharePoint

1. Make sure that you have downloaded and installed the items listed in System Requirements above prior to beginning this exercise.

2. Launch Visual Studio 2010 as administrator and open the lab project by selecting File » Open » Project.

a. Browse to the WP7.Cloud.PartsClient.sln file located at C:\%TrainingKit%\Labs\IntegratingAzureCloudServices\Source\Before and select it.

b. Click Open to open the solution.

Task 2 – Configuring Constants in the Windows Phone 7 Application

In this task, you will configure the constants used in the Windows Phone 7 application to work with your development environment.

1. In the WP7.Cloud.PartsClient project, in the Utilities folder, open the Constants.cs file.

2. Change the value for the USER_NAME and USER_PASSWORD constants to represent a Forms Based Authentication user specific to your development environment. For this lab, the user requires reader permissions.

3. Change the value for the AUTHENTICATION_SERVICE_URL constant to the URL specific to your development environment.

The following code example demonstrates the value for a SharePoint server named fbawp7.

C#

public const string AUTHENTICATION_SERVICE_URL = "http://fbawp7/_vti_bin/authentication.asmx";

Task 3 – Adding a Reference to the SharePoint Lists.asmx Web Service

In this task, you will add a reference to the SharePoint lists.asmx Web service.

1. In the Solution Explorer, in the WCFServiceWebRole project, right click Service References and select Add Service Reference.

2. In the Address textbox enter the URL to the lists.asmx SharePoint web service for the site where you created the Maintenance Tasks list.

Example: http://fbawp7/_vti_bin/lists.asmx

3. Click Go.

4. Once the service is resolved, enter SPListsService in the Namespace textbox.

5. Click OK.

Task 4 – Retrieving Maintenance Requests from SharePointPage | 11

Page 12: Integrating SharePoint and Cloud Services in …az12722.vo.msecnd.net/.../Lab.docx · Web viewWindows Phone 7 applications that that use Windows Azure Services in addition to SharePoint

In this task, you will use the SharePoint lists.asmx Web service to return maintenance requests from the SharePoint list.

1. In the WP7.Cloud.PartsClient project, in the ViewModels folder, open the MainViewModel.cs file.

2. Add the following code under the //TODO: 8.1.2 comment to define the LoadMaintenanceTasks method:

C#

public void LoadMaintenanceTasks(){ XElement viewFields = new XElement("ViewFields", new XElement("FieldRef", new XAttribute("Name", "Title")), new XElement("FieldRef", new XAttribute("Name", "Body")), new XElement("FieldRef", new XAttribute("Name", "Make")), new XElement("FieldRef", new XAttribute("Name", "Model")));

WP7.Cloud.PartsClient.SPListsService.ListsSoapClient lists = new WP7.Cloud.PartsClient.SPListsService.ListsSoapClient(); lists.CookieContainer = App.CookieJar; lists.GetListItemsCompleted += new EventHandler<WP7.Cloud.PartsClient.SPListsService. GetListItemsCompletedEventArgs>(lists_GetListItemsCompleted); lists.GetListItemsAsync(Constants.SHAREPOINT_LIST_NAME, string.Empty, null, viewFields, null, null, null);}

The above code uses the proxy class Visual Studio 2010 generated for the lists.asmx service to query the Maintenance Tasks SharePoint list.

3. Add the following code under the //TODO: 8.1.3 comment to define the lists_GetListItemsCompleted method:

C#

void lists_GetListItemsCompleted(object sender, WP7.Cloud.PartsClient.SPListsService.GetListItemsCompletedEventArgs e){ IEnumerable<XElement> rows = e.Result.Descendants(XName.Get("row", "#RowsetSchema")); IEnumerable<SPMaintenanceTask> maintenanceTasks = from element in rows select new SPMaintenanceTask

Page | 12

Page 13: Integrating SharePoint and Cloud Services in …az12722.vo.msecnd.net/.../Lab.docx · Web viewWindows Phone 7 applications that that use Windows Azure Services in addition to SharePoint

{ Title = (string)element.Attribute("ows_Title"), Body = Utils.HtmlToText((string)element.Attribute("ows_Body")), Make = (string)element.Attribute("ows_Make"), Model = (string)element.Attribute("ows_Model") };

Deployment.Current.Dispatcher.BeginInvoke(() => { if (MaintenanceTasks == null) { MaintenanceTasks = new ObservableCollection<SPMaintenanceTask>(); } MaintenanceTasks.Clear(); maintenanceTasks.ToList().ForEach(a => MaintenanceTasks.Add(a)); });}

The lists_GetListItemsCompleted method fires when the call to the lists.asmx SharePoint Web service completes. The method parses the result set, creates an instance of the SPMaintenanceTask that represents each maintenance task in the SharePoint list, and adds the SPMaintenanceTask instances to the MaintenanceTasks observable collection. The MaintenanceTasks observable collection is bound to the MainPage user control in the Windows Phone 7 application. The MainPage user control displays the maintenance requests retrieved from the SharePoint list.

4. Save MainViewModel.cs.

Task 5 – Adding a Reference to the Windows Azure WCF Service

In this task, you will add a reference to the PartsService Windows Azure WCF Service created in Exercise 2.

1. In the Solution Explorer, in the WP7.Cloud.PartsClient project, right click Service References and select Add Service Reference.

2. In the Address textbox enter the URL to the local running instance of the PartsService Windows Azure Service.

Example: http://127.0.0.1:81/PartService.svc?wsdl

3. Click Go.

4. Once the service is resolved, enter PartsService in the Namespace textbox.

5. Click OK.

Page | 13

Page 14: Integrating SharePoint and Cloud Services in …az12722.vo.msecnd.net/.../Lab.docx · Web viewWindows Phone 7 applications that that use Windows Azure Services in addition to SharePoint

Task 6 – Retrieving Replacement Part Lead-Time from Azure

In this task, you will retrieve the replacement part lead-time from the PartsService Windows Azure WCF Service.

1. In the WP7.Cloud.PartsClient project, in the ViewModels folder, open the MaintenanceTaskViewModel.cs file.

2. Add the following code under the //TODO: 8.1.4 comment to define the RetrieveLeadTimeFromCloud method:

C#

public void RetrieveLeadTimeFromCloud(string make, string model){ WP7.Cloud.PartsClient.PartsService.PartServiceClient partsService = new PartsService.PartServiceClient(); partsService.GetPartLeadTimeAsync(make, model); partsService.GetPartLeadTimeCompleted += new EventHandler<PartsService.GetPartLeadTimeCompletedEventArgs> (partsService_GetPartLeadTimeCompleted);}

The above code uses the proxy class Visual Studio 2010 generated for the PartsService Windows Azure WCF Service to return the lead-time for a replacement part based on make and model.

3. Add the following code under the //TODO: 8.1.5 comment to define the partsService_GetPartLeadTimeCompleted method:

C#

private void partsService_GetPartLeadTimeCompleted(object sender, PartsService.GetPartLeadTimeCompletedEventArgs e){ LeadTime = e.Result.ToString();}

The partsService_GetPartLeadTimeCompleted method fires when the call to the PartsService Windows Azure WCF Service completes, and sets the LeadTime property equal to the returned value. The LeadTime property is bound to the MaintenanceTaskView user control in the Windows Phone 7 application. The MaintenanceTaskView user control displays detailed information for a maintenance request selected in the MainPage user control. The detailed information includes the metadata about a give maintenance request from the SharePoint list, as well as the lead-time from the PartsService Windows Azure WCF Service.

4. Save MaintenanceTaskViewModel.cs.

Task 7 – Modifying the web.config File to Support the Cookie Container Used with Forms BasedAuthentication

Page | 14

Page 15: Integrating SharePoint and Cloud Services in …az12722.vo.msecnd.net/.../Lab.docx · Web viewWindows Phone 7 applications that that use Windows Azure Services in addition to SharePoint

In this task, you will modify the web.config file to support the CookieContainer used with Forms BasedAuthentication. The code used to authenticate to the SharePoint server in this lab uses Forms Based Authentication. Forms Based Authentication requires the use of a CookieContainer. Please see the Security With SharePoint And Windows Phone 7 Applications Module for more information about Forms Based Authentication.

1. In the WP7.Cloud.PartsClient project, open the ServiceReferences.ClientConfig file.

2. Locate the ListsSoap binding element.

3. Add the following attribute to the ListsSoap binding element.

XML

enableHttpCookieContainer="true"

The following screenshot shows what the ListSoap binding element looks like after the above code is added.

Figure 6Enable cookies on the binding

4. Save ServiceReferences.ClientConfig.

Note: The following exception will occur if you do not make this change to the ServiceReferences.ClientConfig file.

Page | 15

Page 16: Integrating SharePoint and Cloud Services in …az12722.vo.msecnd.net/.../Lab.docx · Web viewWindows Phone 7 applications that that use Windows Azure Services in addition to SharePoint

Figure 7CookieContainer error

Note: If you change the interface to one or both of the services the application calls and need to update the service reference you will need to remove the XML code above from the ServiceReferences.ClientConfig file then update the service reference. After the service reference update is complete, add the XML code back to the ServiceReferences.ClientConfig file.

Task 8 – Testing the Application in the Local Azure AppFabric Simulation Environment

In this task, you will test the Windows Phone 7 application in the local Azure AppFabric simulation environment.

1. In the WP7.Clioud.PartsClient solution, select Windows Phone 7 Emulator in the deployment location dropdown list.

2. Press F5.

3. The Windows Phone application starts in the emulator and displays the items from the Maintenance Requests SharePoint list.

Page | 16

Page 17: Integrating SharePoint and Cloud Services in …az12722.vo.msecnd.net/.../Lab.docx · Web viewWindows Phone 7 applications that that use Windows Azure Services in addition to SharePoint

Figure 8Maintenance Request items in the application

4. Click on one of the maintenance requests in the list to select it.Page | 17

Page 18: Integrating SharePoint and Cloud Services in …az12722.vo.msecnd.net/.../Lab.docx · Web viewWindows Phone 7 applications that that use Windows Azure Services in addition to SharePoint

5. The Windows Phone application displays the details for the selected maintenance request from the SharePoint list, as well as the lead-time from the PartsService Windows Azure WCF Service.

Figure 9

Page | 18

Page 19: Integrating SharePoint and Cloud Services in …az12722.vo.msecnd.net/.../Lab.docx · Web viewWindows Phone 7 applications that that use Windows Azure Services in addition to SharePoint

Request details

Exercise 4: Deploying and Testing in the Cloud

In this exercise, you will publish the PartsService Windows Azure WCF Service to Windows Azure, configure the Windows Phone 7 application to access the service, and test the Windows Phone 7 application.

Task 1 – Packaging the WCF Service for Publishing to Windows Azure

In this task, you will package the PartsService WCF Service for Azure publishing.

1. Return to the WP7.Cloud.PartService Microsoft Visual Studio 2010 solution.

2. Press Shift-F5 to stop the debugger.

Note: Steps 3-7 help guarantee the Azure Deployment package is as small as possible and help to ensure the package will work once deployed to Windows Azure. You may not need to perform all of these steps in every scenario; they have been included in this lab document to ensure the deployment package will work properly.

3. In the Solution Explorer, right click the WCFServiceWebRole project and select Clean.

4. In the Solution Explorer, right click the WCFServiceWebRole project and select Build

5. In the Solution Explorer, right click the WP7.Cloud.PartsService project and select Clean.

6. In the Solution Explorer, right click the WP7.Cloud.PartsService project and select Build

7. In the Solution Explorer, right click the WP7.Cloud.PartsService project and select Publish.

8. There are two ways to publish the service to Windows Azure.

a. Create a service package, uploading it to Windows Azure.

b. Directly deploying to Windows Azure.

In this scenario, create the service package and upload it to Windows Azure.

9. Select the Create Service Package Only radio button in the Publish dialog box, and select OK.

Page | 19

Page 20: Integrating SharePoint and Cloud Services in …az12722.vo.msecnd.net/.../Lab.docx · Web viewWindows Phone 7 applications that that use Windows Azure Services in addition to SharePoint

Figure 10Deploy Windows Azure project dialog

10. The service package is created in a folder named Publish inside the bin directory. You can access it from the following location:C:\% TrainingKit%\Labs\8-1\Source\Before\WP7.Cloud.PartsService\bin\Debug\PublishTwo files are created at the above location. – The service package file (.cspkg) and the service configuration file (.cscfg)

Task 2 – Uploading the Deployment Package and Configure the PartsService in Windows Azure

In this task, you will upload the deployment package and configure the PartsService WCF Service in Windows Azure.

1. Open Internet Explorer, and go to http://windows.azure.com.

2. Login using your Windows Azure credentials. If you do not have a Windows Azure Account, sign-up for a new one.Create a new Hosted service by clicking the New Hosted Service from the ribbon menu.

Page | 20

Page 21: Integrating SharePoint and Cloud Services in …az12722.vo.msecnd.net/.../Lab.docx · Web viewWindows Phone 7 applications that that use Windows Azure Services in addition to SharePoint

Figure 11Create a new hosted service

3. Configure the new service as follows:

a. Choose a subscription: Select the name of Azure subscription. (You would have provided this information while signing up for the Azure account.)

b. Name of the Service: Provide a user friendly name to the service. See the screenshot below for an example.

c. URL prefix of your service: This is a unique URL. Choose an available URL. See the screenshot below for an example.

Note: When you delete this service, the URL is immediately available to others.

d. Region or Affinity group: This is the physical location of the Azure datacenter hosting your service. Choose a region.

e. Deployment Options: Select “Deploy to production environment”.

Note: In this scenario, the service is published directly to a production environment, but as a best practice, publish the service to a staging environment, and test it on staging before publishing it to Production.

f. Deployment Name: A user-friendly name to identify the service. See the screenshot below for an example.

Page | 21

Page 22: Integrating SharePoint and Cloud Services in …az12722.vo.msecnd.net/.../Lab.docx · Web viewWindows Phone 7 applications that that use Windows Azure Services in addition to SharePoint

g. Package Location: Select “Browse Locally”, browse to the .cspkg file that you published earlier, and select the file.

h. Configuration file: Select “Browse Locally”, browse to the .cscfg file that you published earlier, and select the file.

i. Click OK.

Figure 12Create New Hosted Service dialog

4. If you see a warning, click Yes to override and submit. Page | 22

Page 23: Integrating SharePoint and Cloud Services in …az12722.vo.msecnd.net/.../Lab.docx · Web viewWindows Phone 7 applications that that use Windows Azure Services in addition to SharePoint

Note: This warning indicates that this deployment is a single instance deployment. For a 99.95% uptime Microsoft recommends at least 2 instances. You can always increase the number of instances in the Production deployment by changing it in the configuration file

Figure 13Deployment Warning Dialog

5. It could take a few minutes for the production environment to be ready. The image below shows a production environment when ready.

Page | 23

Page 24: Integrating SharePoint and Cloud Services in …az12722.vo.msecnd.net/.../Lab.docx · Web viewWindows Phone 7 applications that that use Windows Azure Services in addition to SharePoint

Figure 14Production environment ready

Note: The DNS name in the right panel is the production URL.

6. Open Internet Explorer.

7. In the web browser, navigate to the PartService.svc file to test the deployment.

Example: http://partsleadtime.cloudapp.net/partservice.svc

Note: The URL will be different in your environment. The URL follows the convention http://<DNS name>.cloudapp.net/partservice.svc.

Page | 24

Page 25: Integrating SharePoint and Cloud Services in …az12722.vo.msecnd.net/.../Lab.docx · Web viewWindows Phone 7 applications that that use Windows Azure Services in addition to SharePoint

Figure 15PartService page

Task 3 – Configuring the Windows Phone 7 Application to Access the Service Deployed to Windows Azure

In this task, you will modify the ServiceReferences.ClientConfig file in the Windows Phone application to set the endpoint for the PartsService Windows Azure WCF Service to the production deployment you created in the previous task.

1. In the WP7.Cloud.PartsClient project open the ServiceReferences.ClientConfig file.

2. Locate the BasicHttpBinding_IPartService endpoint element.

3. Modify the address attribute in the BasicHttpBinding_IPartService endpoint element. Replace the existing address value with the URL to the PartsService WCF Service in Windows Azure.

XML

<endpoint address=http://<DNS name>.cloudapp.net/partservice.svc binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IPartService" contract="PartsService.IPartService" name="BasicHttpBinding_IPartService" />

Page | 25

Page 26: Integrating SharePoint and Cloud Services in …az12722.vo.msecnd.net/.../Lab.docx · Web viewWindows Phone 7 applications that that use Windows Azure Services in addition to SharePoint

The following screenshot shows what the BasicHttpBinding_IPartService endpoint element looks like after the above code is modified.

Note: The URL will be different in your environment.

Figure 16Configure the Azure endpoint address

4. Save ServiceReferences.ClientConfig.

Task 4 – Testing the Application with the PartsService Windows Azure WCF Service Deployed to the Cloud

In this task, you will test the Windows Phone 7 application with the PartsService Windows Azure WCF Service deployed to the cloud.

1. In the WP7.Clioud.PartsClient solution, press F5.

2. The Windows Phone application starts in the emulator and displays the items from the Maintenance Requests SharePoint list.

Page | 26

Page 27: Integrating SharePoint and Cloud Services in …az12722.vo.msecnd.net/.../Lab.docx · Web viewWindows Phone 7 applications that that use Windows Azure Services in addition to SharePoint

Figure 17Maintenance Requests in the application

3. Click on one of the maintenance requests in the list to select it.Page | 27

Page 28: Integrating SharePoint and Cloud Services in …az12722.vo.msecnd.net/.../Lab.docx · Web viewWindows Phone 7 applications that that use Windows Azure Services in addition to SharePoint

4. The Windows Phone application displays the details for the selected maintenance request from the SharePoint list, as well as the lead-time from the PartsService Windows Azure WCF Service.

Figure 18

Page | 28

Page 29: Integrating SharePoint and Cloud Services in …az12722.vo.msecnd.net/.../Lab.docx · Web viewWindows Phone 7 applications that that use Windows Azure Services in addition to SharePoint

Request details

Summary

In this hands-on lab, you saw how to integrate SharePoint data with a Windows Azure Service in a Windows Phone 7 application. You learned how to use SharePoint data to supplement the functionality in the Windows Phone 7 application. Finally, you learned how to create and deploy a Windows Azure Service, and also how to call the Windows Azure Service from a Windows Phone 7 application.

Page | 29