Tuesday, April 12, 2022

Azure @ Enterprise - WCF netNamedPipe binding inside Windows container

Recently I was into serious discussions on containerizing 15+ years old distributed applications developed using the .Net Framework and hosted in IIS web server. The first suggestion or the approach coming to all our minds is to migrate to .Net 6 and containerize using Linux containers. Nobody thinks about Windows containers. But unfortunately, we need to think about containerizing it to Windows containers. We are not going to discuss the merits and demerits of Windows containers in this post or the rationale for that thought. But one of the technical tasks that will come if we use Windows containers.

Please note this needs some basic understanding of WCF (Windows Communication Foundation)

Problem

The current system has the below characteristics

  • It uses netNamedPipeBinding to expose internal services in every IIS box. 
  • The HTTP front-facing apps and APIs consume the internal net.pipe services to get things done.
  • The internal services are also hosted inside IIS. 

If we move to Windows containers one approach to solve this is to extract the internal services and host them as independent containers and use net.tcp binding to establish communication. It is simply that the net.pipe binding only works inside the machine.

But let us see how can we have netNamedPipe services inside the same container as the front-end services and establish the communication between services using net.pipe?

Challenges

  • The base image provided by Microsoft doesn't have support for hosting net.pipe services.
  • The UI tooling is limited when we are in the container world compared to IIS in the Windows server machines. We should have a good grip on using AppCmd command for IIS management or the PowerShell modules such as WebAdministration or IISAdministration used to manage IIS.

Solution

It is nothing fancy. This will work if we get the Dockerfile right. We need to enable the netNamedPipe binding at the machine level and set the bindings and protocols at the IIS level.

I am not giving many details in this post as the repo will get more updates into the readme.md file.

Happy coding.

No comments: