BTARN and TLS Protocol

As part of a blog entry back in April I mentioned a problem some folks were having with RNIFSend pages. Here’s the blog link (check the bottom of the post).

http://blogs.msdn.com/b/biztalkcpr/archive/2009/09/04/troubleshooting-btarn-web-pages-and-more-on-btarn-x64.aspx 

At the time I could not confirm the problem can happen with Windows 03 (x32 and x64). The issue has been confirmed with the latest service packs/security updates for Windows 03 SP2. The send page will attempt to use TLS first (not SSL 3.0). Also, immediately after the “Client Hello” in the network trace the conversation shows “Encrypted Alert” and the communication ends.

If web page tracing has been added it will show “Underlying connection was closed”. The fix is the same. Add a line of code to the RNIFSend page to force the use of SSL 3.0.

ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3; (add this)

//rest of the code

HttpWebRequest outerRequest = null;

ErrorLevel level = ErrorLevel.ProxyToOuterFailure;

The location is not critical. Keeping it close to the other connection related code is a good idea. Copy the existing virtual folders as a backup. Deploy the new send page and test.

Unit Testing Workflows-Testing Activities with Bookmarks

In my previous post I showed you how to test simple activities using WorkflowInvoker.  While this is a great way to test simple activities it does have limitations.  The MSDN documentation states

WorkflowInvoker does not allow instance control such as persisting, unloading, or resuming bookmarks. If instance control is desired, use WorkflowApplication instead.

In this post I’ll show you how you can use WorkflowTestHelper to test an activity that uses Bookmarks.

Watch endpoint.tv – How To Unit Test Workflows
Download Workflow Test Helper (including this sample code) from MSDN Code Gallery

What is a Bookmark?

Suppose you have an activity that needs some data.  Perhaps you want to ask the user for something or you need the host environment to do something that the activity itself cannot do.  In this example I’m going to create a ReadLine activity.  I could call Console.ReadLine from my activity but that is a bad practice because it blocks the Activity Scheduler thread.  As an activity author you should never block the thread but instead should use bookmarks.

Here is my ReadLine Activity

public sealed class ReadLine : NativeActivity<string>

{
private BookmarkCallback _readCompleteCallback;

[RequiredArgument]
public InArgument<string> BookmarkName { get; set; }

protected override bool CanInduceIdle
{
get { return true; }
}

public BookmarkCallback ReadCompleteCallback
{
get { return _readCompleteCallback ?? (_readCompleteCallback = new BookmarkCallback(OnReadComplete)); }
}

protected override void Execute(NativeActivityContext context)
{
// Inform the host that this activity needs data and wait for the callback
context.CreateBookmark(BookmarkName.Get(context), ReadCompleteCallback);
}

private void OnReadComplete(NativeActivityContext context, Bookmark bookmark, object state)
{
// Store the value returned by the host
context.SetValue(Result, state as string);
}
}

Now I can use this activity in a workflow that requires input from the user

If you try to run this workflow with WorkflowInvoker your app will hang.  Instead you have to use WorkflowApplication and deal with the bookmarks in the host application.  I’ve included the host application with this post so you can see the necessary code.

How To Test This Workflow

Testing an activity like this can be tricky.  In the WorkflowTestHelper library I’ve added a class that makes it much easier.  The class is called WorkflowApplicationTest<T>.  This class will create and manage the WorkflowApplication and handle all the events for you resulting in some very clean test code.

[TestMethod]

public void ShouldOutputGreeting()
{
// Arrange
const string expectedFirstName = "Test";
const string expectedLastName = "User";
var expectedGreeting = string.Format("Hello {0} {1}", expectedFirstName, expectedLastName);
var sut = WorkflowApplicationTest.Create(new TestReadLine());

// Act

// Run the workflow
sut.TestActivity();

// Wait for the first idle event - prompt for First Name
// will return false if the activity does not go idle within the
// timeout (default 1 sec)
Assert.IsTrue(sut.WaitForIdleEvent());

// Should have a bookmark named "FirstName"
Assert.IsTrue(sut.Bookmarks.Contains("FirstName"));

Assert.AreEqual(BookmarkResumptionResult.Success,
sut.TestWorkflowApplication.ResumeBookmark("FirstName", expectedFirstName));

// Wait for the second idle event - prompt for Last Name
Assert.IsTrue(sut.WaitForIdleEvent());

// Should have a bookmark named "LastName"
Assert.IsTrue(sut.Bookmarks.Contains("LastName"));

Assert.AreEqual(BookmarkResumptionResult.Success,
sut.TestWorkflowApplication.ResumeBookmark("LastName", expectedLastName));

// Wait for the workflow to complete
Assert.IsTrue(sut.WaitForCompletedEvent());

// Assert
// WorkflowApplicationTest.TextLines returns an array of strings
// that contains strings written by the WriteLine activity
Assert.AreEqual(4, sut.TextLines.Length);
Assert.AreEqual(expectedGreeting, sut.TextLines[2]);
}

Give It A Try

I’ve just posted WorkflowTestHelper v1.3 which now provides better support for testing with Bookmarks and capturing output of WriteLine activities.  Give it a try and let me know what you think.

Applied Architecture Patterns on the Microsoft Platform Now Available on Amazon.com

Applied Architecture Patterns on the Microsoft Platform Now Available on Amazon.com

I am pleased to announce my book is now available for immediate delivery on Amazon.com!

The book is called “Applied Architecture Patterns on the Microsoft Platform” published by Packt Publishing.

Applied Architecture Patterns on the Microsoft Platform

This book is a detailed scenario-driven approach to architecting systems using Microsoft technologies covering BizTalk Server, .Net 4, AppFabric, Azure, SQL, and more.  We dive into 13 real-life style scenarios and talk about various technology options available to solve the problem.  One technology is selected for each scenario and a detailed walk-through it given.

The four other co-authors and I have been working on this book for nearly a year.  We hope you enjoy it!

And  The New Book is Released

And The New Book is Released

Nearly 16 months after a book idea was born, the journey is now complete. Today, you can find our book, Applied Architecture Patterns on the Microsoft Platform, in stock at Amazon.com and for purchase and download at the Packt Publishing site. I am currently in Stockholm along with co-authors Stephen Thomas and Ewan Fairweather delivering […]

endpoint.tv – The FlowChart Activity

In this episode, we discuss the FlowChart activity. Sure, it looks simple—and in fact it is. Watch as Leon Welicki explains how you can use the new WF4 Flowchart activity to build workflows.

The sample application shown is a part of the WF4 SDK Samples.

Ron Jacobs
blog        http://blogs.msdn.com/rjacobs
twitter    @ronljacobs

What do you want to see on endpoint.tv?

Introducing the Microsoft Web Farm Framework

Introducing the Microsoft Web Farm Framework

Last month we released a beta of the Microsoft Web Farm Framework. The Microsoft Web Farm Framework is a free product we are shipping that enables you to easily provision and mange a farm of web servers.  It enables you to automate the installation and configuration of platform components across the server farm, and enables you to automatically synchronize and deploy ASP.NET applications across them.  It also supports integration with load balancers – and enables you to automate updates across your servers so that your site/application is never down or unavailable to customers (it can automatically pull servers one-at-a-time out of the load balancer rotation, update them, and then inject them back into rotation).

The Microsoft Web Farm Framework is a 1 MB download, and can be installed on IIS 7 and above. It is available for free. You can download the first preview of this beta here: x86 / x64.

Why Is the Web Farm Framework Useful?

Running a web farm requires you to provision and manage multiple servers.  Running a web farm involves (among other things):

  1. Installing IIS, ASP.NET and all of the core platform components on the servers
  2. Installing and configuring custom IIS modules (UrlRewite, Media Services, etc)
  3. Configuring IIS Application Pools and Sites
  4. Setting up SSL certificates for things like HTTPs endpoints
  5. Copying and synchronizing the appropriate sites/applications/content across the various boxes
  6. Coordinating the various web servers with a HTTP load balancer to distribute load

Administrators and developers managing a web farm today often perform a lot of manual steps to do the above (which is error prone and dangerous), or write a lot of custom scripts to automate it (which is time consuming and hard).  Adding new servers or making configuring or application changes can often be painful and time-consuming.

The Microsoft Web Farm Framework makes this process much easier, and enables you to manage web farms in a completely automated way. Best of all, it is really easy to setup and use.

Using Web Farm Framework to Provision and Scale a Web Farm

The Microsoft Web Farm Framework enables you to easily define a “Server Farm” that you can add any number of servers into.  Servers participating in the “Server Farm” will then be automatically updated, provisioned and managed by the Web Farm Framework. 

What this means is that you can install IIS (including modules like UrlRewrite, Media Services, etc), ASP.NET, and custom SSL certificates once on a primary server – and then the Web Farm Framework will automatically replicate and provision the exact same configuration across all of the other web servers in the farm (no manual or additional steps required). 

You can then create and configure an IIS Application Pool and a new Site and Application once on a primary server – and the Web Farm Framework will automatically replicate and provision the settings to all of the other web servers in the farm.  You can then copy/deploy an ASP.NET application once on the primary server – and the Web Farm Framework will automatically replicate and provision the changes to all of the web servers in the farm (no manual or additional steps required).

The Web Farm Framework eliminates the need to manually install/manage things across a cluster of machines.  It handles all of the provisioning and deployment for you in a completely automated way.

Load Balancer Integration

In addition to making it easy to provision/deploy servers and applications, the Web Farm Framework also includes load balancer integration. Specifically, the Web Farm Framework can integrate with an HTTP load balancer so that as web servers in the farm are updated with changes, they can be automatically pulled out of a load balancer rotation, updated, and then added back in.  The Web Farm Framework can also optionally update the machines one at a time – so that you always have servers available to handle heavily load.  This enables you to keep your site always available during updates – without you having to write any manual scripts to control or manage the update roll-out.

The current beta of the Web Farm Framework includes built-in support for the IIS Application Request Routing (ARR) service (which supports automatic load balancing of HTTP requests across multiple machines in a web-farm).  The Web Farm Framework makes it really easy to integrate your web farm of servers with ARR for load-balancing, and includes the support to automatically pull a server out of rotation as it is being updated, and then have it added back into rotation once the update is done.

The final Web Farm Framework release will enable extensibility with other load-balancing technologies as well – enabling the same ability to automatically pull/inject servers from a load balancing rotation as they are updated.

Scenario Walkthrough: Setting up and Provisioning a Web Farm

Let’s walkthrough a simple scenario where we want to setup and manage a server farm made up of two web servers.  We’ll call these two web-servers the “DemoPrimary” and “DemoSeconday” servers.  We’ll use a third “DemoController” machine to coordinate and manage the web farm.  DemoController doesn’t technically need to be a separate machine – but makes it easier to understand the various roles in the walkthrough.

image

Installing the Web Farm Framework

We’ll begin by installing the current beta of the Microsoft Web Farm Framework using the Microsoft Web Platform Installer on our “DemoController” machine. It works with any machine that has IIS 7 (and above) installed.

Creating and Provisioning a Web Farm

Once the Microsoft Web Farm Framework is installed, you’ll find a new “Server Farm” node listed within the left-hand tree view of the IIS Admin Tool on the “DemoController” machine.  If you right-click on this “Server Farm” node you’ll see an option to “Create Server Farm”

image

Selecting this option will bring up a “Create Server Farm” dialog – and allow us to configure and setup a farm of machines that we want to manage together.

We’ll name the new server farm we want to create “DemoFarm”, and indicate that we want to automatically provision all of the servers in the farm (by checking the “Provision Server Farm” option in the dialog).  We’ll also indicate that we want to make it available for load-balancing with the IIS Application Request Routing (ARR) load-balancer:

image

When we click the “Next” button the wizard will bring up an “Add Servers” dialog that allows us to specify the servers we want to have in the web farm. We can add any number of servers at the time of first setup.  We can also come back and add more servers to the server farm later.  When you add more servers to the farm later, the Web Farm Framework will automatically provision and update them to have the latest changes (allowing us to easily add additional capacity at any time).

For this walkthrough we’ll add our two servers – “DemoPrimary” and “DemoSeconday” to our server farm.  We’ll start by adding the “DemoPrimary” machine.  We’ll select the “Primary Server” checkbox in the dialog – which will indicate that its role is to act as the primary server that the other servers in the farm will replicate:

image

Once we add the “DemoPrimary” server we’ll also add the “DemoSecondary” server to the farm.  

image

When we click the “Finish” button the Web Farm Framework will connect to the servers we’ve added to the farm and automatically provision the appropriate management software on them for us (no need for us to install anything manually – the web farm framework will automatically install its management service on the target machines).  Clicking the “servers” tab in the “Server Farm” node in the IIS Admin tool always provides an up-to-date view of the provisioning and deployment operations happening across all the farm (you can also filter it by individual server if you want):

image

At this point we are completely done configuring our web farm.  We now have a working, automated, web farm enabled. 

We have setup our web farm for automated provisioning and synchronization/replication.  If we were to create sites or application pools on the “DemoPrimary” web server, or install or update applications on it, they would be automatically replicated/synchronized on the “DemoSeconday” server.  This is also true for any web platform components we install. We do not need to manually install or configure anything on any additional secondary servers we add to the farm. The Web Farm Framework will automate keeping them synchronized with our Primary Server – and enable us to manage the entire farm of servers as a group.

Managing a Web Farm

Clicking on the “DemoFarm” sub-node within the IIS Admin Tool enables us to manage, track and configure our server farm:

image

The view above combines the settings of both the Web Farm Framework, as well as the Application Request Routing capability of IIS (which adds load-balancing and cache management support). 

You can click on the “Servers” sub-node of “DemoFarm” to see how the servers within the web farm are doing, if they are currently performing any deployment/provisioning operations, and if any errors have occurred on them.  If any provisioning/deployment errors have occurred anywhere in the farm, you can drill down to detailed tracing to see what they were.

Platform Provisioning using the Web Farm Framework

The Web Farm Framework enables you to easily add more platform components to your server-farm machines at anytime by using the “Platform Provisioning” icon above.  This integrates our Microsoft Web Platform Installer technology, and enables you to easily install platform components on all of your web farm machines.  It also allows you to easily check for any version differences in platform components between your primary and secondary machines in the farm.

Below we can add “ASP.NET MVC 2” to the server farm configuration:

image

Notice that the “Enable Platform Provisioning” checkbox is selected – this will ensure that products we add to the list are automatically provisioned across all of the servers in the farm.  By default the Web Farm Framework will update each server in the farm one-by-one, and take it out of the load-balancer rotation while it does it, and then automatically add it back into the load balancer rotation once it is complete (ensuring your site never goes down).  The Web Farm Framework will even handle scenarios where a server reboot is necessary – and complete the provisioning step and re-add the server back to rotation once the reboot is done.

Application Provisioning using the Web Farm Framework

The Web Farm Framework enables you to easily deploy and replicate/synchronize Sites, Applications, Content and Settings across a Web Farm.  It uses the Microsoft Web Deploy technology to enable application deployment in an automated fashion (no manual steps required for both adding new applications and updating existing ones).

By default, the Web Farm Framework will automatically synchronize the Sites, Applications, Content and Settings we’ve configured on our “DemoPrimary” server to our “DemoSeconday” server (and any other web-servers we later add to the server farm).  We can use any application deployment mechanism we want to create and copy the application up onto the “DemoPrimary” machine.  This means we could use FTP/SFTP or the Microsoft Web Deploy framework to deploy the sites/content to “DemoPrimary”.  It also means any web applications that use a custom MSI installer or custom batch-file/powershell script to deploy applications onto our “DemoPrimary” will also work.

The benefit of supporting any deployment mechanism is that you can leverage any of the existing application/site/app-pool deployment approaches you already use with IIS to update your primary server – and then use the Web Farm Framework to automatically have the installed application/site/content automatically replicated across the other machines in the web-farm.  This makes it easier to integrate the Microsoft Web Farm Framework into your existing deployment workflows.

If you click the “Application Provisioning” icon in the IIS admin tool you can specify the synchronization frequency with which you want the servers in the web-farm to check for application/site/content updates (by default it happens every 30 seconds). 

You can also optionally specify any additional Microsoft Web Deploy providers you want to use to copy custom settings across machines in the web-farm.  For example, if you want a custom registry setting copied – you can enable that.  If you want to set a custom NTFS security ACL – you can enable that.  If you want to copy/register a COM object – you can enable that.  If you’ve built your own custom “FooProvider” to do some custom stuff – you can enable that too.

image

When you make changes or updates to applications on your primary server, the Web Farm Framework will automatically synchronize and copy them to the other servers in the server-farm for you.  No manual steps required.

Running Operations and Managing the Server Farm

The Web Farm Framework includes some built-in management infrastructure that allows you to check on the health of a server, and track its status.  You can also use a product like Microsoft System Center (or any custom monitoring software or scripts you have) to monitor the server status within the farm.  If you are using ARR for load-balancing, it also supports a bunch of monitoring and load-balancing settings that allow you to dynamically shift loads across the farm based on server performance and available utilization.

The Web Farm Framework also supports a “Server Farm Operations” task link within the IIS Admin Tool (on the right-hand side of the tool) that you can use to easily run commands across the server farm.  For example, we could flash a command to all the servers in the web farm to ensure that a “MyCustomWindowsService” is started and running using the screen below:

image

You can also fully automate tasks using PowerShell scripts.

Summary

You can take advantage of the Microsoft Web Farm Framework to simplify the provisioning and deployment of your web server infrastructure – both the servers themselves, as well as the web applications and sites you run on top of them.  It enables a smoother continuous deployment workflow.  It also makes it easy to seamlessly scale your infrastructure by adding servers to it without additional management overhead.  Best of all it is available at no extra cost and works with all editions of Windows Server.

Click here to learn more about the Microsoft Web Farm Framework. You can download a beta of the Microsoft Web Farm Framework here.

Hope this helps,

Scott

P.S. In addition to blogging, I am also now using Twitter for quick updates and to share links. Follow me at: twitter.com/scottgu

AppFabric Reference Implementation: Managing the LifeCycle of a WorkFlow Service

 We have new premium content for AppFabric server. This sample and the document are just what customers need to start using AppFabric Server to manage a .NET4 WCF Workflow service. Customers have been asking about versioning and security, and those are two features of the sample. The sample is released via the TechNet Wiki and this gives the community the opportuntiy to expand the solution and fix the code and doc as needed.

On the wiki:

http://social.technet.microsoft.com/wiki/contents/articles/appfabric-reference-implementation-managing-the-lifecycle-of-a-workflow-service.aspx

 

The Visual Studio solution is at MSDN Code Gallery

http://code.msdn.microsoft.com/AppFabricRefImpl

Namaste!

Synopsis

The Starter Kit is designed to be a reference implementation; a secondary objective is to provide sample code that developers could use to manage the life-cycle of the .NET 4 Workflow Services on Windows Server AppFabric. It does this by providing a complete client-side application that enables design of .NET Windows Workflow Services outside of the Visual Studio IDE; deployment of these Services from the Client to the AppFabric server; versioning of the deployed service definitions; and finally management of Service Instances in a custom monitoring console. Additionally this document provides the instructions for setup, a tour of the features and implementation highlights.

The features enabled via the starter kit are:

       Re-hosting the designer to provide a design experience that’s fully integrated into the line-of-business application  

       Handling deployment from design tool to the Windows Server AppFabric

       Managing the published versions of the customer’s workflow designs

       Securing access to designed workflows

       Executing and controlling instances of custom workflows from the product

       Reporting on business metrics collected from a workflow service instance’s execution

       Troubleshooting and diagnosing issues.

UDDI standard is a niche technology. Why?

New standard the UDDI was announced several years ago [see the history in Wikipedia]. The UDDI future was promising. I was sure for that. I thought, the future is for Web-services [WS], and it is. Isn’t that mean, we need services to search Web-services in internet, some Registries/Catalogs of the Web-services?
How we could find the WS in internet? Google Search was not effective in this; it is still not effective now. By any means, the UDDI idea should win; all WS-s should work with UDDI Registers. There was no way to live without UDDI. WS-s should be everywhere and to find the right one we should use the UDDI. We thought so.
The big companies started to invest in UDDI: IBM, Microsoft, SAP, and more. Smart people were writing UDDI standard, developers were writing UDDI systems. Big companies announced about public UDDI Registers in internet. Future was without clouds.
What happens after this? Several years ago Microsoft, IBM closed they UDDI Registers in internet. Now there aren’t big public UDDI Registers. We have some but they are miserable. Seems, nobody wants to publish the WS-s in these Registers.
Why the UDDI Registers are not popular as Google or Yahoo Search?
This all resembles to me the “pre-google” days, while each new site must be “promoted” into the search engines. We could register a new site in some engines without problems, in some engines only with payment or registration. Then the Google was born. Google is gathering new sites by itself and automatically included them to the Google register. Explicit procedures were changed to implicit, automatic procedures.
Maybe the same was happened with the Registers for WS-s?
But what was happened, the most of the WS-s did not want to be “promoted”. Most of the WS-s are created for the limited user audience. Those users know all information about the WS, its address, its meta-information (Wsdl, Wsd-s, bindings, etc.). Moreover it is unlikely anybody outside of the circle of the trusted users could access this information.
There were other reasons that let the UDDI standard go down.
One of the reasons was the standard itself. It was not simple, nor clear, nor easy to use standard. Creators make it all-embracing (maybe creators thought so) and designed in smallest details, big and clumsy. It was popular in these years creating internet standards in such fashion; include in standards all and everything. Standards of those years were set apart as monolithic and huge. Standards tended to include all knowledge of specific area. Of course, they were not as large as monster-standards like EDI or HL7. But they were not as laconic and segmented as modern standards (for example, the family of the WS-* standards).
But the most negative factor was the fact the UDDI was substituted by other more advanced technologies. Now most of the Web-services show the meta-information on the predefined URL. All Wsdl-s, Xsd-s, and bindings are placed together with Web-service not in specialized Registers. In this way the Web-service makes itself independent, self-describing. User didn’t have to search the WS meta-information somewhere else. Users need to know only the URI (address) of the WS. It is not wise to use UDDI Registers to store only addresses. UDDI Registers are too complex, too overloaded with unused functionality for this simple task.
As a result the UDDI standard and UDDI services are now used only in small, narrow areas. For example, the UDDI service is used in the Microsoft BizTalk Server (see ESB Toolkit 2.0). Web-service Register has to be in the ESB, because the whole idea of ESB is based on principle, that user is publishing messages in ESB and the Bus knows what services should process the messages, knows all addresses, knows all format transformations.
But if we are returning to the generic case of the Web-service, all we need to know is the address of this WS.
UDDI let us find the WS by key words as it is in the Yahoo Directories. It happens this feature is not a user requirement at all.
The UDDI standard in the niche standard not universal so far.
————–
Links:
[
UDDI. Official site]
[
Why are IBM, Microsoft and SAP discontinuing the operation of the UDDI Business Registry]
[
UDDI in Microsoft]
[
BizTalk. ESB Toolkit 2.0. UDDI in BizTalk]