Appendix 2: Configure a Startup Script for Windows Azure Nodes
Updated: June 29, 2011
Applies To: Windows HPC Server 2008 R2
If you are running Windows HPC Server 2008 R2 with SP2 or later, you can configure a startup script that runs automatically on a set of Windows Azure nodes when they are started (provisioned) in Windows Azure. Using a startup script, you can ensure that a group of nodes are configured properly to run specific jobs. Additionally, the nodes are restored to a known state if they become unavailable because of a service interruption and the role instances need to be provisioned in Windows Azure again. For example, using a startup script, you can install applications or drivers, configure SMB shares, or open firewall ports for specific applications. You can also use a startup script to configure subsets of nodes differently within the set of Windows Azure nodes that are deployed using a particular node template.
In this appendix:
-
General steps to configure and use a startup script
-
Script name
-
Environment variables
-
Example
-
Error logs
The following are the general steps for configuring and using a startup script for your Windows Azure nodes:
-
Create a configuration script (for example, startup.bat) that uses environment variables to differentiate nodes and to set different configurations. For more information, see the remaining sections in this topic.
-
Use hpcpack to package the script and upload it to the Windows Azure storage account that is used for deploying the Windows Azure nodes.
Important Do not specify the /relativePathparameter when packaging and uploading the startup script. The startup script should only run from the root directory of the Windows Azure nodes. -
Update a Windows Azure node template to specify the startup script.
Important To specify the startup script, you must edit an edit an existing node template, or edit a node XML file. -
Start (provision) the Windows Azure nodes.
The startup script is automatically deployed to the Windows Azure nodes and runs on the nodes.
-
If HPC Cluster Manager is not already open, open it. Click Start, point to All Programs, click Microsoft HPC Pack 2008 R2, and then click HPC Cluster Manager.
-
In Configuration, in the Navigation Pane, click Node Templates.
-
In the views pane, select a Windows Azure node template.
-
In the Actions pane, click Edit. The Node Template Editor dialog box appears.
-
Click Startup Script, and specify the name of the startup script that will run from the root directory (for example, startup.bat).
The startup script will run on each Windows Azure node the next time that it is provisioned.
You must ensure conformity between the name of the package that you upload to Windows Azure and the name of the script that runs (and that is specified in the node template). Only the naming conventions in the following table are allowed:
| Script name | Package name |
|---|---|
|
file.extension (example: startup.bat) |
file.extension.zip (example: startup.bat.zip) -OR- file.zip (example: startup.zip) |
You can use the environment variables in the following table, which are set automatically on the Windows Azure nodes, to help configure your startup script:
| Environment variable | Description | ||
|---|---|---|---|
|
HPC_NODE_NAME |
The name of the Windows Azure node that is automatically configured by Windows HPC Server 2008 R2 – for example, AZURECN-0014. |
||
|
HPC_NODE_GROUPS |
A comma-delimited list of node groups that the node belongs to.Allows the behavior of a script to be specialized for different subsets of the nodes.
|
The following example is a batch file that configures a firewall rule on a subset of nodes that are identified by the node group Port31337 Server Group. You can adapt this pattern to create startup scripts that perform other tasks.
@echo off echo %HPC_NODE_GROUPS% | findstr /C: "Port31337 Server Group" if %errorlevel% == 0 ( echo Creating firewall exception netsh advfirewall firewall add rule name="MyRule" dir=in protocol=tcp localport=31337 action=allow enable=yes )
The error logs for the startup scripts are listed in the following table. The location of the log files on each Windows Azure node depends on the type of node, as follows:
-
Worker nodes. Log files are in the %CCP_HOME% folder.
-
VM nodes. Log files are in the %CCP_HOME%\bin folder.
| Log file | Description |
|---|---|
|
HpcStartupCommand.log |
Exit code and output stream |
|
HpcStartupCommand.err |
Error stream |