az12722.vo.msecnd.netaz12722.vo.msecnd.net/.../labs/hpcsoaservices1-0/Lab.docx · Web viewAuthor:...

33
Hands-On Lab Running SOA Services with the Windows Azure HPC Scheduler Lab version: 2.0.0 Last updated: 5/18/2022

Transcript of az12722.vo.msecnd.netaz12722.vo.msecnd.net/.../labs/hpcsoaservices1-0/Lab.docx · Web viewAuthor:...

Page 1: az12722.vo.msecnd.netaz12722.vo.msecnd.net/.../labs/hpcsoaservices1-0/Lab.docx · Web viewAuthor: wwegner : Created Date: 11/17/2011 05:52:00 : Title: Running SOA Services with the

Hands-On LabRunning SOA Services with the Windows Azure HPC Scheduler

Lab version: 2.0.0

Last updated: 5/25/2023

Page 2: az12722.vo.msecnd.netaz12722.vo.msecnd.net/.../labs/hpcsoaservices1-0/Lab.docx · Web viewAuthor: wwegner : Created Date: 11/17/2011 05:52:00 : Title: Running SOA Services with the

CONTENTS

OVERVIEW................................................................................................................................................. 3

EXERCISE 1: CREATING, DEPLOYING, AND SUBMITING A SOA-BASED HPC APPLICATION IN WINDOWS AZURE..................................................................................................................................... 4

Task 1 - Create the Square Service and Configure it to Run in an HPC Environment...........................4

Task 2 - Create a Client That Uses Interactive Sessions with WCF Service Reference..........................8

Task 3 - Create a Client That Uses Interactive Sessions with the BrokerClient<T> Class....................13

Task 4 - Deploy the WCF Service to Windows Azure Nodes..............................................................17

Task 5 - Run the Client Application in the Windows Azure Head Node.............................................25

Verification........................................................................................................................................27

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

Page 3: az12722.vo.msecnd.netaz12722.vo.msecnd.net/.../labs/hpcsoaservices1-0/Lab.docx · Web viewAuthor: wwegner : Created Date: 11/17/2011 05:52:00 : Title: Running SOA Services with the

Overview

The HPC Square service demonstrates how to build, deploy, and execute an HPC SOA application that can run in Windows Azure. This sample includes a WCF service project and a client application that consumes it.

The client application demonstrates how to use the interactive session with both a service reference generated proxy and the BrokerClient class.

To run the client and service completely in Windows Azure, you will use the Windows Azure HPC Scheduler SDK. The SDK enables developers to create Windows Azure deployments that include parallel applications that can scale when more computation power is needed. It supports not only SOA applications, but also MPI and LINQ to HPC applications.

To manage HPC jobs, create new jobs, check currently executing jobs, and view the results of finished jobs, the Windows Azure HPC Scheduler SDK also includes a web-based portal that you can access from your local machine through a web-browser.

Note: Although this solution is for Visual Studio 2010, the AzureSquareService project uses .NET Framework 3.5; this is because the Windows Azure HPC Scheduler cannot currently host WCF services compiled for .NET Framework 4.

In this lab, you will deploy applications to Windows Azure and use the Windows Azure Management Portal. To learn more about deploying applications to Windows Azure and using the portal, refer to the Windows Azure Training Course on MSDN and run the first lab in the course, Introduction to Windows Azure.

Objectives

In this hands-on lab, you will learn how to:

Create a WCF service and configure it to run in an HPC cluster.

Create a WCF client application that calls the HPC SOA application using a service reference generated proxy and the BrokerClient<T> generic class.

Deploy the Windows Azure HPC Scheduler.

Deploy the WCF service and client application to a Windows Azure head node and compute nodes.

Run the WCF client application from a head node.

Use the Windows Azure HPC Scheduler Web Portal to check the status of jobs and tasks.

Page 4: az12722.vo.msecnd.netaz12722.vo.msecnd.net/.../labs/hpcsoaservices1-0/Lab.docx · Web viewAuthor: wwegner : Created Date: 11/17/2011 05:52:00 : Title: Running SOA Services with the

Prerequisites

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

Visual Studio 2010 Professional or higher with (Visual C# and Visual C++)

Windows Azure Tools for Microsoft Visual Studio 2010 1.6

Windows Azure HPC Scheduler SDK

HPC Pack 2008 R2 Client Utilities Redistributable Package with Service Pack 3

Exercises

This hands-on lab includes the following exercise:

1. Creating, deploying, and submitting a SOA-based HPC application in Windows Azure.

Estimated time to complete this lab: 60 minutes.

Exercise 1: Creating, deploying, and submiting a SOA-based HPC application in Windows Azure

In this exercise, you will create a WCF service that will be hosted with the Windows Azure HPC Scheduler, a client application that submits SOA jobs to the scheduler, and then deploy the scheduler and the applications to Windows Azure. After the scheduler and the applications are deployed, you will run the client application, and use the Windows Azure HPC Scheduler web portal to verify its execution.

Task 1 - Create the Square Service and Configure it to Run in an HPC Environment

One of the benefits of running WCF services with the Windows Azure HPC Scheduler is that, in most cases, no changes need to be made to the service code. However, because of the environment transition, you will be required to generate a special configuration file that includes information about the service to be hosted.

1. Open Microsoft Visual Studio 2010 elevated as Administrator from Start | All Programs | Microsoft Visual Studio 2010 by right-clicking Microsoft Visual Studio 2010 and choosing Run as administrator.

2. Open the begin.sln solution file located in the Source\Ex01-SoaService\begin folder.

Page 5: az12722.vo.msecnd.netaz12722.vo.msecnd.net/.../labs/hpcsoaservices1-0/Lab.docx · Web viewAuthor: wwegner : Created Date: 11/17/2011 05:52:00 : Title: Running SOA Services with the

3. In the Solution Explorer window, expand the SquareService solution folder, and then expand the AzureSquareService project node.

Figure 1The AzureSquareService project

4. Right-click the AzureSquareService project and select Add | New Item.

5. In the Add New Item dialog, select WCF Service from the Visual C# Items list, name the file SquareService.cs, and then click Add.

Figure 2

Page 6: az12722.vo.msecnd.netaz12722.vo.msecnd.net/.../labs/hpcsoaservices1-0/Lab.docx · Web viewAuthor: wwegner : Created Date: 11/17/2011 05:52:00 : Title: Running SOA Services with the

Add a new WCF service item

6. Open the ISquareService.cs file, and remove the DoWork method declaration and the decorating OperationContract attribute. The interface should resemble the following code:

C#

[ServiceContract]public interface ISquareService{}

7. Add the Square method declaration to the ISquareService interface:

(Code Snippet – SOA Services - ISquareService - Square Method Declaration– CS)

C#

[ServiceContract]public interface ISquareService{ [OperationContract] int Square(int num);}

8. Open the SquareService.cs file, and remove the DoWork method implementation. The service’s code should resemble the following code:

C#

public class SquareService : ISquareService{}

9. The default concurrency mode of WCF is single threading, which results in the synchronization of all requests sent from a single client. To enable the service to handle multiple client requests at once, the concurrency mode of the service must be changed to multithreading by decorating the service class with the ServiceBehavior attribute and setting the ConcurrencyMode to Multiple, as shown in the following code:

(Code Snippet – SOA Services - SquareService - Add ServiceBehavior – CS)

C#

[ServiceBehavior(ConcurrencyMode = ConcurrencyMode.Multiple)]public class SquareService : ISquareService{}

Page 7: az12722.vo.msecnd.netaz12722.vo.msecnd.net/.../labs/hpcsoaservices1-0/Lab.docx · Web viewAuthor: wwegner : Created Date: 11/17/2011 05:52:00 : Title: Running SOA Services with the

10. Add the Square method implementation to the SquareService class:

(Code Snippet – SOA Services - SquareService - Square Method Declaration– CS)

C#

[ServiceBehavior(ConcurrencyMode = ConcurrencyMode.Multiple)]public class SquareService : ISquareService{ public int Square(int num) { Console.WriteLine("calculating square of :" + num); return num * num; }}

11. Note the Console.WriteLine method call. This call will output a message, which you will be able to see in the task results window in the Windows Azure HPC Scheduler Web Portal.

12. Right-click the AzureSquareService project and select Add | Existing Item

13. In the Add Existing Item dialog, browse to Source\Assets, change the file type to All Files (*.*), select the SquareService.config file, and click Add.

14. In the AzureSquareService project, right-click the SquareService.config file and select Properties.

15. In the Properties window, change Build Action to Content, and Copy to Output Directory to Copy always.

Figure 3SquareService.config file properties

Page 8: az12722.vo.msecnd.netaz12722.vo.msecnd.net/.../labs/hpcsoaservices1-0/Lab.docx · Web viewAuthor: wwegner : Created Date: 11/17/2011 05:52:00 : Title: Running SOA Services with the

16. Open the SquareService.config file, and examine the contents of the file. The service configuration file allows you to set how the HPC service host locates your service and hosts it. It also includes information on how to expose the service through the WCF broker node.

17. In the SquareService.config file, look for the <microsoft.Hpc.Session.ServiceRegistration> XML element:

XML

<microsoft.Hpc.Session.ServiceRegistration><service assembly="AzureSquareService.dll" contract="AzureSquareService.ISquareService" type="AzureSquareService.SquareService" includeExceptionDetailInFaults="true" maxConcurrentCalls="0" maxMessageSize="65536" serviceInitializationTimeout="60000" enableMessageLevelPreemption="true" ></service></microsoft.Hpc.Session.ServiceRegistration>

18. The following attributes are required to configure how the service is hosted:

a. assembly. Defines the location of the service’s assembly file, which should contain both the service contract and the service implementation.

b. contract. Defines the fully qualified name of the service contract.

c. type. Defines the fully qualified name of the service’s implementation class.

Note: If you have named your WCF service something other than SquareService, change the contract and type attributes accordingly.

19. Inside the SquareService.config file, locate the <brokerServiceAddresses> XML element under the <microsoft.Hpc.Broker> | <services> element. Each of the <add> XML elements defines a base address that the WCF broker node uses to listen for client service requests.

20. Inside the SquareService.config file, locate the <system.serviceModel> XML element and inspect the contents of that element. This XML element contains the configuration for the broker service’s diagnostic tracing as well as the binding configuration for the endpoints exposed by the broker service.

21. Save the changes made to the ISquareService.cs and SquareService.cs files.

Task 2 - Create a Client That Uses Interactive Sessions with WCF Service Reference

In this task, you will add the client code that creates an interactive session. Interactive sessions are service jobs that host WCF services in the Windows Azure HPC cluster and allow interaction with the

Page 9: az12722.vo.msecnd.netaz12722.vo.msecnd.net/.../labs/hpcsoaservices1-0/Lab.docx · Web viewAuthor: wwegner : Created Date: 11/17/2011 05:52:00 : Title: Running SOA Services with the

services through the WCF broker node, which routes requests and responses from the client to the cluster and back. This task uses a WCF service reference to call the hosted WCF service.

1. In the Solution Explorer window, expand the SquareService solution folder and then expand the Client project node.

Figure 4The Client project

2. Right-click the Client project and select Add Reference.

3. In the Add Reference dialog, move to the .NET tab and add a reference to the Microsoft.HPC.Scheduler and Microsoft.HPC.Scheduler.Session assemblies. These assemblies enable the client application to submit SOA jobs to the head node and send requests to the Windows Azure HPC cluster.

Note: In case the assemblies are not added in the .NET tab, switch to Browse tab and browse to %windows%\Assembly\GAC_MSIL folder (usually, you will find Windows folder in C:\Windows). Locate the folders named Microsoft.HPC.Scheduler and Microsoft.HPC.Scheduler.Session and add the reference to the assemblies.

4. Verify the added referenced assemblies.

Page 10: az12722.vo.msecnd.netaz12722.vo.msecnd.net/.../labs/hpcsoaservices1-0/Lab.docx · Web viewAuthor: wwegner : Created Date: 11/17/2011 05:52:00 : Title: Running SOA Services with the

Figure 5Verify the added referenced assemblies

5. Open the Program.cs file, and examine the three static variables:

C#

private static int numOfRequests = 20;private static string headNode = Environment.GetEnvironmentVariable("CCP_SCHEDULER");private static string serviceName = "SquareService";

Note: These three variables contain the information required to submit the SOA job:

The numOfRequests static variable controls how many square calculation requests will be submitted to the server. You can increase the number of requests if you wish, but be aware that the more requests you set, the more time it will take the cluster to calculate them.

The headNode static variable holds the name of the HPC head node to which the client submits the SOA job. The variable is set according to the CCP_SCHEDULER environment variable that exists in all Windows Azure HPC nodes, including the head node, compute nodes, and frontend node.

The serviceName static variable holds the name of the hosted SOA service that will start when the job begins running. The name of the service must match the name of the service configuration file created in the previous task.

6. Add the following namespace directive at the beginning of the Program.cs file:

Page 11: az12722.vo.msecnd.netaz12722.vo.msecnd.net/.../labs/hpcsoaservices1-0/Lab.docx · Web viewAuthor: wwegner : Created Date: 11/17/2011 05:52:00 : Title: Running SOA Services with the

(Code Snippet – SOA Services -Program - Adding Namespace directive– CS)

C#

using Microsoft.Hpc.Scheduler.Session;

7. Add the following method code to the Program class:

(Code Snippet – SOA Services -Program - InteractiveUsingServiceReference Method– CS)

C#

private static void InteractiveUsingServiceReference(){ SessionStartInfo info = new SessionStartInfo(headNode, serviceName);

using (Session session = Session.CreateSession(info)) { }}

8. The method creates a new session object using the Microsoft.HPC.Scheduler.Session.Session class. The Session class is responsible for creating a new job with a service task in the Windows Azure HPC Scheduler. Once the session starts, the client application can send service requests to the WCF broker.

Note: You can also set other properties of the SessionStartInfo object to configure how the job executes. For instance, you can set the SessionResourceUnitType property to SessionUnitType.Cores and then set the MinimumUnits and MaximumUnits to define how many cores will be available for each hosted service.

9. Add the following WCF code inside the using statement to send requests to the WCF service using a service reference generated proxy:

(Code Snippet – SOA Services - Program - InteractiveUsingServiceReference WCF code– CS)

C#

private static void InteractiveUsingServiceReference(){ SessionStartInfo info = new SessionStartInfo(headNode, serviceName);

using (Session session = Session.CreateSession(info)) { AutoResetEvent done = new AutoResetEvent(false); int count = 0; Console.WriteLine("Session ID: " + session.Id);

Page 12: az12722.vo.msecnd.netaz12722.vo.msecnd.net/.../labs/hpcsoaservices1-0/Lab.docx · Web viewAuthor: wwegner : Created Date: 11/17/2011 05:52:00 : Title: Running SOA Services with the

SquareServiceClient proxy = new SquareServiceClient( new NetTcpBinding(SecurityMode.Transport), session.NetTcpEndpointReference);

proxy.SquareCompleted += (sender, e) => { try { int reply = e.Result.SquareResult; Console.WriteLine("Received response for request {0}: {1}", e.UserState, reply); } catch (SessionException ex) { Console.WriteLine("SessionException while getting responses in callback: {0}", ex.Message); } catch (Exception ex) { Console.WriteLine("Exception while getting responses in callback: {0}", ex.Message); }

if (Interlocked.Increment(ref count) == numOfRequests) { done.Set(); } };

// start to send requests Console.WriteLine("Sending {0} requests using Service Reference proxy...", numOfRequests); for (int i = 0; i < numOfRequests; i++) { proxy.SquareAsync(new SquareRequest(1000 + i), i); }

// Main thread block here waiting for the retrieval process // to complete. As the thread that receives the "_numOfRequests" // responses does a Set() on the event, "done.WaitOne()" will pop done.WaitOne();

Console.WriteLine("Done retrieving {0} responses\n", numOfRequests);

// Close connections and delete messages stored in the system session.Close(); }}

Page 13: az12722.vo.msecnd.netaz12722.vo.msecnd.net/.../labs/hpcsoaservices1-0/Lab.docx · Web viewAuthor: wwegner : Created Date: 11/17/2011 05:52:00 : Title: Running SOA Services with the

Note: The above method code uses the service reference class created for the square service to call the service asynchronously and print out the responses returned by the service. The session closes once the last response returns to the client.

You cannot use bindings other than the NetTcp binding to communicate with the WCF service broker.

10. Add the following method call to the Main method:

(Code Snippet – SOA Services - Program - Call InteractiveUsingServiceReference – CS)

C#

public static void Main(string[] args){ InteractiveUsingServiceReference();

Console.WriteLine("Press enter to exit."); Console.Read();}

11. Save the Program.cs file.

Task 3 - Create a Client That Uses Interactive Sessions with the BrokerClient<T> Class

In this task, you will create a method similar to that of Task 2, only this time instead of using the generated WCF service reference you will use the BrokerClient<T> generic class.

1. In the Client project, open the Program.cs file and add the following method to the Program class:

(Code Snippet – SOA Services - Program - InteractiveUsingBrokerClient Method – CS)

C#

private static void InteractiveUsingBrokerClient(){ SessionStartInfo info = new SessionStartInfo(headNode, serviceName);

using (Session session = Session.CreateSession(info)) { int count = 0; AutoResetEvent done = new AutoResetEvent(false);

Console.WriteLine("Session ID: " + session.Id);

Page 14: az12722.vo.msecnd.netaz12722.vo.msecnd.net/.../labs/hpcsoaservices1-0/Lab.docx · Web viewAuthor: wwegner : Created Date: 11/17/2011 05:52:00 : Title: Running SOA Services with the

Console.WriteLine("Done retrieving {0} responses\n", numOfRequests);

// Close connections and delete messages stored in the system session.Close(); }}

2. Like the method in the previous task, this method also starts a new session, but this time the new method sends service requests to the WCF broker using the BrokerClient<T> generic class. To create the BrokerClient instance, add the following code inside the using statement, between the two Console.WriteLine methods:

(Code Snippet – SOA Services - Program - BrokerClient Instance – CS)

C#

private static void InteractiveUsingBrokerClient(){ SessionStartInfo info = new SessionStartInfo(headNode, serviceName);

using (Session session = Session.CreateSession(info)) { int count = 0; AutoResetEvent done = new AutoResetEvent(false);

Console.WriteLine("Session ID: " + session.Id); using (BrokerClient<ISquareService> client = new BrokerClient<ISquareService>(session)) { }

Console.WriteLine("Done retrieving {0} responses\n", numOfRequests);

// Close connections and delete messages stored in the system session.Close(); }}

Note: The generic argument T of the BrokerClient<T> class is the service’s contract type.

3. To handle the responses, the method calls the BrokerClient<T>.SetResponseHandler<TMessage> generic method with a callback method parameter. The TMessage generic argument is the type of the message class, representing the

Page 15: az12722.vo.msecnd.netaz12722.vo.msecnd.net/.../labs/hpcsoaservices1-0/Lab.docx · Web viewAuthor: wwegner : Created Date: 11/17/2011 05:52:00 : Title: Running SOA Services with the

response type of the called service operation. Add the following code inside the second using statement.

(Code Snippet – SOA Services - Program - Response Handler – CS)

C#

private static void InteractiveUsingBrokerClient(){ SessionStartInfo info = new SessionStartInfo(headNode, serviceName);

using (Session session = Session.CreateSession(info)) { int count = 0; AutoResetEvent done = new AutoResetEvent(false);

Console.WriteLine("Session ID: " + session.Id); using (BrokerClient<ISquareService> client = new BrokerClient<ISquareService>(session)) { // Set the response handler client.SetResponseHandler<SquareResponse>((response) => { try { int reply = response.Result.SquareResult; Console.WriteLine("Received response for request {0}: {1}", response.GetUserData<int>(), reply); } catch (SessionException ex) { Console.WriteLine("SessionException while getting responses in callback: {0}", ex.Message); } catch (Exception ex) { Console.WriteLine("Exception while getting responses in callback: {0}", ex.Message); }

if (Interlocked.Increment(ref count) == numOfRequests) { done.Set(); } }); }

Console.WriteLine("Done retrieving {0} responses\n", numOfRequests);

Page 16: az12722.vo.msecnd.netaz12722.vo.msecnd.net/.../labs/hpcsoaservices1-0/Lab.docx · Web viewAuthor: wwegner : Created Date: 11/17/2011 05:52:00 : Title: Running SOA Services with the

// Close connections and delete messages stored in the system session.Close(); }}

Note: The message classes were created with the Add Service Reference tool in Visual Studio 2010, by checking the Always generate message contract checkbox in the Service Reference Settings window (accessible by clicking the Advanced… button in the Add Service Reference window).

4. To send a request to the service, call the BrokerClient<T>.SendRequest<TMessage> generic method, where TMessage is the type of the message class containing the parameters required by the service operation. Complete the method by adding the following code after the SetResponseHandler method:

(Code Snippet – SOA Services - Program - Send Requests- CS)

C#

private static void InteractiveUsingBrokerClient(){ SessionStartInfo info = new SessionStartInfo(headNode, serviceName);

using (Session session = Session.CreateSession(info)) { int count = 0; AutoResetEvent done = new AutoResetEvent(false);

Console.WriteLine("Session ID: " + session.Id); using (BrokerClient<ISquareService> client = new BrokerClient<ISquareService>(session)) { // Set the response handler client.SetResponseHandler<SquareResponse>((response) => { try { int reply = response.Result.SquareResult; Console.WriteLine("Received response for request {0}: {1}", response.GetUserData<int>(), reply); } catch (SessionException ex) { Console.WriteLine("SessionException while getting responses in callback: {0}", ex.Message); }

Page 17: az12722.vo.msecnd.netaz12722.vo.msecnd.net/.../labs/hpcsoaservices1-0/Lab.docx · Web viewAuthor: wwegner : Created Date: 11/17/2011 05:52:00 : Title: Running SOA Services with the

catch (Exception ex) { Console.WriteLine("Exception while getting responses in callback: {0}", ex.Message); }

if (Interlocked.Increment(ref count) == numOfRequests) { done.Set(); } });

// start to send requests Console.WriteLine("Sending {0} requests using BrokerClient...", numOfRequests); for (int i = 0; i < numOfRequests; i++) { client.SendRequest<SquareRequest>(new SquareRequest(1000 + i), i); }

client.EndRequests();

// Main thread block here waiting for the retrieval process // to complete. As the thread that receives the "_numOfRequests" // responses does a Set() on the event, "done.WaitOne()" will pop done.WaitOne(); }

Console.WriteLine("Done retrieving {0} responses\n", numOfRequests);

// Close connections and delete messages stored in the system session.Close(); }}

5. Add a method call for the InteractiveUsingBrokerClient method to the Main method:

(Code Snippet – SOA Services - Program - Call InteractiveUsingBrokerClient Method - CS)

C#

public static void Main(string[] args){ InteractiveUsingBrokerClient();

Page 18: az12722.vo.msecnd.netaz12722.vo.msecnd.net/.../labs/hpcsoaservices1-0/Lab.docx · Web viewAuthor: wwegner : Created Date: 11/17/2011 05:52:00 : Title: Running SOA Services with the

InteractiveUsingServiceReference();

Console.WriteLine("Press enter to exit."); Console.Read();}

6. Save the Program.cs file.

Task 4 - Deploy the WCF Service to Windows Azure Nodes

Deploying the Windows Azure HPC Scheduler is a task that involves the creation of many Windows Azure components: a hosted service, an Azure storage account, a SQL Azure server and database instance, and a set of worker roles for the head node, compute nodes, and frontend node. All of these steps are performed for you by the AppConfigure application; all you need to do is provide it with the information it requires, such as your subscription ID and usernames and passwords for the database and the hosted services.

You can read more about the deployment tool in the Getting Started with Application Deployment with the Windows Azure HPC Scheduler article on MSDN.

If you have an HPC application that you want to run using the Windows Azure HPC Scheduler, you will also need to upload them to the head node and compute nodes. One way to do this, demonstrated in this task, is to include the executable and assembly files in one of the roles - either the head node role or the compute node role.

1. In the Solution Explorer window, expand the AzureServices solution folder, and then expand the HeadNode project node.

Figure 6

Page 19: az12722.vo.msecnd.netaz12722.vo.msecnd.net/.../labs/hpcsoaservices1-0/Lab.docx · Web viewAuthor: wwegner : Created Date: 11/17/2011 05:52:00 : Title: Running SOA Services with the

The HeadNode project

2. Right-click the HeadNode project, and select Add Reference.

3. In the Add Reference dialog, select the Project tab, and add the Client and AzureSquareService projects.

4. Verify the added referenced assemblies.

Figure 7Verify the added referenced assemblies

5. In the Solution Explorer window, expand the Deployment solution folder, right-click the AppConfigure project, and select Set as StartUp Project.

6. Build the solution and start it without debugging (Ctrl+F5). After a couple of seconds, you should see the deployment application.

Page 20: az12722.vo.msecnd.netaz12722.vo.msecnd.net/.../labs/hpcsoaservices1-0/Lab.docx · Web viewAuthor: wwegner : Created Date: 11/17/2011 05:52:00 : Title: Running SOA Services with the

Figure 8The Windows Azure HPC Scheduler deployment application

7. In the Subscription ID field, type the subscription ID of your Windows Azure account. You can find the subscription ID in the Management Portal.

Page 21: az12722.vo.msecnd.netaz12722.vo.msecnd.net/.../labs/hpcsoaservices1-0/Lab.docx · Web viewAuthor: wwegner : Created Date: 11/17/2011 05:52:00 : Title: Running SOA Services with the

Figure 9Locating the subscription ID of a Windows Azure subscription

8. If you already have a management certificate installed on your machine, click Browse and select it. If you do not have a management certificate, click the Create button. If you have selected an existing certificate, skip to Step 11.

Note: If you choose to use an existing certificate, and that certificate is not properly installed in the Windows Azure subscription, you might get error messages about failed SSL/TLS connections. If you see these kinds of errors, try creating a new management certificate and adding it to your subscription.

9. If you have chosen to create a new management certificate, a new certificate will be created and installed on your machine; this procedure may cause a Security Warning dialog box to appear. If the warning appears, click Yes.

Page 22: az12722.vo.msecnd.netaz12722.vo.msecnd.net/.../labs/hpcsoaservices1-0/Lab.docx · Web viewAuthor: wwegner : Created Date: 11/17/2011 05:52:00 : Title: Running SOA Services with the

Figure 10The Security Warning dialog box

10. After the management certificate is created, follow the instructions for adding the new management certificate in the How to Add a Management Certificate to a Windows Azure Subscription article on MSDN. You can find the location of the certificate (.cer) file in the bin\debug folder of the AppConfigure application; a message box will appear specifying the exact path of the certificate.

11. Continue filling in the information as follows:

a. Service Name - the name of your hosted service, which will also become the DNS name. This will also be the name of your HPC cluster, which is used to set the CCP_SCHEDULER environment variable.

b. Location - the region of the Windows Azure storage account, hosted service, and SQL Azure server to be used. If any of these do no currently exist in that region, new ones will be created.

Page 23: az12722.vo.msecnd.netaz12722.vo.msecnd.net/.../labs/hpcsoaservices1-0/Lab.docx · Web viewAuthor: wwegner : Created Date: 11/17/2011 05:52:00 : Title: Running SOA Services with the

c. Administrator’s Name - the name of the scheduler and SQL Azure server administrator. This username will also be the administrator’s name when you remotely connect to the Windows Azure instances.

d. Administrator’s Password - the password for the administrator user. If you try to enter a password that does not meet the requirements, you will see an error message.

e. Number of Nodes - the number of instances of a head node role, a compute node role, and a web frontend node role. The default is one head node, one web frontend node, and three compute nodes.

Note: The default VM size of each instance is set to small. You can change the VM size of each role by editing the ServiceDefinition.csdef file in the AppConfigure application folder.

12. After filling in the missing information, click the Configure button. The application will create the required configuration files, verify the existence of the storage account, and create the SQL Azure server if it does not yet exist.

Note: This process may take several minutes to complete, depending on the existence of the storage account and the SQL Azure server.

As this is for demo purposes, the deployment application will create a new SQL Azure Server with the given credentials in the selected geographical location if there are no servers available. If your subscription already has SQL Azure servers in the selected location, the deployment application will use the first one that appears in the SQL Azure Servers list within the Management Portal and authenticate with the given credentials. Make sure you are using the right credentials and geographical location in case you use an existing server.

13. After the configuration process completes, click the Publish button. The application will add a certificate to the hosted service, create the database instance in the SQL Azure server, upload the scheduler package to storage, and deploy the different roles to Windows Azure.

Note: This process requires uploading a large file to a Windows Azure storage container, and creating several role instances in Windows Azure. It may take more than 10 minutes to complete this process, depending on your Internet bandwidth.

14. After the publishing process completes, click the Close button to close the AppConfigure application.

Page 24: az12722.vo.msecnd.netaz12722.vo.msecnd.net/.../labs/hpcsoaservices1-0/Lab.docx · Web viewAuthor: wwegner : Created Date: 11/17/2011 05:52:00 : Title: Running SOA Services with the

Note: The information you write down in the AppConfigure application is stored in the application’s configuration file and will be available the next time you start the application. The information is stored as plain text, including the passwords, so keep that file safe.

15. In a browser, open the Management Portal, and then click Hosted Services, Storage Accounts & CDN.

16. Click Hosted Services.

17. In the main window, locate your hosted service, expand the HeadNode role, and select the HeadNode_IN_0 instance. Make sure the instance’s status is set to Ready.

Note: It may take another couple of minutes from the time the deployment application completes the publishing process until all the instances are created.

18. On the ribbon, in the Remote Access area, click Connect.

19. When prompted to download the .rdp file, open it, enter the administrator password you selected in Step 11, and complete the login process. If you are warned that the identity of the remote computer cannot be verified, click Yes to connect to the machine despite the certificate’s errors.

Note: The certificate warning that may appear is due to the fact that the certificate used to identify the server was issued by the AppConfigure application and not by a trusted certifying authority.

20. After connecting to the head node instance, open an Explorer window and verify the existence of the following application folders:

a. E:\approot

b. E:\plugins\HpcHeadNode\HPCPack

21. Open the E:\approot folder in windows explorer, and create a folder named SquareService in it.

22. Move the following files from the E:\approot folder to the SquareService folder:

a. AzureSquareService.dll

b. AzureSquareService.pdb

c. SquareService.config

23. Open a command prompt window and type the following commands to move to the client application folder:

Page 25: az12722.vo.msecnd.netaz12722.vo.msecnd.net/.../labs/hpcsoaservices1-0/Lab.docx · Web viewAuthor: wwegner : Created Date: 11/17/2011 05:52:00 : Title: Running SOA Services with the

CMD

e:cd approot

24. Run the following command to create a deployment package for the service:

CMD

hpcpack create SquareService.zip SquareService\

Note: Do not change the name of the package; it must match that of the service configuration file and the service name used by the client application.

25. Run the following command to upload the deployment package to the Windows Azure package storage. Replace <storageAccountName> and <storageAccountKey> with your Windows Azure storage account’s name and primary key:

CMD

hpcpack upload SquareService.zip /account:<storageAccountName> /key:<storageAccountKey>

Note: To find your storage account’s primary key follow the steps in the How to View, Copy, and Regenerate Access Keys for a Windows Azure Storage Account article on MSDN.

26. To sync the Windows Azure compute nodes with the new package, run the following command:

CMD

clusrun hpcsync

27. Leave the remote desktop connection opened, as you will use it for the next task.

Task 5 - Run the Client Application in the Windows Azure Head Node

1. If you have closed the remote desktop connection to the head node, reconnect to it by performing steps -19 of Task 4.

2. Open a command prompt window, and type the following commands to start the client application:

CMD

e:

Page 26: az12722.vo.msecnd.netaz12722.vo.msecnd.net/.../labs/hpcsoaservices1-0/Lab.docx · Web viewAuthor: wwegner : Created Date: 11/17/2011 05:52:00 : Title: Running SOA Services with the

cd approotclient

3. After the client application starts, you will be prompted to enter the username and password you supplied when you deployed the Windows Azure HPC Scheduler. After entering your username and password, select whether to store the password for later use or not.

4. The client application will display the session ID, and then start sending requests to the WCF broker using the WCF service reference. Write down the session ID, and wait for all requests to return.

Figure 11 The client application window with session ID 2

Note: The order of the responses appearing in your output may be different, and the number of responses depends on the value you set for the _numOfRequests static variable.

5. After the first set of requests arrives, press enter. This will cause the client to start a new session, sending requests to the WCF broker using the BrokerClient class. Write down the session ID, and wait for all requests to return.

Note: If you did not decide to store the user’s credentials, you will be required to enter the scheduler’s username and password.

Page 27: az12722.vo.msecnd.netaz12722.vo.msecnd.net/.../labs/hpcsoaservices1-0/Lab.docx · Web viewAuthor: wwegner : Created Date: 11/17/2011 05:52:00 : Title: Running SOA Services with the

6. Keep the two session IDs, and close the remote desktop window.

Verification

1. Open a web browser and browse to your Windows Azure HPC Scheduler Web Portal, which should be located at https://service_name.cloudapp.net/portal, where service_name is the name of the hosted service you entered in Task 4.

2. If you are prompted with a warning message regarding the certificate, click the option Continue to this website (not recommended). The reason for the possible warning is that an untrusted certification authority (that is, the AppConfigure application) issued the certificate used to identify the server.

3. If a Windows Security dialog box opens, enter the username and password of the administrator account you entered in Task 4.

4. After the portal opens, you will see a list of jobs.

Figure 12List of jobs in the Windows Azure HPC Scheduler Web Portal

5. Click on the finished SquareService - WCF service job that has the ID you wrote down in Task 5. You should see a job information window.

Page 28: az12722.vo.msecnd.netaz12722.vo.msecnd.net/.../labs/hpcsoaservices1-0/Lab.docx · Web viewAuthor: wwegner : Created Date: 11/17/2011 05:52:00 : Title: Running SOA Services with the

Figure 13The job information window

6. Click the View Tasks tab, and then click on any of the sub-tasks (1.1-1.N) to see the output of each node.

Figure 14Results of a single sub-task

Page 29: az12722.vo.msecnd.netaz12722.vo.msecnd.net/.../labs/hpcsoaservices1-0/Lab.docx · Web viewAuthor: wwegner : Created Date: 11/17/2011 05:52:00 : Title: Running SOA Services with the

Summary

In this lab, you learned how to create a WCF service and host it in a Windows Azure compute node; how to create a client that can submit a SOA job and call the WCF service in the cluster; and how to deploy the Windows Azure HPC Scheduler to the cloud. You also learned how to use the Windows Azure HPC Scheduler Web Portal to verify the execution of the SOA job.