Windows Azure AppFabric – Part 1: The Big Picture with Pub/Sub


I am currently working on some AppFabric projects for a company I am thrilled to have recently joined called Readify. So, why not share the love and discuss AppFabric.

Part 1: I am hoping to complete a series of blogs on Windows Azure AppFabric. This blog will be part where we look at the basics for getting started and the bigger picture and some infrastructure configuration for IIS AutoStart, I love WAS J We must use it.

Part 2: Will show a Asynchronous message pattern via Windows Azure Appfabric and we will use WPF clients to publish and subscribe messages using the EventRelayBinding. The WPF application will be using the Event Aggregation framework from the Composite Application Library (Prism), which you can download here:

We also use a WPF phone client, that subscribes to events, it is VERY SIMILAR to a real windows 7 Phone implementation where calls back to the phone occur from the Windows 7 Phone cloud that pushes Tile and Toast notifications. Perhaps in a separate blog I will post a sample Windows 7 App, however, I have to chat with my colleague Miguel Maderoas he is doing allot of work on it in regards to IoC (Ninject) and Silverlight stuff.

Part 3: We will look at integration with Azure Worker/Web Roles and Azure Queues

Part 4: We will look at BizTalk 2010 integration scenarios J

What this allows is a single client to subscribe to the AppFabric Service Bus and then it can distribute it to internal subscribers; this is a nice way to receive messages when Message Queues are out of the question. So in Part two the high level solution will be:

I have omitted the client in this diagram that published to AppFabric.


Service Bus Benefits

· Expose apps and services through problematic network boundaries

· Exposing services easily, supporting multiple connection options and publish and subscribe for multicasting. 

· Lightweight developer friendly programming model

· Shields your services from intrusions and denial-of-service attacks

Service Bus Features

· Services discovered through URL, irrespective of location

· One-way messaging between sender and listener supports unicast and multicast datagram distribution

· Full-duplex connection-oriented sessions

· Full-duplex, connection-oriented peer-to-peer sessions

· Multiple publishers and multiple subscribers can simultaneously use the service’s topic management and event distribution system

· Support of REST and HTTP Access from non-.NET platforms

· Global hierarchical namespaces that are DNS- and transport- independent

· Anonymous access to services is supported

Community Technology Preview

To get started with AppFabric, there is a free CTP portal where you can register a service, below is a Service Bus, hosted on the CTP labs cloud, which is free of charge.


Windows Azure AppFabric Getting Started

Once the CTP portal is running you can then setup the development environment to work with the Labs Portal and the SDK.


You can rename the Servicebus.config.txt file to Servicebus.config and ensure to have a Servicebus.config in the .Net Framework configuration folder, depending on the framework version you using e.g. c:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\servicebus.config

The default content for the Lab config file is:

Ensure to read the Release Notes.mht

Note:The above config file is for Development only, production will be pointing to:


Service Bus SDK


Run this command to customize the location of the SDK:

msiexec /I WindowsAzureAppFabricSDK.msi APPLICATIONFOLDER=c:\WindowsAzureAppFabricSDK /qn

Service Bus Known Issues

1. Current users would need to update their issuer keys for their existing applicationss to work with the new services – you can get this key from the ServiceBus section on the portal.

2. When uploading CrossDomain.XML to the Service Bus root, please leave out the schema declaration.

3. Silverlight clients convert every Service Bus operation error to a generic HTTP NotFound error.

4. Service Bus Multicast with Message Buffers features, which have been available in LABS since March 2010, has been temporarily removed from the LABS environment. The team is working on an alternative approaches to these features.

Access Control SDK

The access control samples can be downloaded from:

Access Control

Shared key

The default mechanism to authenticate is Shared Key, therefore ensure in AppFabric Labs Portal, you find the Issuer Name and Issuer Secret:

Default Issuer Name is: Owner

You can find the details in the ACS links for Service Identities. So to keep things simple, we will not use any federated services and claim tokens such as SimpleWebToken.

Below is a screenshot, where you can find this information, the production version has links to the Issuer Name from the Service NameSpace Management page, but not in the Labs Portal!


Then when creating a connection from a client endpoint, the code will resemble the following for Shared Key authentication.

TransportClientEndpointBehavior relayCredentials = new TransportClientEndpointBehavior();

relayCredentials.CredentialType = TransportClientCredentialType.SharedSecret;

relayCredentials.Credentials.SharedSecret.IssuerName = issuerName;

relayCredentials.Credentials.SharedSecret.IssuerSecret = issuerSecret;

Uri serviceAddress = ServiceBusEnvironment.CreateServiceUri(“sb”, serviceNamespace,

String.Format(CultureInfo.InvariantCulture, “{0}/MulticastService/”, session));

ServiceHost host = new ServiceHost(typeof(MulticastService), serviceAddress);



This can be testing using the simple SDK samples for Azure AppFabric, particularly the sample application: WindowsAzureAppFabricSDKSamples_V1.0-CS\ServiceBus\GettingStarted\Echo. Note run RelayConfigurationInstaller.exe if you convert the sample to .Net 4.0

Here is output from the console to test the connection, remember the servicebus.config file MUST be in the config folder in the .NetFramework as mentioned before, or you can add it to the local app.config for each sample you want to use, if you do not want to add it, else it will try to connect to the Production AppFabric Portal and the host.Open() method will fail as it is resolving the service name to instead of


Windows Azure AppFabric Platform Training Kit

You can download the following kit to assist in learning various scenarios with App-Fabric Service Bus:

Hosting a Service with relay bindings Preparation

What we want to do is ensure that Publisher can always publish messages, so let’s host the service in IIS AppFabric, then configure the service to relay the message to a Brodcaster, this means two things:

1. The service accepts messages from a publisher, hence a IContract

2. The service resends the message to a new service endpoint in AppFabric that Clients connect to; we call this the BookingFeedBroadCast endpoint!

Here is a diagram showing what we building in the future parts:


Note, you can have multiple Publishers and multiple Subscribers.

You probably first wrote the service that has a channel listening to AppFabric as a Console App, this can be hosted in IIS with some small changes and some hotfixes!

Since relay bindings OPENS a channel with, IIS cannot activate such a service, so if you want to host a service with relay bindings, then you need to use IIS Autostart

Check List

· Always run Visual Studio 2010 in Administrator’s Mode

· Have IIS 6.0 Metabase Compatibility installed.

· IIS 7.5

· AppFabric Server Install

· Two patches to allow AppFabric XML settings to be recognised by IIS and the other for autostart features.

o– transportClientEndpointBehavior and serviceRegistrySettings in C:\Windows\System32\inetsrv\config\schema


· Run the RelayConfigurationInstaller.exe which is part of the Azure AppFabric SDK

· Create a new project (Empty ASP.NET Application) and just add linked references to the console version (I like the console version for testing, very rare scenario where I have a console app for testing, since it connects to the service bus it makes sense to have it here, I guess you can make some integration tests too).

· Configure hosting in IIS on the project properties web page.

· Add links to the original services in the console, or if you prefer to just have this, then create the service etc, the contracts are in a different assembly, so you will not see them here:

o Notice above that I have it linked, since I use it for testing in a console app as well, but I always prefer IIS auto Start, then I always know the latest service for publishing is always up and running!


Notice that System.Runtim.Serialization is .Net 3.0 assembly!

· Now we just configure the web.config for it. This is slightly different to the console application config. Here is my config, notice I am using NetEventRelayBinding, for a multicast scenario, or commonly called PUB/SUB messaging pattern.

In future parts, I will explain these settings, they for a Pub/Sub model! I have the credentials twice one for IIS to use and the other for the service to call the broadcaster endpoint. You can always just have one location if need me, I just find it easier to have them in both places as I use System.Configuration.

Notice the service here is also a client! It is a client to a Subscribers endpoint to broadcast the message for pub/sub J

We can now publish the application to IIS, notice we actually do not have an SVC file, since we really do not need one, as the EventRelayBinding will open a channel when IIS instantiates it. So in IIS we configure the AutoStart without a SVC file!
Notice the relative address in the web.config is:

<add relativeAddress="ExternalBookingsReportService.svc"

You can make yours whatever you like.

· In IIS we will configure the WCF properties with AutoStart Set to custom:


· Then at the AppFabric Service level we will set auostart (if you do not do the step above, this will be greyed out!) Also in production use a dedicate application pool for AuoStart!



That it is, now the service will automatically start up, no requests from users are needed, now when it autostarts, it can create a channel with the AppFabric Service Bus!

We can check that the endpoints are configured from the config file correctly in IIS AppFabric:


To test the endpoint with ap fabric is easy, just browse the to the default virtual directory for the app and add the relative address e.g.


This is in the ServiceActivation element in the web.config:


I have not created a Mex EndPoint, and why should I when building a PUB/Sub system, it is totally transparent from subscribers J

Now, I do not want to get into too much detail here, the idea is to have some inkling of configuration settings that you will get into, however, if I now publish a message the Bus, I can debug the service hosted in IIS:


Now when I use a client who connects to AppFabric:


I should be able to step in:


Cool right! A client submitted a message asynchronously and we can debug it remotely J

Let the system go with F5 and indeed a subscriber got the message via AppFabric and IIS Autostart:



I understand pricing is big issue for allot of people, the best advice is to get an excel sheet and try calculate the costs, you will be amazed at how cheap hosting services are, however depending on how you design your architecture; you can keep the costs down!

The following prices are in US Dollars

Access Control

Access Control transactions = $1.99/100K

Service Bus connections

$3.99 per connection on a “pay-as-you-go” basis

$9.95 for a pack of 5 connections

$49.75 for a pack of 25 connections

$199 for a pack of 100 connections

$995 for a pack of 500 connections

Data transfers

Data transfers = $0.10 in / $0.15 out / GB – ($0.30 in / $0.45 out / GB in Asia)

Measuring AppFabric Consumption

AppFabric Service Bus connections can be provisioned individually on a “pay-as-you-go” basis or in a pack of 5, 25, 100 or 500 connections. For individually provisioned connections, you will be charged based on the maximum number of connections you use for each day. For connection packs, you will be charged daily for a pro rata amount of the connections in that pack (i.e., the number of connections in the pack divided by the number of days in the month). You can only update the connections you provision as a pack once every seven days. You can modify the number of connections you provision individually at any time.

For AppFabric Access Control transactions, customers will be charged the actual number of transactions utilized for the billing period (i.e., not in discrete blocks of 100,000 transactions), plus data transfers in or out.

Community Technology Preview (CTP)

Community Technology Preview (CTP) participants that have not yet upgraded to a commercial subscription of the Windows Azure platform will continue to be subject to the following limits:

· Total compute usage: 2,000 compute hours

· Cloud storage capacity: 50GB

· Total storage data transfers: 20GB/day


In part 2 we will go into a deep dive and check out how to build these composite applications. I hope this gives you some ideas on AppFabric. Also, we could make this a reliable message pattern by introducing queues, but I need to do some thinking around that to make it as reliable as NserviceBus, which will be a challenge in AppFabric/Azure hosting, but should be possible.


Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s