Exercise 1: Testing your Azure development environment

In this exercise, you will deploy a sample Azure WCF service and then use a simple test client to access the WCF Service to create sample data and verify that your environment is setup correctly.

Task 1 – Deploying the SaleObservationService Sample

In this task, you will review the SaleObservationService solution files and then build/deploy the project to Azure’s Development Fabric.

  1. If you have not already, setup the Azure development tools on your computer.
    1. Download & install the Windows Azure Tools for Visual Studio 1.4 .
    2. Setup Development Storage for local development

      Note:
      Development Storage is a utility that simulates the Blob, Queue, and Table Services available on Windows Azure. By default, development storage is configured for SQL Server Express 2005 or 2008. You can also configure it to use a local instance of SQL Server using the dsInit tool. For more information see the following resources:

      Windows Azure Tools for Visual Studio 1.4

      Windows Azure Storage Emulator

  2. Review the sample Azure WCF service project
    1. Open Visual Studio 2010 (run as administrator)
    2. Open C:\Student\Azure\SaleObservationService\SaleObservationService.sln
    3. Double-click on the file named SaleObservationService.src in the Solution Explorer to view the code for this file. Observe there are four public methods:
      1. LoadData – The purpose of this method is to create a table for storing sale observation data and then populating it with data contained in the SaleObservations.xml file that is bundled with the project.
      2. CategorySales – This function returns the total sales for a given category.
      3. ProductSales – This function returns the total sales for a given product.
      4. GetSaleObservation –This function returns a SaleObservation object given a sale observation ID.
    4. Observe the three classes for accessing Azure’s table storage service
      1. SaleObservation.cs – This is a class for modeling the data structure of an individual sale observation. It extends TableServiceEntity, an Azure class, to include a class attribute required by the Azure Table service along with two class additional class properties – PartitionKey and RowKey.
      2. SaleObservationDataContext.cs – This is a class for representing the runtime context of a data service.
      3. SaleObservationDataSource.cs – This class handles the details of connecting to the Azure table service and implements methods on the sales observation records.
  3. Run the sample Azure WCF service project. The project is configured to use Azure’s Development Fabric and Development Storage. This allows you to test and develop Azure solutions locally before you deploy them to Azure.
    1. Right-click on SaleObservationService.svc in the Solution Explorer and choose Set as Start Page
    2. Press F5 to begin debugging the project. If everything is setup correctly, you should see a page similar to the screenshot below.

      Figure 1

      SaleObservation Service

    3. Take note of the URL of the SaleObservationService as you will need to know this in later steps.

Task 2 – Testing the SaleObservationService Sample with a Simple Test Client

In task 2, you will use a basic test client application to call methods exposed by the SaleObservationService.

  1. Without closing the browser window containing the SaleObservationService service page, open another instance of Visual Studio (run as administrator).
  2. Open the C:\Student\Azure\SaleObservationTestClient \SaleObservationServiceTestClient.sln
  3. In the Solution Explorer, double-click on app.config
  4. Verify that the endpoint address in the configuration file matches the endpoint of your service (as noted above in Task 1, step 3, item c).

    Figure 2

    Endpoint Address

  5. Press F5 to debug the test client
  6. Click the button Load Data. The SaleObservationService exposes a method to create a table using the Azure Table Storage service and populate it with sample sales data. The test client merely calls this method when you click Load Data. After a brief moment, the test client should indicate that 58 items were loaded.

    Figure 3

    Test Sale Observation Client Dialog

  7. Enter Beverages in the Total by Category text box
  8. Click Total. When you click Total, the test client calls the CategorySales function exposed by the SaleObservationService.

    Figure 4

    CategorySales function result

  9. Enter Northwind Traders Beer in the Total by Product text box
  10. Click Total. When you click Total, the test client calls the ProductSales function exposed by the SaleObservationService.

    Figure 5

    ProductSales function result

  11. Close the test client
  12. Close the SaleObservationServiceTestClient solution in Visual Studio.

Exercise 1 Verification

If you completed steps 6-10 in task 2 above, you have verified that the SaleObservationService is running in the Azure Development Fabric and that your Azure Development Storage is working correctly. Another way to verify the existence of objects within Azure storage is to use Visual Studio. To do this, perform the following steps.

  1. In Visual Studio, select ViewServer Explorer
  2. Expand the Windows Azure Storage node and click through to Windows Azure Storage(Development)TablesSaleObservation
  3. Double-click on SaleObservation to see a read-only view of the items in the table.

    Figure 6

    Read-only view of the items