Provision Linux compute nodes in Batch pools

05/22/2017

10 minutes to read

Contributors

In this article

You can use Azure Batch to run parallel compute workloads on both Linux and Windows virtual machines. This article details how to create pools of Linux compute nodes in the Batch service by using both the Batch Python and Batch .NET client libraries.

Note

Application packages are supported on all Batch pools created after 5 July 2017. They are supported on Batch pools created between 10 March 2016 and 5 July 2017 only if the pool was created using a Cloud Service configuration. Batch pools created prior to 10 March 2016 do not support application packages. For more information about using application packages to deploy your applications to your Batch nodes, see Deploy applications to compute nodes with Batch application packages.

Virtual machine configuration

When you create a pool of compute nodes in Batch, you have two options from which to select the node size and operating system: Cloud Services Configuration and Virtual Machine Configuration.

Cloud Services Configuration provides Windows compute nodes only. Available compute node sizes are listed in Sizes for Cloud Services, and available operating systems are listed in the Azure Guest OS releases and SDK compatibility matrix. When you create a pool that contains Azure Cloud Services nodes, you specify the node size and the OS family, which are described in the previously mentioned articles. For pools of Windows compute nodes, Cloud Services is most commonly used.

Virtual Machine Configuration provides both Linux and Windows images for compute nodes. Available compute node sizes are listed in Sizes for virtual machines in Azure (Linux) and Sizes for virtual machines in Azure (Windows). When you create a pool that contains Virtual Machine Configuration nodes, you must specify the size of the nodes, the virtual machine image reference, and the Batch node agent SKU to be installed on the nodes.

Node agent SKU

The Batch node agent is a program that runs on each node in the pool and provides the command-and-control interface between the node and the Batch service. There are different implementations of the node agent, known as SKUs, for different operating systems. Essentially, when you create a Virtual Machine Configuration, you first specify the virtual machine image reference, and then you specify the node agent to install on the image. Typically, each node agent SKU is compatible with multiple virtual machine images. Here are a few examples of node agent SKUs:

batch.node.ubuntu 14.04

batch.node.centos 7

batch.node.windows amd64

Important

Not all virtual machine images that are available in the Marketplace are compatible with the currently available Batch node agents. Use the Batch SDKs to list the available node agent SKUs and the virtual machine images with which they are compatible. See the List of Virtual Machine images later in this article for more information and examples of how to retrieve a list of valid images at runtime.

This snippet creates an ImageReference explicitly and specifies each of its properties (publisher, offer, SKU, version). In production code, however, we recommend that you use the list_node_agent_skus method to determine and select from the available image and node agent SKU combinations at runtime.

As mentioned previously, we recommend that instead of creating the ImageReference explicitly, you use the list_node_agent_skus method to dynamically select from the currently supported node agent/Marketplace image combinations. The following Python snippet shows how to use this method.

# Get the list of node agents from the Batch service
nodeagents = client.account.list_node_agent_skus()
# Obtain the desired node agent
ubuntu1404agent = next(agent for agent in nodeagents if "ubuntu 14.04" in agent.id)
# Pick the first image reference from the list of verified references
ir = ubuntu1404agent.verified_image_references[0]
# Create the VirtualMachineConfiguration, specifying the VM image
# reference and the Batch node agent to be installed on the node.
vmc = batchmodels.VirtualMachineConfiguration(
image_reference = ir,
node_agent_sku_id = ubuntu1404agent.id)

Create a Linux pool: Batch .NET

The following code snippet uses the PoolOperations.ListNodeAgentSkus method to select from the list of currently supported Marketplace image and node agent SKU combinations. This technique is desirable because the list of supported combinations may change from time to time. Most commonly, supported combinations are added.

Although the previous snippet uses the PoolOperations.ListNodeAgentSkus method to dynamically list and select from supported image and node agent SKU combinations (recommended), you can also configure an ImageReference explicitly:

List of virtual machine images

The following table lists the Marketplace virtual machine images that are compatible with the available Batch node agents when this article was last updated. It is important to note that this list is not definitive because images and node agents may be added or removed at any time. We recommend that your Batch applications and services always use list_node_agent_skus (Python) and ListNodeAgentSkus (Batch .NET) to determine and select from the currently available SKUs.

Warning

The following list may change at any time. Always use the list node agent SKU methods available in the Batch APIs to list the compatible virtual machine and node agent SKUs when you run your Batch jobs.

Publisher

Offer

Image SKU

Version

Node agent SKU ID

Canonical

UbuntuServer

14.04.5-LTS

latest

batch.node.ubuntu 14.04

Canonical

UbuntuServer

16.04.0-LTS

latest

batch.node.ubuntu 16.04

Credativ

Debian

8

latest

batch.node.debian 8

OpenLogic

CentOS

7.0

latest

batch.node.centos 7

OpenLogic

CentOS

7.1

latest

batch.node.centos 7

OpenLogic

CentOS-HPC

7.1

latest

batch.node.centos 7

OpenLogic

CentOS

7.2

latest

batch.node.centos 7

Oracle

Oracle-Linux

7.0

latest

batch.node.centos 7

Oracle

Oracle-Linux

7.2

latest

batch.node.centos 7

SUSE

openSUSE

13.2

latest

batch.node.opensuse 13.2

SUSE

openSUSE-Leap

42.1

latest

batch.node.opensuse 42.1

SUSE

SLES

12-SP1

latest

batch.node.opensuse 42.1

SUSE

SLES-HPC

12-SP1

latest

batch.node.opensuse 42.1

microsoft-ads

linux-data-science-vm

linuxdsvm

latest

batch.node.centos 7

microsoft-ads

standard-data-science-vm

standard-data-science-vm

latest

batch.node.windows amd64

MicrosoftWindowsServer

WindowsServer

2008-R2-SP1

latest

batch.node.windows amd64

MicrosoftWindowsServer

WindowsServer

2012-Datacenter

latest

batch.node.windows amd64

MicrosoftWindowsServer

WindowsServer

2012-R2-Datacenter

latest

batch.node.windows amd64

MicrosoftWindowsServer

WindowsServer

2016-Datacenter

latest

batch.node.windows amd64

MicrosoftWindowsServer

WindowsServer

2016-Datacenter-with-Containers

latest

batch.node.windows amd64

Connect to Linux nodes using SSH

During development or while troubleshooting, you may find it necessary to sign in to the nodes in your pool. Unlike Windows compute nodes, you cannot use Remote Desktop Protocol (RDP) to connect to Linux nodes. Instead, the Batch service enables SSH access on each node for remote connection.

The following Python code snippet creates a user on each node in a pool, which is required for remote connection. It then prints the secure shell (SSH) connection information for each node.

Instead of a password, you can specify an SSH public key when you create a user on a node. In the Python SDK, use the ssh_public_key parameter on ComputeNodeUser. In .NET, use the ComputeNodeUser.SshPublicKey property.

Pricing

Azure Batch is built on Azure Cloud Services and Azure Virtual Machines technology. The Batch service itself is offered at no cost, which means you are charged only for the compute resources that your Batch solutions consume. When you choose Cloud Services Configuration, you are charged based on the Cloud Services pricing structure. When you choose Virtual Machine Configuration, you are charged based on the Virtual Machines pricing structure.

If you deploy applications to your Batch nodes using application packages, you are also charged for the Azure Storage resources that your application packages consume. In general, the Azure Storage costs are minimal.

Batch Python code samples

The Python code samples in the azure-batch-samples repository on GitHub contain scripts that show you how to perform common Batch operations, such as pool, job, and task creation. The README that accompanies the Python samples has details about how to install the required packages.

Batch forum

The Azure Batch Forum on MSDN is a great place to discuss Batch and ask questions about the service. Read helpful "pinned" posts, and post your questions as they arise while you build your Batch solutions.