Top Banner
Demo Script Service Bus Relay Demo Demo version: 1.0.0 Last updated: 5/15/2022
20

Windows Azure Service Bus Relay Demo - Western …rvitolo06/WATK/Demos/ServiceBusRelay/Demo... · Web viewThis demo shows how to expose a database table using a Service hosted in

May 24, 2018

Download

Documents

vungoc
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Windows Azure Service Bus Relay Demo - Western …rvitolo06/WATK/Demos/ServiceBusRelay/Demo... · Web viewThis demo shows how to expose a database table using a Service hosted in

Demo ScriptService Bus Relay Demo

Demo version: 1.0.0

Last updated: 5/8/2023

Page 2: Windows Azure Service Bus Relay Demo - Western …rvitolo06/WATK/Demos/ServiceBusRelay/Demo... · Web viewThis demo shows how to expose a database table using a Service hosted in

CONTENTS

OVERVIEW................................................................................................................................................. 3Key Messages......................................................................................................................................... 3

Key Technologies.................................................................................................................................... 3

Prerequisites............................................................................................................................................ 3

Time Estimates........................................................................................................................................ 3

SETUP AND CONFIGURATION................................................................................................................. 5Task 1 – Creating a Service Bus Namespace........................................................................................5

Task 2 – Updating the Solutions with the Service Namespace Settings...............................................5

Task 3 – Run provided scripts to add the Northwind database...........................................................6

DEMO FLOW.............................................................................................................................................. 6

OPENING STATEMENT............................................................................................................................. 8

STEP-BY-STEP WALKTHROUGH.............................................................................................................9Segment #1: Exposing Tables using Windows Azure Service Bus.........................................................9

(Optional) Segment #2: Consuming Services in iOS with Safari...........................................................15

SUMMARY................................................................................................................................................ 18

Page 3: Windows Azure Service Bus Relay Demo - Western …rvitolo06/WATK/Demos/ServiceBusRelay/Demo... · Web viewThis demo shows how to expose a database table using a Service hosted in

Overview

This demo shows how to expose a database table using a Service hosted in the Windows Azure Service Bus and consume it using a Cloud based MVC4 application. It also show how easy is to generate an iOS compatible application using MVC4 and deploy it to the cloud.

Key Messages

In this demo you will see several key features and tools:

1. Creating a Service Client using a Channel Factory

2. Exposing a data using Windows Azure Service Bus

3. Accessing a MVC4 cloud application using Safari

Key Technologies

This demo uses the following technologies:

1. MVC4

2. Windows Azure SDK and Windows Azure Tools for Microsoft Visual Studio 2010

3. Windows Azure Service Bus

Prerequisites

Windows Azure subscription

Time Estimates

Estimated time for setting up and configuring the demo: 10 minutes

Page 4: Windows Azure Service Bus Relay Demo - Western …rvitolo06/WATK/Demos/ServiceBusRelay/Demo... · Web viewThis demo shows how to expose a database table using a Service hosted in

Estimated time to complete the demo: 20 minutes

Page 5: Windows Azure Service Bus Relay Demo - Western …rvitolo06/WATK/Demos/ServiceBusRelay/Demo... · Web viewThis demo shows how to expose a database table using a Service hosted in

Setup and Configuration

Make sure you have checked all the dependencies for this demo before running the setup.

The setup and configuration for this demo involves the following tasks:

Create a Service Bus Namespace in your Windows Azure subscription.

Update the solutions with your newly created Service Namespace settings.

Run provided scripts to add the Northwind sample database into your SQL Server.

Task 1 – Creating a Service Bus Namespace

1. Navigate to the Windows Azure portal. You will be prompted for your Windows Live ID credentials if you are not already signed in.

2. Click Service Bus, Access Control & Caching link in the left pane, and then select Service Bus item under the Services element.

3. In the upper ribbon, click New and create a new Service Namespace. Make sure the ServiceBus box is selected.

4. Locate the Properties of the newly created Service Namespace and record the name. Then, click the View button inside the Default Key box and record the values of the Default Issuer and the Default Key as well. You will use them in the next task.

Task 2 – Updating the Solutions with the Service Namespace Settings

1. Open the ServiceBusRelay-Cloud.sln solution located in the Code folder of this demo.

2. Locate the ServiceBusRelay.Web project and expand it.

3. Open the Web.config file and update the ServiceIssuer and ServiceSecret values with the values recorded in the previous task.

4. Open CustomerService.cs file within Services folder and replace the Service Namespace value with the one you created in the previous task.

5. Now, open the ServiceBusRelay-OnPremises.sln solution located in the Code folder of this demo.

Page 6: Windows Azure Service Bus Relay Demo - Western …rvitolo06/WATK/Demos/ServiceBusRelay/Demo... · Web viewThis demo shows how to expose a database table using a Service hosted in

6. Edit the app.config file and replace the placeholders with the same ServiceIssuer and ServiceSecret values you used in the step 3.

7. Open the Program.cs file and update the Service Namespace value with the one you used in step 4.

Task 3 – Run provided scripts to add the Northwind database

1. Run the Setup.cmd file located in the root folder of this demo to add the Northwind database in your SQL Server.

Demo Flow

The following diagram illustrates the high-level flow for this demo and the steps involved:

Page 7: Windows Azure Service Bus Relay Demo - Western …rvitolo06/WATK/Demos/ServiceBusRelay/Demo... · Web viewThis demo shows how to expose a database table using a Service hosted in

Figure 1Demo Flow

Page 8: Windows Azure Service Bus Relay Demo - Western …rvitolo06/WATK/Demos/ServiceBusRelay/Demo... · Web viewThis demo shows how to expose a database table using a Service hosted in

Opening Statement

In this demo, you will learn how a simple Console application can expose and bind a Service to the Windows Azure Service Bus to retrieve customers from a SQL Server database. You’ll also learn how to consume this service via a Cloud based MVC4 application using IE and Safari browsers.

Page 9: Windows Azure Service Bus Relay Demo - Western …rvitolo06/WATK/Demos/ServiceBusRelay/Demo... · Web viewThis demo shows how to expose a database table using a Service hosted in

Step-by-Step Walkthrough

This demo is composed of the following segments:

Exposing Tables using Windows Azure Service Bus.

(Optional) Consuming Services in iOS with Safari.

Segment #1: Exposing Tables using Windows Azure Service Bus

Action Script Screenshot

Page 10: Windows Azure Service Bus Relay Demo - Western …rvitolo06/WATK/Demos/ServiceBusRelay/Demo... · Web viewThis demo shows how to expose a database table using a Service hosted in

1. Open Visual Studio 2010 with Administrator privileges.

2. Open the ServiceBusRelay-Cloud.sln solution located in the Code folder of this demo.

3. In the Solution Explorer, locate the ServiceBusRelay.Web project and open CustomerService.cs file within Services folder.

I’ll start showing you the Client application.

This is a Cloud based project that uses a MVC4 web page to list customers from a SQL Server database.

Let’s open the CustomerService class. There you’ll see how this application consumes the table exposed by the Server application in the Service Bus.

Page 11: Windows Azure Service Bus Relay Demo - Western …rvitolo06/WATK/Demos/ServiceBusRelay/Demo... · Web viewThis demo shows how to expose a database table using a Service hosted in

4. Show how to write a Client using the ChannelFactory.

Inside the CustomService class, we are using the ChannelFactory object. This object creates a channel through which the service and client applications communicate.

The ICustomerChannel sent as parameter indicates the type of channel produced by the channel factory that’s used to send messages to configured service endpoints.

5. Run a new instance of Visual Studio as Administrator.

6. Open the ServiceBusRelay-OnPremises.sln solution located in the Code folder of this demo.

7. In the Solution Explorer, locate the ServiceBusRelay.Console project and double-click Program.cs file.

Now that we know how a client application communicates with a server, we’ll examine the Server application.

The Server application is a simple console application with the necessary logic to return the requested information and log the Client’s requests in the console window.

Page 12: Windows Azure Service Bus Relay Demo - Western …rvitolo06/WATK/Demos/ServiceBusRelay/Demo... · Web viewThis demo shows how to expose a database table using a Service hosted in

We’ll start with the Program class. This is where the Server Application hosts the service and binds it to Service Bus.

8. In the Program.cs class, show how to host the service and bind it to Service Bus.

9. Double-click CustomerService.cs file and show the implementation of the GetCustomers method.

In the Main class we create a ServiceHost object and configure it to expose the service binding it to Service Bus.

Then, with the Open method, you open the ServiceHost to start listening for messages.

Now, let’s see how the service retrieves the requested information.

In the CustomerService class, you’ll find the service’s logic.

As you can see, we have just two methods, one that retrieves all the customers, and other to retrieve a specific client filtering by Id.

When the client makes a request, the Service retrieves the requested information and logs the call type in the console.

Page 13: Windows Azure Service Bus Relay Demo - Western …rvitolo06/WATK/Demos/ServiceBusRelay/Demo... · Web viewThis demo shows how to expose a database table using a Service hosted in

10. Press CTRL + F5 to start the console application. Wait until it starts before continue with the next step.

We’ll start the Server console in order to host and expose the service in the Windows Azure Service Bus and then, run the Client web application to access it. This way, you’ll see how the applications communicate with each other.

Before running the Client application, we need to make sure that the service is started. The application will show a message in the console.

Page 14: Windows Azure Service Bus Relay Demo - Western …rvitolo06/WATK/Demos/ServiceBusRelay/Demo... · Web viewThis demo shows how to expose a database table using a Service hosted in

11. Switch back to the other instance of Visual Studio with the ServiceBusRelay-Cloud solution.

12. Press CTRL + F5 to run the MVC4 client application that consumes the exposed service.

Now that we have the service exposed in the Service Bus, we’ll proceed to run the Client web application.

We are running the client on-premises using the Windows Azure Emulator, but the functionality would be the same with the Web Application hosted in Windows Azure.

Page 15: Windows Azure Service Bus Relay Demo - Western …rvitolo06/WATK/Demos/ServiceBusRelay/Demo... · Web viewThis demo shows how to expose a database table using a Service hosted in

13. In the Console Application window, show how it reflects that the client has connected and requested the GetCustomers method.

14. Switch back to the web application and click a customer from the list.

15. Back in the console application, show how it reflects this action by showing a call to GetCustomerById method.

Let’s see the console application. Now that we’ve run the Client and it has called the GetCustomers method to the service, the console will show a message with that request.

In addition, if we click a customer to see more information, we’ll notice in the console the log of the call to the GetCustomerById method.

In the next segment, we’ll publish the Client application to the cloud and see how easy is to generate a iOS compatible application and access it using Safari instead of IE.

(Optional) Segment #2: Consuming Services in iOS with Safari

Action Script Screenshot

Page 16: Windows Azure Service Bus Relay Demo - Western …rvitolo06/WATK/Demos/ServiceBusRelay/Demo... · Web viewThis demo shows how to expose a database table using a Service hosted in

1. Open Visual Studio 2010 with Administrator privileges.

2. Open the ServiceBusRelay-Cloud.sln solution located in the Code folder of this demo.

3. Right-click the Cloud Project and select Publish.

4. Follow the Publish wizard to deploy your application to Windows Azure.

Note: You can learn more about Publishing Applications to Windows Azure using Visual Studio in the Publishing Cloud Apps demo that is included in this Training Kit.

5. Make sure the Console application you used in the previous segment is still running. If not, repeat step 10 of Segment #1.

6. Open Internet Explorer and Browse to http://your-hosted-sevice-name.cloudapp.net where your-hosted-sevice-name is the hosted service name where you deployed the application.

7. Repeat the previous step, but this

To see how the Client application can be accessed by an iOS based application, we’ll need to publish it to Windows Azure.

To do this, we’ll use the Publish wizard Visual Studio provides.

Following some quick and easy steps, we’ll have this MVC4 application deployed.

First, we’ll need to sign in to download our credentials.

Then, we’ll choose where we’d like to deploy the application.

If we don’t have an available hosted service we can also create one from here!

Lastly, we need to define our deployment’s settings and wait until the application is deployed.

Now we’ll access it using Internet Explorer.

As you can see, it has the same functionalities we saw in the previous sample.

Now, we’ll use this iOS device/emulator to see how

Page 17: Windows Azure Service Bus Relay Demo - Western …rvitolo06/WATK/Demos/ServiceBusRelay/Demo... · Web viewThis demo shows how to expose a database table using a Service hosted in

time using Safari on an iOS Simulator or iOS device.

MVC4 applications also work on Safari browsers.

Page 18: Windows Azure Service Bus Relay Demo - Western …rvitolo06/WATK/Demos/ServiceBusRelay/Demo... · Web viewThis demo shows how to expose a database table using a Service hosted in

Summary

This demo showed how to create a Service that exposes a database table using Windows Azure Service Bus and how to access to that service using a MVC4 application.