Introduction to Windows Azure Marketplace Datamarket

Total Page:16

File Type:pdf, Size:1020Kb

Introduction to Windows Azure Marketplace Datamarket

1.

Hands-On Lab Introduction to Windows Azure Marketplace DataMarket

Lab version: 1.0.0 Last updated: 5/10/2018

2. 3. Contents 1. Overview

2. In this lab, we will introduce Microsoft Azure Maketplace DataMarket. DataMarket is Microsoft’s Information Service offering which allows developers and information workers to find, acquire and consume published datasets and web services. Users subscribe to datasets and web services of interest and can integrate the information into their own applications via a standardized data services. Data can also be analyzed online using the DataMarket Service Explorer or externally using the PowerPivot Add-In for Excel.

Objectives 1. In this hands-on lab, you will learn how to: Explore the Microsoft Azure Marketplace DataMarket portal and Service Explorer Query a Microsoft Azure Marketplace DataMarket dataset using a URL Access and consume a Microsoft Azure Marketplace DataMarket dataset and Service via Managed Code Use the PowerPivot Add-In for Excel to consume and analyze data from Microsoft Azure Marketplace DataMarket datasets

System Requeriments 1. You must have the following items to complete this lab: Microsoft Visual Studio 2010 Microsoft .NET Framework 4.0 Microsoft Office Excel 2010 PowerPivot

Setup 1. In order to execute this hands-on lab exercises you need to setup this lab. 2. Open a Windows Explorer window and browse to the lab’s root folder. 3. Double-click the Setup.cmd file in this folder to launch the setup process that will configure your environment and install the Visual Studio code snippets for this lab. 4. If the User Account Control dialog is shown, confirm the action to proceed. Using the Code Snippets Throughout the lab document, you will be instructed to insert code blocks. For your convenience, most of that code is provided as Visual Studio Code Snippets, which you can use from within Visual Studio 2010 to avoid having to add it manually. 1. If you are not familiar with the Visual Studio Code Snippets, and want to learn how to use them, you can refer to the Setup.docx document in the Assets folder of the training kit, which contains a section describing how to use them.

Exercises 1. This hands-on lab includes the following exercises:

2. Exploring the Microsoft Azure Marketplace DataMarket portal and Service Explorer 3. Querying Microsoft Azure Marketplace DataMarket Datasets via URL’s 4. Consuming Microsoft Azure Marketplace DataMarket Data and Services via Managed Code 5. Consuming Microsoft Azure Marketplace DataMarket Data via PowerPivot

1. Estimated time to complete this lab: 60 minutes.

2.

3. Note: When you first start Visual Studio, you must select one of the predefined settings collections. Every predefined collection is designed to match a particular development style and determines window layouts, editor behavior, IntelliSense code snippets, and dialog box options. The procedures in this lab describe the actions necessary to accomplish a given task in Visual Studio when using the General Development Settings collection. If you choose a different settings collection for your development environment, there may be differences in these procedures that you need to take into account.

4. Exercise 1: Exploring the Microsoft Azure Marketplace DataMarket portal and Service Explorer

In this exercise, we will sign up to the Microsoft Azure Marketplace DataMarket portal and use the Service Explorer to explore your service details and the DataMarket datasets. Task 1 – Accessing and Signing Up to the Microsoft Azure Marketplace DataMarket Portal 5. In this task you will access the Microsoft Azure Marketplace DataMarket portal and sign up: 6. Navigate to https://datamarket.azure.com/ 7. If you have a Windows Live ID, use it to sign in. If you do not have a Windows Live ID, create one. 8. Once you have signed in, take some time to review the portal. 8.a.

8.b. Figure 1 8.c. Microsoft Azure Marketplace DataMarket portal

8.d. 9. Click Register link.

9.a.

9.b. Figure 2 9.c. Clicking Register

9.d. 10. Enter the requested information in Account Details, review the privacy statement, and select the checkbox to agree with DataMarket privacy policies. Click the Continue button. 10.a.

10.b. Figure 3 10.c. Registering for DataMarket

10.d. 11. Review the User Agreement, and accept it selecting the I accept the Terms of Use checkbox. Click Register button to finish registration. 11.a.

11.b. Figure 4 11.c. Accepting User Agreement

11.d. 12. Once registered you see the My Data page. If not automatically redirected click My Data button on ribbon. 12.a.

12.b. Figure 5 12.c. My Data Page

12.d.

Task 2 – Exploring Your Account Keys In this task, you will explore your account keys and create a new account key. 1. From the DataMarket Portal Home Page, click the My Account link. Alternatively, you can click on My Data tab.

1.a.

1.b. Figure 6 1.c. Clicking My Account

1.d. 2. Click Account Keys on left pane. To create a new account key, click the Add account key link. 1.e.

1.f. Figure 7 1.g. Creating a new account key

1.h. 2. The screen for adding an account key will display. Enter a description for the account key and click the Create button.

2.a.

2.b. Figure 8 2.c. Adding a new Account Key

2.d. 3. You will now see your new account key in the list of available keys. 3.a.

3.b. Figure 9 3.c. Your new account key

1. Task 3 – Exploring the Datasets in the DataMarket and Subscribing to a Dataset In this task, you will explore the DataMarket. The DataMarket allows users to browse and subscribe to available datasets. 1. Click Browse tab. 1.a.

1.b. Figure 10 1.c. Clicking Browse

1.d.

1.e. Note: For each dataset, the DataMarket shows the data provider, a description of the dataset’s content, the type of the content, and provides a link that will allow you to subscribe to the dataset.

1.f. 2. Using Search the MarketPlace, locate the UN DATA dataset called “Gender Info 2007 – United Nations Statistics Division”. Use the key word Gender. 1.g.

1.h. Figure 11 1.i. Searching Dataset

1.j. 2. Click on the dataset and review the information. Click on Sign Up button to subscribe to the dataset.

2.a.

2.b. Figure 12 2.c. Reviewing dataset information

2.d. 3. Review and accept Dataset Terms. Click Sign Up button. 3.a.

3.b. Figure 13 3.c. Signing Up Dataset Subscription

3.d. 3. Review the Receipt.

3.e.

3.f. Figure 14 3.g. Your DataMarket Subscription Receipt

1. Task 4 – Using Service Explorer to Preview a Dataset 2. In this task, you will use the Service Explorer to preview a dataset to which you have subscribed. 1. From the DataMarket Portal, click the My Data tab; you will see a list of your subscribed datasets. 2. Locate the Free subscription for “Gender Info 2007” Dataset and click the title to open subscription. 3. Click Explore This Dataset link.

2.a.

2.b. Figure 15 2.c. Exploring the dataset

2.d. 4. The dataset will open in the Service Explorer.

2.e.

2.f. Figure 16 2.g. Service Explorer

2.h. Note: You can use the Service Explorer to query the dataset, invoke the dataset as an Atom feed, or analyze the dataset using the PowerPivot add-in for Excel 2010. 2.i. 5. Modify or set some of the Optional parameters and click the Run Query button. This will display a preview of the dataset based on the criteria you set.

2.j.

2.k. Figure 17 2.l. Previewing your Dataset

2.m. 6. By default, the preview will display in Table format, however you can click Atom Pub link to preview the dataset in Atom Pub format.

2.n. 2.o. Figure 18 2.p. Preview Formats Exercise 2: Consuming DataMarket Data and Services via Managed Code

1. In this exercise, you will add the service reference to consume DataMarket data. You will create a class to expose the consumed DataMarket data. Task 1 – Adding a Service Reference 2. In this task, we will add the service reference to consume DataMarket data. 1. Log on to the Windows Azure Marketplace DataMarket portal. 2. From the DataMarket Portal, click the My Data tab; you will see a list of your subscribed datasets. 3. Locate the subscription for “Gender Info 2007” Dataset and click the title to open subscription. 4. Click on Explore This Dataset link to open dataset details.

2.a.

2.b. Figure 19 2.c. Exploring the Dataset

2.d. 5. From the dataset explorer page, copy the Service root URL link. 2.e.

2.f. Figure 20 2.g. Copying Service root URL

2.h. 6. Open Microsoft Visual Studio 2010. 7. Open solution called begin.sln located in the Source folder Ex02- ConsumingDataMarketDataAndServicesViaManagedCode\begin\CS. 8. Right click on the ConsumingDataMarketData project and select Add service reference. 9. Paste the URL you copied into the Address textbox. Click on the Go button. Once the service is discovered, add UNData as Namespace. 2.i.

2.j. Figure 21 2.k. Adding Service Reference

2.l.

Task 2 – Consuming Data with Managed Code 1. In this task, you will create a simple class that wraps the dataset queries. 2. Add in ConsumingDataMarketData project, a class called UNGenderData. 2.a.

2.b. Figure 22 2.c. Adding UNGenderData

2.d. 3. Add System.Net and ConsumingDataMarketData.UNData to the using list. 3.a. (Code Snippet – Introduction to DataMarket – Ex2 Adding Using – CS) 3.b. C# 3.c. using System.Net; 3.d. using ConsumingDataMarketData.UNData;

3.e. 4. Add the public access modifier to the class UNGenderData. 5. Add the properties serviceUri and context to your class. 5.a. (Code Snippet – Introduction to DataMarket – Ex2 Adding Properties – CS) 5.b. C# 5.c. private Uri serviceUri; 5.d. private UnitedNationsGenderInfo2007Container context;

5.e. 6. Create the class constructor with the following code inside. 6.a. (Code Snippet – Introduction to DataMarket – Ex2 Create Constructor – CS) 6.b. C# 6.c. public UNGenderData() 6.d. { 6.e. serviceUri = new Uri("{replace-with-dataset-url}"); 6.f. context = new UnitedNationsGenderInfo2007Container(serviceUri); 6.g. context.Credentials = new NetworkCredential("{replace-with-your- user-id}", 6.h. "{replace-with-your-key}"); 6.i. }

6.j. 7. Replace the placeholder in the code with the actual data. To do this, navigate back to the DataMarket portal. 8. Click on the My Data tab. 9. On the left side under My Account, click on Account Keys link. 10. Replace {replace-with-your-user-id} placeholder with the account description you created on Exercise 1. 11. Replace {replace-with-your-key} placeholder with the account key.

11.a.

11.b. Figure 23 11.c. Getting Account Key details

11.d. 12. On the left side under My Account, click on Datasets link. 13. Click on Gender Info … title to view details of the dataset. 14. Click on the Explore this Dataset link. 15. Copy Service root URL link.

15.a.

15.b. Figure 24 15.c. Getting Account Key details

15.d. 16. Replace {replace-with-dataset-url} placeholder with the url you copied. 17. Add the following code to the class. 17.a. (Code Snippet – Introduction to DataMarket – Ex2 GetValues Method – CS) 17.b. C# 17.c. public IList GetValues() 17.d. { 17.e. IEnumerable query; 17.f. query = from value in context.Values 17.g. where value.CountryName == "Argentina" 17.h. select value; 17.i. 17.j. try 17.k. { 17.l. return query.ToList(); 17.m. } 17.n. catch (Exception ex) 17.o. { 17.p. Console.WriteLine("Error: {0}", ex.Message); 17.q. return null; 17.r. } 17.s. } 17.t. Note: The method GetValues() queries the context provided by the DataMarket service. You can add other methods that query using other parameters. To do this you can review the different optional parameters on the dataset service explorer page.

17.u.

17.v. 18. Copy the following code on the Program class Main method. 18.a. (Code Snippet – Introduction to DataMarket – Ex2 Main Method – CS) 18.b. C# 18.c. UNGenderData data = new UNGenderData(); 18.d. 18.e. foreach (var value in data.GetValues()) 18.f. { 18.g. Console.WriteLine(string.Format("Country {0} year {1} {2} value {3}", value.CountryName, value.Year, value.SubGroupName, value.Value)); 18.h. } 18.i. 18.j. Console.ReadKey();

18.k. 19. Run the application by pressing the F5 key. A Console window will open and a tabular view of the data returned by our query will be displayed. Press the Enter key to close the Console window.

19.a.

19.b. Figure 25 19.c. Console running

1. Exercise 3: Consuming DataMarket Data via PowerPivot

2. In this exercise, you will use the Excel Add-In PowerPivot to consume and analyze data from DataMarket datasets. Task 1 – Importing Data From a DataMarket Dataset Into PowerPivot 3. In this task, you will import data from a DataMarket dataset into PowerPivot. 4. Navigate to https://datamarket.azure.com/. 5. Locate the UN data dataset “UNESCO UIS Data”. 6. Click on title to view detail information. 7. Click Sign Up button to subscribe.

7.a. 7.b.

7.c. Figure 26 7.d. UNESCO UIS Data Dataset

7.e. 8. Agree and confirm subscription. To do this, check the checkbox and click on Sign Up button. 9. Click on the Explore This Dataset link. 10. Select Values on Query dropdown box. Complete with optional parameters. To narrow the query you can write 2000 on the TimePeriod textbox. Select PowerPivot and click Open button. 10.a.

10.b. Figure 27 10.c. UNESCO UIS Data Dataset service explorer

10.d. 11. Click on the Open button. 11.a. 11.b. Figure 28 11.c. Opening the atom feed

11.d. 12. If prompted, select and click Ok button, when prompted by PowerPivot.

12.a. 12.b. Figure 29 12.c. Selecting the workbook 12.d. 13. Microsoft Excel will launch and the PowerPivot Table Import Wizard dialog will display. On the Table Import Wizard, complete with a Friendly connection name and copy your account key into the Account Key textbox. To do this, see exercise 2 task 2. Optionally, check Save my account key. Click Next button.

13.a.

13.b. Figure 30 13.c. Excel Table Import Wizard

13.d. 14. Click Finish button to start importing information. 14.a.

14.b. Figure 31 14.c. Importing dataset data

14.d. 15. The wizard will import data from the dataset, when finished click on the Close button. The imported data will be displayed in PowerPivot. Keep the PowerPivot window open to do the next tasks.

15.a. Note: The import operation may take several minutes to complete.

15.b. 15.c.

15.d. Figure 32 15.e. Dataset imported into PowerPivot

Task 2 – Importing Data From an External Data Source Into PowerPivot 1. In this task, you will import data from an existing Excel spreadsheet into PowerPivot. 1. From the PowerPivot window, click the From Other Sources toolbar item. 1.a.

1.b. Figure 33 1.c. From Other Sources option on PowerPivot toolbar

1.d. 2. On the Table Import Wizard, scroll down and select Excel File and click Next. Click the Browse button. Browse to Ex03-ConsumingDataMarketDataViaPowerPivot\ in the Source folder of this lab, select the RegionOrArea.xlsx file, and select the Use first row as column headers option. Click Next to select the tables, which will be imported. Make sure that the RegionOrArea$ source table is checked. Click Finish to import the file into PowerPivot. Finally click Close.

1.e. 1.f. Figure 34 1.g. The Excel spreadsheet imported into PowerPivot

Task 3 – Creating a Relationship in PowerPivot 1. In this task, you will create a relationship between the two sets of data we have imported into PowerPivot. 2. From the PowerPivot toolbar, click the Design tab. 2.a. 2.b. Figure 35 2.c. Design tab on the PowerPivot toolbar

2.d. 3. From the PowerPivot Design toolbar, click the Create Relationship button.

3.a. 3.b. Figure 36 3.c. Create Relationship button on the PowerPivot Design toolbar

3.d. 4. Set the following criteria on the Create Relationship dialog box: Table: RegionOrArea Column: RegionOrAreaCode Related Lookup Table: UNESCO UIS Data…. Related Lookup Column: ReferenceAreaCode

4.a. 4.b. Figure 37 4.c. Create Relationship dialog window

4.d. 5. Click the Create button. This will create a relationship between the two PowerPivot tables.

Task 4 – Creating a Simple Pivot Table With Your Data 1. In this task, you will use PowerPivot to create a simple Pivot Table using the data imported in the previous tasks. 2. Click the Home tab on the PowerPivot toolbar.

2.a. 2.b. Figure 38 2.c. Home tab on PowerPivot toolbar

2.d. 3. Click the PivotTable button on the PowerPivot toolbar, choose the PivotTable option.

3.a. 3.b. Figure 39 3.c. PivotTable button on the PowerPivot toolbar

3.d. 4. On the Create PivotTable dialog box, choose the Existing Worksheet radio button and click the OK button, an empty Pivot Table will be displayed. 4.a.

4.b. Figure 40 4.c. The empty Pivot Table

4.d. 5. Set up the initial Pivot Table rows and columns as follows: 5.a. Drag the RegionOrArea field to the Row Labels list. 5.b.Drag the Sex field to the Row Labels list. 5.c. Drag the TimePeriod field to the Column Labels list. 5.c.i.

5.c.ii. Figure 41 5.c.iii. Initial Pivot Table

5.c.iv. 6. Click the checkbox next to the ObservationValue field, this will populate the Pivot Table. 6.a.

6.b. Figure 42 6.c. Populated Pivot Table

6.d. 7. Right-click the Continent field and choose the Add to Slicers Vertical option. This will add a vertical slicing option to the Pivot Table. 7.a.

7.b. Figure 43 7.c. Pivot Table with Vertical Slicer added

7.d. 8. You can now slice your data based on the Continent that the data applies.

Summary

In this lab, we explored Microsoft Azure Marketplace DataMarket and how to subscribe, access and analyze the published datasets.

Recommended publications