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.
    1. Create a service package, uploading it to Windows Azure.
    2. 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.

    Figure 10

    Deploy 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 https://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.

    Figure 11

    Create a new hosted service

  3. Configure the new service as follows:
    1. Choose a subscription: Select the name of Azure subscription. (You would have provided this information while signing up for the Azure account.)
    2. Name of the Service: Provide a user friendly name to the service. See the screenshot below for an example.
    3. URL prefix of your service: This is a unique URL. Choose an available URL. See the screenshot below for an example.

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

    4. Region or Affinity group: This is the physical location of the Azure datacenter hosting your service. Choose a region.
    5. 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.

    6. Deployment Name: A user-friendly name to identify the service. See the screenshot below for an example.
    7. Package Location: Select “Browse Locally”, browse to the .cspkg file that you published earlier, and select the file.
    8. Configuration file: Select “Browse Locally”, browse to the .cscfg file that you published earlier, and select the file.
    9. Click OK.

      Figure 12

      Create New Hosted Service dialog

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

    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 13

    Deployment 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.

    Figure 14

    Production 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: https://partsleadtime.cloudapp.net/partservice.svc

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

    Figure 15

    PartService 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=https://<DNS name>.cloudapp.net/partservice.svc binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IPartService" contract="PartsService.IPartService" name="BasicHttpBinding_IPartService" />

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

    Note:
    Error: Note format was corrupted. Title should be bold.different in your environment.

    Figure 16

    Configure 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.

    Figure 17

    Maintenance Requests in the application

  3. Click on one of the maintenance requests in the list to select it.
  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

    Request details