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.
First, download the python installer from the official site (Example below is using the 3.8.0 version for Windows)
Download Python | Python.org
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.
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.
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.
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.
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
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.
You can execute the following command to confirm that the correct python version is installed.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.