Demo Script - netOnewayRelayBinding

advertisement
Demo Script
Windows Azure Service Bus NetOneWayRelayBinding
Lab version:
2.0.0
Last updated:
2/8/2016
Contents
OVERVIEW ................................................................................................................................................... 3
Key Messages ........................................................................................................................................... 3
Key Technologies ...................................................................................................................................... 3
Time Estimates ......................................................................................................................................... 4
SETUP AND CONFIGURATION .................................................................................................................. 4
Task 1 – Creating a Service Bus Namespace ......................................................................................... 4
Task 2 – Opening the NetOneWaySimple Sample ................................................................................ 4
DEMO FLOW ................................................................................................................................................ 5
OPENING STATEMENT............................................................................................................................... 5
STEP-BY-STEP WALKTHROUGH .............................................................................................................. 6
Looking at the code in Visual Studio ......................................................................................................... 6
Run the service and client ......................................................................................................................... 8
SUMMARY .................................................................................................................................................. 10
KNOWN ISSUES ........................................................................................................................................ 10
Overview
This demo shows the Service Bus NetOnewayRelayBinding. This is the simplest possible way to send messages on the bus. This sample is good to
show as it uses information cards to authenticate to the bus (Echo, Chat use username and password).
The code is part of the Windows Azure SDK samples that you can download from http://code.msdn.microsoft.com/windowsazure.
Note: In order to run through this complete demo, you must have network connectivity.
Key Messages
1. It is very simple for a .NET developer to modify a typical WCF app to use the relay
2. You use a Live ID to access your solution the Windows Azure Portal
3. You can use a username and password, or a certificate to access your Service Bus service programmatically using the built-in identity
store.
Key Technologies
This demo uses the following technologies:
1. .NET Framework 3.5 SP1
2. Visual Studio 2010
3. Windows Azure SDK and Windows Azure Tools for Microsoft Visual Studio
4. Windows Azure Service Bus (i.e. internet connectivity is required)
Time Estimates

Estimated time for setting up and configuring the demo: 5 min

Estimated time to complete the demo: 5 min
Setup and Configuration
This demo does not have any advanced configuration requirements. Make sure you have checked all the dependencies for this demo and have
Windows Azure account. For more information on how to purchase an account, visit the Windows Azure Portal at https://windows.azure.com/.
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 Services element.
3. Create a Service Namespace.
4. Go into the Solution Credential Management part of the portal and associate a self-issued information card with the solution.
Task 2 – Opening the NetOneWaySimple Sample
1. Download the Relayed Messaging Bindings: Net Oneway sample from http://code.msdn.microsoft.com/Relayed-Messaging-Bindingsbb5b813a.
2. Open Visual Studio running as administrator. Open the NetOneWaySample solution located in the zip file donwloaded in the previous
step.
Demo Flow
The following diagram illustrates the high-level flow for this demo and the steps involved:
Figure 1
Demo Flow
Opening Statement
This demo shows the simplest use of the Windows Azure Service Bus using one way messaging over the Service Bus. A set of one-way messages
will be sent from the client app to the service via the Service Bus.
Step-by-Step Walkthrough
This demo is composed of the following segments:
1. Show the code in Visual Studio
2. Show the solution in the portal
3. Run the service and client
Looking at the code in Visual Studio
Action
Script
1. Open the NetOnewaySimpleSample
in Visual Studio

This is the service contract. There is
nothing new here, it looks like any
WCF service contract. Note the
Operation Contract with IsOneWay =
true.

Here is the service implementation –
again nothing new.
2. Open the (service)
OnewayContract.cs
3. Open OnewayService.cs
Screenshot
4. Open service App.config

In the App.config however, there are
a number of changes to how we
configure our service on the Service
Bus.

You can see we are using a
netOnewayRelayBinding to connect
to the Service Bus and there is new
endpoint behavior,
transportClientEndpointBehavior
which is specifying a credentialType
of SharedSecret. As you might guess,
transportClientEndpointBehavior is
where we specify the Service Bus
credentials to use for a particular
endpoint. Here we are saying that the
shared secret credential is used to
authenticate with the Service Bus.

In the main program we are using the
Microsoft.ServiceBus namespace and
a helper function to get the solution
name. Our service URI is special and
begins sb:// to denote that it will be
hosted on the ServiceBus. Otherwise
the code the looks exactly the same
as in any other WCF console app
5. Highlight the binding and then
transportClientEndpointBehavior
credentialType="SharedSecret"
6. Complete the placeholders for issuer
name and secret key.
7. Open service Program.cs

On the client side the contract is, of
course, the same. The App.config
uses the same binding,
netOnewayRelayBinding.

In the client’s main program we again
use the Microsoft.ServiceBus
namespace and prompt the user for
the service bamespace domain. The
URI of the service is built up in a
similar way to the service. The code
for actually accessing the service is
boilerplate WCF code – there is
nothing new here. We create a
channel factory, create and open a
channel, and send a message.
Open client App.config.
8. Complete the placeholders for issuer
name and secret key.
9. Open client Program.cs
Run the service and client
Action
Script
Screenshot

Now we’ll run the application.

We enter the service namespace
domain.
11. Enter your service namespace
domain in the console window when
prompted.

The service is now running and
connected to the Service Bus where
a listener is set up.
12. Right click Client in the Solution
Explorer and select Debug > Start
new instance

Now we launch the client and again
enter the service namespace domain.

Once the channel is open the client
sends 25 one way messages to the
service via the Service Bus.
10. Right click Service in the Solution
Explorer and select Debug > Start
new instance
13. Enter your service namespace
domain in the console window when
prompted.
Summary
This demo showed how straightforward it is for a WCF client and service to use the Service Bus. We also looked at the different credentials users
can provide to be authenticated and authorized by the Access Control service.
Known Issues
Please note the following known issues with this demo: None.
Download