Azure Batch walkthrough
This guide details how to set up more complex Azure Batch compute environments with Seqera Platform. It begins with the simplest possible setup before adding complexity, therefore it is designed to be performed stepwise.
Seqera Platform now provisions most advanced Azure Batch topologies natively through Batch Forge, including separate head and worker pools, dedicated head job resources, autoscaling, Entra authentication, and private networking. This walkthrough covers the native Batch Forge path, then the cases that still require manual Azure configuration, such as low-priority (spot) nodes and pre-existing pools.
For a field-by-field reference of every compute environment option, see Azure Batch.
- An Azure account with sufficient permissions to create resources.
- Azure CLI
- Seqera Platform CLI
Set up Azure Batch
In the Azure Portal:
- Create an Azure Storage account with the default settings.
- In the Azure Storage account, add a single blob container called
work. This is the Nextflow working directory. - Create a new Azure Batch account. Use Batch Managed for now, with the default settings. Use the same region as your Storage account and attach the Storage account to the Batch account when prompted.
- On the Azure Batch page, select Quotas.
- Select Request Quota Increase.
- For Quota Type, select Batch, then select Next.
- Select Enter Details, then choose the Location as the region of your Batch account.
- Select EDv5 Series.
- Select Spot/low-priority vCPUS (all Series).
- Select Active jobs and job schedules per Batch account.
- Select Pools per Batch account.
Increase each value to a minimum of the following:
- EDv5 Series: 192
- Active jobs and job schedules per Batch account: 100
- Pools per Batch account: 50
- Spot/low-priority vCPUS (all Series): 192
Set up Seqera Cloud
In Seqera Cloud:
- Create a new account.
- Create a new organization and workspace.
- Add a GitHub credential to the workspace to prevent API rate-limiting issues with GitHub.
Part 1. Azure Batch with Batch Forge
Batch Forge creates and manages the Azure Batch pools for you. By default it creates separate pools for the Nextflow head job and compute tasks (named tower-pool-{envId}-head and tower-pool-{envId}-worker), so the head node does not compete with tasks for resources and each pool can be sized independently. Both pools autoscale based on the number of waiting tasks.
First, add the Azure Batch account credentials to Seqera Platform:
- In the Azure portal, go to the Batch account you created and note the Batch account name and region.
- Go to the Keys tab to find the primary access keys for the Batch account and Storage account.
- In your Seqera Platform workspace, go to the Credentials tab and select Add credentials.
- Enter a credential name such as
azure-keysand select Azure from the Provider drop-down. - Enter the Batch account name and key, and Storage account name and key.
- Select Create to save the credentials.
Next, create a compute environment with Batch Forge:
- Go to the Compute Environments tab and select Add Compute Environment.
- Enter a name such as
azure-batch-forge. - Select Azure Batch from the Provider drop-down.
- Select your
azure-keyscredentials. - Select the Region of your Batch account.
- Select the
az://workcontainer in your Storage account. - Set Config mode to Batch Forge.
- For VMs type, select
standard_e2ds_v5. - For VMs count, select 4.
- Enable Autoscale and Dispose resources.
- (Optional) Under Head job resources, set a separate Head VM type, Head job CPUs, and Head job memory to size the head node independently of the compute tasks.
- All other options can be left default. Select Create to save the compute environment.
To reduce pipeline latency, disable Autoscale on the head pool so a head node stays running (fixed scale). This incurs additional cost for the always-on node but improves response time, which is more noticeable on larger production pipelines.
Add the nextflow-hello pipeline to your workspace:
Add a pipeline from your workspace Launchpad with the following settings:
- Select your Azure Batch compute environment from the drop-down.
- For Pipeline to launch, enter
https://github.com/nextflow-io/hello. - For Work directory, enter a subdirectory in the
az://workcontainer in your Storage account.
Select Launch next to the pipeline name in your workspace Launchpad to complete the launch form and launch the workflow.
Part 2. Use low-priority (spot) worker nodes
Advantages:
- Low-priority (spot) VMs are cheaper than dedicated VMs.
- You keep the head node on dedicated VMs while running the cheaper work on the worker pool.
Disadvantages:
- Spot and low-priority nodes can be preempted, which can cause the pipeline to fail.
Batch Forge provisions dedicated nodes only. To use low-priority (spot) nodes for the compute tasks, edit the autoscale formula of the Forge-created worker pool to target low-priority nodes:
- In the Azure Portal, go to the Batch account you created earlier.
- Go to the Pools tab and find the worker pool called
tower-pool-{envId}-worker, where{envId}is the compute environment ID (shown at the top of the compute environment page in Seqera). - Select Scale.
- In the autoscale formula, find the line that starts with
$TargetDedicatedNodesand change it to$TargetLowPriorityNodes. - Select Evaluate, then Save.
The worker pool now provisions low-priority VMs, while the head pool continues to use dedicated VMs. Launch the nextflow-hello pipeline again to run the compute tasks on low-priority nodes.
Part 3. Use Entra authentication
Advantages:
- No keys or short access tokens are exchanged, increasing security.
- A service principal can have very granular permissions, so you can grant it only the permissions it needs.
- Managed identities can be scoped to a specific resource, so the Nextflow head job has very restricted permissions.
- Different managed identities can have different permissions, so different compute environments can have different scoped permissions.
Instead of access keys, Seqera can authenticate to Azure Batch and Storage using an Entra service principal, and Nextflow can authenticate using a managed identity. Batch Forge configures the pool identity for you. You create the service principal and managed identity in Azure, then select them in the compute environment form.
See Microsoft Entra in the Nextflow documentation for more information.
Create a service principal for Seqera to use for authentication
- Create an Azure service principal.
- Assign roles to the service principal.
- Get the Service Principal ID, Tenant ID, and Client Secret.
- Add to Seqera credentials.
In Seqera:
- Add new credentials with the name
entra-keysand select the Azure Provider. - Add the Service Principal ID, Tenant ID and Client Secret.
- Select Create to save the credentials.
Create a managed identity for Nextflow to use for authentication
In the Azure Portal:
- Create a managed identity
- Assign the relevant roles to the managed identity. See Required role assignments for Nextflow requirements.
- Note the managed identity client ID for later.
In Seqera:
- Add a new Batch Forge compute environment named
entra-miand select the Azure Batch Provider type. - For Credentials, select the
entra-keysservice principal credentials. - For Location, select the same region as your Batch account.
- Under the managed identity fields, enter the client ID of the managed identity created earlier.
- Configure the remaining fields as in Part 1.
Duplicate the nextflow-hello pipeline, save it as hello-world-entra-mi, and select the new compute environment.
Select Launch next to the hello-world-entra-mi pipeline in your workspace Launchpad to complete the launch form and launch the workflow. The pipeline runs as before, but uses the managed identity to authenticate to Azure Batch and Storage. No keys are exchanged.
You can also use User Subscription mode instead of Batch Managed here, but this is beyond the scope of this tutorial.
Part 4. Attach the pool to a virtual network (VNet)
Advantages:
- Security can be increased by restricting the virtual network subnet.
- Exchange of data can be faster and cheaper than routing over the public internet.
To connect the Batch pool nodes to a private Azure VNet, enter a Subnet ID when creating the Batch Forge compute environment. Batch Forge attaches the subnet to both the head and worker pools, so worker nodes inherit the same networking automatically.
VNet/subnet configuration requires Entra credentials. The Subnet ID field is only available when Entra credentials are selected. See Entra service principal and managed identity in the Azure Batch reference.
-
Add a new Batch Forge compute environment named
azure-batch-vnetand select the Azure Batch Provider type. -
For Credentials, select the
entra-keysservice principal credentials. -
For Location, select the same region as your Batch account.
-
For Subnet ID, enter the full Azure ARM subnet resource ID:
/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Network/virtualNetworks/{vnetName}/subnets/{subnetName} -
Configure the remaining fields as in Part 1.
Duplicate the nextflow-hello pipeline, save it as hello-world-vnet, and select the new compute environment. Select Launch to run the workflow on the pool attached to the VNet.
Advanced. Use a pre-existing Azure Batch pool
Some scenarios still require a manually created pool, such as custom VM images or Azure Batch features that Batch Forge does not expose. In these cases, create the pool yourself and select it in a Manual compute environment.
See Create a Nextflow-compatible Azure Batch pool in the Azure Batch reference for the full pool configuration (identity, OS image, autoscale formula, start task, and networking), then create a Manual compute environment that points at the pool name.
The Nextflow autopool feature (azure.batch.autoPoolMode and azure.batch.allowPoolCreation) is deprecated and not used by Seqera Platform. Use the Batch Forge separate-pool model described above instead.
Clear up resources
Once you have completed setup and workflow execution, you can delete the pipelines and compute environments from Seqera.
In Azure, you can delete the Batch account, which will delete all pools, jobs, and tasks. You can then delete the Storage account.
If you wish to keep the Azure resources, you can remove each pool within a Batch account and mark any active jobs as terminated to free up any quotas on your Azure Batch account.