How to: Debug Windows containers in Azure Service Fabric using Visual Studio 2017
With Visual Studio 2017 Update 7 (15.7), you can debug .NET applications in containers as Service Fabric services. This article shows you how to configure your environment and then debug a .NET application in a container running in a local Service Fabric cluster.
- On Windows 10, follow this quickstart to Configure Windows 10 to run Windows containers
- On Windows Server 2016, follow this quickstart to Configure Windows 2016 to run Windows containers
- Set up your local Service Fabric environment by following Prepare your development environment on Windows
Configure your developer environment to debug containers
Make sure the Docker for Window service is running before proceeding with the next step.
In order to support DNS resolution between containers, you will have to set up your local development cluster, using the machine name. These steps are also necessary if you want to address services through the reverse proxy.
Open PowerShell as administrator
Navigate to the SDK Cluster setup folder, typically
C:\Program Files\Microsoft SDKs\Service Fabric\ClusterSetup.
Run the script
C:\Program Files\Microsoft SDKs\Service Fabric\ClusterSetup\DevClusterSetup.ps1
You can use the
-CreateOneNodeClusterto setup a one-node cluster. The default will create a local five-node cluster.
To learn more about the DNS Service in Service Fabric, see DNS Service in Azure Service Fabric. To learn more about using Service Fabric reverse proxy from services running in a container, see Reverse proxy special handling for services running in containers.
Known limitations when debugging containers in Service Fabric
Below is a list of known limitations with debugging containers in Service Fabric and possible resolutions:
- Using localhost for ClusterFQDNorIP will not support DNS resolution in containers.
- Resolution: Set up the local cluster using machine name (see above)
- Running Windows10 in a Virtual Machine will not get DNS reply back to the container.
- Resolution: Disable UDP checksum offload for IPv4 on the Virtual Machines NIC
- Please note this will degrade networking performance on the machine.
- Resolving services in same application using DNS service name does not work on Windows10, if the application was deployed using Docker Compose
- Resolution: Use servicename.applicationname to resolve service endpoints
- If using IP-address for ClusterFQDNorIP, changing primary IP on the host will break DNS functionality.
- Resolution: Recreate the cluster using the new primary IP on the host or use machine name. This is by design.
- If the FQDN the cluster was created with is not resolvable on the network, DNS will fail.
- Resolution: Recreate the local cluster using the primary IP of the host. This is by design.
- When debugging a container, docker logs will only be available in the Visual Studio output window, not through Service Fabric APIs, including Service Fabric Explorer
Debug a .NET application running in docker containers on Service Fabric
Run Visual Studio as an administrator.
Open an existing .NET application or create a new one.
Right-click the project and select Add -> Container Orchestrator Support -> Service Fabric
Press F5 to start debugging the application.
Visual Studio supports console and ASP.NET project types for .NET and .NET Core.
To learn more about the capabilities of Service Fabric and containers, please follow this link: Service Fabric containers overview.
Send feedback about: