Service Fabric in DevTest Lab Environments

DevTest Labs can create self-contained test environments as defined by an Azure Resource Management template. These environments can contain both IaaS resources, like virtual machines, and PaaS resources, like Service Fabric.

DevTest Lab provides the means to manage virtual machine resources defined within an environment by providing commands to control the virtual machine including the ability to start or stop the virtual machine on a schedule. With this update, DevTest Labs can now help you manage Service Fabric clusters in an environment as well. This includes starting or stopping the cluster either manually or via a schedule.

The image below shows the updated view of ‘My Virtual Machines’ with environments. This post will cover how to create an environment with a self-contained Service Fabric cluster and how to start and stop the cluster via schedules.

'My Virtual Machines' showing Service Fabric cluster in an environment

'My Virtual Machines' showing Service Fabric cluster in an environment

Creating an Environment

Service Fabric clusters must be created using the environment feature in DevTest Labs. Environments are made available by adding a repository source to the lab. See Add a Git repository to store custom artifacts and Resource Manager templates for instruction on how to add a repository source. See Create multi-VM environments and PaaS resources with Azure Resource Manager templates for an overview how to create an environment.

Each environment is defined by an Azure Resource Manager (ARM) template. Service Fabric clusters are highly configurable in ARM. If you would like to test Service Fabric in DevTest Labs, a sample environment can be found at An environment named ‘Service Fabric Lab Cluster’, as seen below, will become available when creating new lab resources. See for more details how this environment works.

'Environment to create secure Service Fabric Cluster in a Lab. Available after choosing 'Add' command in the lab.

The 'Service Fabric Lab Cluster' environment creates a 5-node 1-nodetype cluster on either Linux or Windows. You will need to provide administrator username and passwords for the virtual machine. Certificate information will also need to be provided. Use Create-ClusterCertificate.ps1 to get the needed base64 encoding of the certificate, certificate password and certificate thumbprint.
It is important to note that lab environments are self-contained within the resource group in which they are created. This means the template that defines the environment can only access resources within the newly created resource group or virtual networks configured to be used by the lab. The sample above creates all the required resources in the same resource group.

Starting and Stopping a Cluster

Once a cluster is created within the environment, you can start or stop it by clicking a command from the list of lab resources or click the commands on the menu bar for the cluster. The start command will start all nodes in a cluster. The stop command will stop all nodes in a cluster. Once a cluster is stopped, the Service Fabric cluster itself will remain in a ready state, but no nodes will be available until the start command is re-issued on the cluster in the lab.

Start, Stop and Pin to dashboard commands available in 'My Virtual Machines' view of lab resources.

'Commands available in 'My Virtual Machines' view of lab resources.


Start and Stop commands available when seeing details of cluster in a lab.

'Commands available when seeing details of cluster in a lab.

There are a few considerations to note when using a Service Fabric cluster in a test environment. The first is it may take some time for the Service Fabric cluster to fully re-hydrate after the nodes have been restarted. The second consideration regards data retention. To retain data from shutdown to startup, data must be saved on a managed disk attached to the virtual machine. There are performance implications when using an attached managed disk, so it is recommended for test environments only. If the disk used for data storage is not backed, then data will be lost when the stop command is issued on the cluster.

Configuring an Auto Startup and Auto Shutdown Schedule

Service Fabric clusters can also be started or stopped on a schedule. The experience for this is comparable to the experience for virtual machines in a lab.

To save money, by default every cluster created in a lab will auto shutdown at the time defined by the lab shutdown policy. Users can override if a cluster should be shut down or can modify the time the cluster is shut down. To do this click on the Service Fabric cluster in the list of lab resources. You will see a blade that shows the essentials of the Service Fabric cluster and the status of startup and shutdown schedules for that cluster.

To opt-in to the startup schedule, click on ‘Auto-startup’ blade. This blade will only be enabled if the lab owner has allowed chosen to allow users to auto-start their virtual machines or Service Fabric clusters.

To change settings for shutdown, click on the ‘Auto-shutdown’ blade. From this blade, you can opt-out of automatic shutdown, change the time for shutdown, or add notifications for when you cluster will be shutdown.


As you can see, you can now readily create test environments for Service Fabric clusters using DevTest Labs. Dev Test Labs allows both lab administrators and users to shutdown clusters when they not being used.

If you have any questions about DevTest Labs, please check out the MSDN forum.


clip_image004[6] Elizabeth Maher, Senior Software Engineer

Elizabeth is part of the Visual Studio and .Net engineering team focused on Visual Studio and Azure customers. She has been at Microsoft for 15 years, working on various developer technologies.

Comments (0)

Skip to main content