Install Python on a windows node using a start task with Azure Batch
Published May 16 2021 06:04 AM 11.9K Views

It is common that customers contact the Azure Batch Team to provide instructions on how to install Python using the start task feature. I would like to provide the steps to perform this task in case that someone needs to work in a similar case.


Required steps:

  • Get the python release that you want to install.
  • Add the installer into a storage container.
  • Create the windows pool and define the required start task and the resource files to install the features.

Get the python release that you want to install.
 

First, download the python installer from the official site (Example below is using the 3.8.0 version for Windows) 
Download Python | Python.org

carlosbermudezlopez_0-1620665567879.png

Add the installer into a storage container.

Next step is to upload the installer to a Storage Blob Container, this installer will be downloaded to the Azure Batch Node using the Resource Files Feature in feature steps.
 

Select your Storage Account and create a new container/ select an existing one, then upload the installer.
 

carlosbermudezlopez_1-1620665586738.png

 

carlosbermudezlopez_2-1620665586745.png

Create a Windows Pool, and define the required start task and resource files.
 

Next step is to create our Windows Batch pool. We will use the required fields to create a pool, which requires to enable the Start task section.
 

carlosbermudezlopez_3-1620665635136.png

 

By using the start task run on each compute node as it joins the pool, the task will be executing when the node is added to the pool or when the node is restarted.

Once the start task configuration is enabled, we will need to define the required command line for the installation. We are using the following command line cmd /c "python-3.8.10-amd64.exe /quiet InstallAllUsers=1 PrependPath=1 Include_test=0"

However, you can find all the required command lines to execute the installation in the following link.


3. Using Python on Windows — Python 3.9.5 documentation

It is important to set the User Identity to Pool Autouser, Admin to grant administrative privileges.

 

carlosbermudezlopez_4-1620665656871.png

 

Additionally, we need to define the Resource files that Azure Batch downloads to the compute node before running the command line, so once you click on the resource files option you need to click on the “pick storage blob” and it will open an interactive window where you can navigate through your storage explorer and select the installer.
 

carlosbermudezlopez_5-1620665656875.png

Important: Check the Public access level of the blob container, if you leave it as Private(no anonymous access), like in the above example, you will need to specify the “Include SaS key” when you select the resource file, otherwise you will get authentication problems. However, If the access level is set to Blob or Container it will be public.

If you are using a Private access, then it is required to mark the Include SAS and set an expiration date before adding the Resources files
 

carlosbermudezlopez_6-1620665656877.png

 

Finally, once the VM node is ready and the Start task finished, you can access the node using RDP and confirm that python is now installed.
 

carlosbermudezlopez_7-1620665656882.png

 

carlosbermudezlopez_8-1620665656893.png

You can execute the following command to confirm that the correct python version is installed.
 

carlosbermudezlopez_9-1620665656894.png

4 Comments
Version history
Last update:
‎May 11 2021 05:50 PM
Updated by: