CodeProject
What is WAP and what can I do with it?
Windows Azure Pack (WAP) was officially announced on this year's (2013) TechEd North America. Basically it is a collection of Azure Services that are included in a Windows Server license. This means that if you have licensed Windows Server (starting from Windows Server 2008) your have the right to install the WAP on your servers on-premise.
Here is the official definition taken from the Azure Pack Website:
The Windows Azure Pack delivers Windows Azure technologies for you to run inside your datacenter, enabling you to offer rich, self-service, multi-tenant services that are consistent with Windows Azure
Installing Service Bus 1.1 (preview) on a Windows 8 x64 System
The version of WAP to install on a Windows 8 x64 box (x32 will not work!) is the express version. The installer can be run using the “Microsoft Web Platform installer”. You can read later in this article how to install WPI.
Here are some additional requirements that need to be fulfilled by the target machine:
- Ensure that your machines name is not longer than 15 characters
- At least 8GB of RAM if all components are installed using the Express installation
- For a proof of concept (POC) install, or local dev a Windows 8 x64 based system
can be used - SQL Server, starting from SQL-Server express
For a first try I would recommend that you setup a virtual machine using Hyper-V and a Windows 8 x64 ISO file. That way you can test everything without messing up your current development workstation.
Setting up a Windows 8 x64 VM using Hyper-V on Windows 8 x64
If you have not installed Hyper-V until now on your development machine , you open the control panel, go to “Programs and Features” and choose “Turn Windows features on or off”
Find the “Hyper-V” entry, expand it and select everything that’s visible under that tree:
Hit “OK” and wait for Hyper-V to be installed for you. Should take only a few minutes.
Adding a new VM
Go to your Windows 8 Start-Screen and type Hyper-V Manager and hit “ENTER”. Hyper-V Manager opens up. On the right hand side you can see the “Actions” panel. Click on “New” and then on “Virtual Machine”:
The new “Virtual Machine Assistant” opens up:
Give your virtual machine a name. You can choose an additional location if you want. Then click “Next”.
Depending on how much RAM you have installed in your system, choose an appropriate value to be assigned to your virtual machine. We need at least 2GB here. If you have only 4GB of RAM installed, that should be the maximum value to use. I set the value to 4GB (4096) and click next.
Now it is time to choose the network connection you want to share with your virtual machine. Make a selection and choose next.
For a basic Windows 8 x64 install and the express version of WAP 40GB should be more than enough (30GB like in this screenshot will definitely NOT be enough) . Change the value to your desired value, or leave it like it is. Click “Next”.
On the last screen we need to choose the ISO-Image to be booted during the startup of the virtual machine.
The assistant will now create a virtual disk and prepare everything according to our settings. Double click the new entry in Hyper-V Manger (Left hand side) and press the “Power” button.
From now on, you install Windows 8 like you always do. Install all the updates needed and move on.
Downloading and installing SQL-Server Express 2012
To be able to install and operate Service Bus locally, we need to install SQL Server, at least the express edition.
To do so, please download SQL Server 2012 Express here:
Microsoft SQL Server 2012 Express
After clicking on the download button, you will be presented with different options. I selected the second (largest) file, because it contains SQL Server Express, the management tools like SQL Server Management Studio or SSMS and the advanced services. This will enable you later to add new features as you need them.
Depending on your internet connection speed, it is the right time to grab some of your favorite drink (mine is coffee) and enjoy it during the download.
Installing SQL Server Express 2012
Simply run the file you downloaded earlier and choose “Installation” in the menu on the left, and “New SQL Server stand-alone installation or add features to an existing installation”
Confirm the license and confirm to install the update (26MB):
Setup will now extract files and download updates. That takes a while (about 3 Minutes or so). When that is finished, you can choose the components you want to install. Just leave everything as is and click on next:
To be able to identify your SQL Server instance later, you should give it an interesting name. I tend to use names like THOR or IRONMAN or – you know what I mean. As soon as you change the instance name and press TAB the instance ID will be changed to THOR as well. Click on next now.
Leave all the settings on the next screen as they are. SQL Server will use the standard account for services on Windows. Just change the the setting for the SQL Server browser from “disabled” to “Automatic”. Otherwise the WAP setup will not be able to automatically detect our SQL Server instance.
On the next screen I tend to choose the “Mixed Mode Authentication” option. If you move databases from one system to another being SA can come in very handy. Because SA is THOR on SQL Server, I choose to be some kind of God rather than a usual human. You can leave the rest of the settings as they are and click on “Next”.
The SQL Server Reporting Services are not needed for our setup. You can play with Reporting Services later on. For now choose the “Install Only” option and click next. Reporting Services will be installed but not configured for now.
Now simply click on next until the installer is staring to do its work.
That takes a while – again. Cheers!
SQL Server will take a good amount of our disk-space and of our time. It’s worth it. SQL Server is a great relational DB-System.
Ok. Our VM is now configured, SQL Server installed, time to install Service Bus using WPI (Web Platform Installer).
Getting the Web Platform Installer
To install WAP Service Bus (preview) the Web Platform installer has to be deployed to the test-vm. You can download the WPI here: Microsoft Web Platform Installer the current version (at the time of this writing) is 4.6.
Click on the “Free Download” button, click on “Run”. Windows Installer will be fired up and you can install WPI.
Right after the install WPI will be started. Type “Service Bus” into the search box on the right hand side and install the first entry “Windows Azure Pack: Service Bus 1.1 – Preview” by clicking on “Add” and then on “Install”. Accept the installation of the prerequisites and you are good to go.
You can exit WPI after the installation is finished.
Basic WAP Service Bus configuration
It’s time to configure our local Service Bus installation now. Visiting your Start Screen reveals two new entries
- Service Bus PowerShell
- Service Bus Configuration
To be able to use the “Service Bus Configuration Wizard” you need to have administrative rights on the executing machine.
The wizard will offer you 2 different options on how to configure your Service Bus installation:
- Create a New Farm (With default or custom settings)
- Join an Existing Farm
Because we have a clean system here, I assume that you don’t have an existing farm running on your network. We choose the first option and the sub-option with the default settings.
First of all, we need to configure the farm. We will use the recommended default settings. On the “New Farm Configuration” screen you can see, that our SQL Server Express installation was successfully detected (Thanks to the SQL Server browser service). Just for fun you can click on “Test Connection” too see if our SQL Server connection is working as expected. If you see a small green circle with a checkmark in it, it worked. Otherwise check if the “SQL Server Browser” service was started on your machine.
Expanding the “Advanced Options” reveals the possibility to choose a secure SSL connection to be used with SQL Sever. This will not work with our current configuration. Additionally you can choose to use the Windows or SQL Server authentication flavor. Windows Authentication is ok. If you want to add a SQL Server user, choose the second option.
Message Containers
To explain what a message container is, we have to dive a bit into the Service Bus for Windows Server architecture. I have taken the original Microsoft platform stack and reduced and simplified it to fit into our scenario:
First in row is always the Service Bus gateway. Requests are pre-processed by Protocol Heads.
A “Protocol Head” is a module that plugs into a gateway service, implementing a particular protocol
Thanks to Clemens Vasters for the detailed definition posted on Twitter. His Twitter handle is @clemensv.
Security checks, authentication and authorization are done. Then the gateway forwards the request to a specific message broker.
The Message Broker is implemented as Windows Service. It hosts one or more Message Containers. For a basic failover scenario your should use at least 3 Message Containers.
A Message Container hosts Service Bus Queues, Topics and Subscriptions, that are backed by a SQL Server database. Each message container has its own database.
The Message Broker registers with the Fabric Service on the same machine. Fabric Services are responsible for high availability within the farm, cluster information and load balancing.
Configuring the Service Account
Next (on the same page) it is necessary to configure the account under which the farm service will be executed. Just enter your credentials here. The service will have the same access rights like your user account does on the system you are currently installing. As soon as you leave the password entry field, the assistant will check your credentials. That’s good, because you don’t want to see a failed setup script later on.
Certificate Generation Key
I think this should be renamed to “Certificate Generation Passphrase” . Just enter a phrase of your choice here. This phrase will be used to generate the certificate that is required for our Service Bus installation.
Service Bus Namespace
Set your preferred namespace here, or leave it like it is.
Leave the settings for the portal as they are, and continue to the next screen. Please don’t confirm the dialog immediately! We will need the information’s from the next page (the Summary page).
The assistant will start all kinds of different setup tasks now and will present you a summary page, that delivers you all the data you need to access your local Service Bus installation and a bit more. At the bottom of the Summary page you will find 2 links. The first one (from left to right) copies all the information’s you see on the screen, so that you can paste them into your favorite editor and save it for later use.
The second link will generate a PowerShell script, stuffed with samples on how to create a new Service Bus farm, your SQL Server connection string and more. Use this file as a reference, if you want to add a new farm or create new service hosts and so forth.
After performing these steps to get your SB installation up and running you may have a little bit more respect for your administrators
Ready to develop
We are ready now to test the installation. To do that, please install Visual Studio within your VM. I will not explain how to install Visual Studio, I assume everyone reading this article knows how to do it.
To get the required connection information’s we need to connect to our local Service Bus installation, we start the “Service Bus PowerShell”:
What we need is the Service Bus namespace information to successfully connect to our local installation. The “Service Bus PowerShell” offers a great set of PowerShell-CmdLets to interact and manage our installation. To get the connection informations, just type “Get-SBClientConfiguration > sbconnectionString.txt”. Start Notepad by typing: “Notepad sbconnectionString.txt” and if everything went fine, you should see data similar to this:
Very cool!
Start Visual Studio and create a new console based project. Call it whatever you want, and add a reference to the “Windows Azure Service Bus” NuGet package. You should install version 1.8.0.0 using the Package Manager Console. The other pre-release package “Service Bus 1.1 for Windows Server” will not work for this kind of installation. And the current Azure Service Bus packages, version > 1.8.0.0 will not work as well. I assume (not tested) that the “Service Bus 1.1 for Windows Server” is meant to work on a real Windows Server >= 2008 and in a domain-driven environment.
Now open your app.config file and configure the connection string to connect to your on-premise Service Bus installation.
Just copy the string from the Service Bus PowerShell and replace the “value” part of the app.config setting:
Ok. Now open your Program.cs file and replace your code with this little piece of source-code, to test if we can create a queue and send a message using our local (on-premise) version of the Service Bus:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.ServiceBus;
using Microsoft.ServiceBus.Messaging;
namespace SBOnPremSample
{
class Program
{
static void Main(string[] args)
{
NamespaceManager nsManager = NamespaceManager.Create();
if (nsManager != null)
{
Console.WriteLine("Hurray! We got access to our local SB installation!");
if (nsManager.QueueExists("Test"))
{
nsManager.DeleteQueue("Test");
}
nsManager.CreateQueue("Test");
QueueClient qCl = QueueClient.Create("Test");
BrokeredMessage bMsg = new BrokeredMessage("That's freakin' awesome! I am doing this locally!");
qCl.Send(bMsg);
BrokeredMessage rcvMsg = qCl.Receive(TimeSpan.FromSeconds(10.0));
if(rcvMsg != null)
{
var content = rcvMsg.GetBody<string>();
Console.WriteLine("Local SB Message {0}",content);
}
qCl.Close();
}
Console.WriteLine("Press any key to exit....");
Console.Read();
}
}
}
That’s really awesome! We have our own local Service Bus instance, that can be used for local dev and testing!