Installing Java into an Azure Worker Role
1. Download Java.
2. Add a reference to the installation package (e.g. jre-6u26-windows-x64.exe) to your worker role. In the properties, set Copy to Output Directory = Copy always.
3. Create and add a Startup.bat to your worker role. Set Copy to Output Directory = Copy always. This batch file is one line long:
jre-6u26-windows-x64.exe /s /L %RoleRoot%/approot/java-install.log
This will silently install Java and create a log in your root directory (which has been E:\approot every time I have ever remoted in to any instance).
4. Add a startup task to ServiceDefinition.csdef that will run the batch file during deployment:
<WorkerRole name="WorkerRole1">
<Startup>
<Task commandLine="Startup.bat" executionContext="elevated" taskType="background" />
</Startup>
</WorkerRole>
5. Before you publish, you need to make sure you have an x.509 certificate added to your worker role. Upload the certificate to your hosted service via the Azure Management Portal. Also, add the certificate to your configuration settings.
6. Now it’s time to publish. Make sure you select Configure Remote Desktop connections. You will want to log into your role remotely (at least once) to verify that Java was installed).
7. After the worker role has been deployed, you should be able to remote into the machine. Once you are in, navigate to E:\approot. The installation log should be there if you need to look at it. If you just need to verify that Java is installed, try D:\Program Files\Java.
[...] Installing Java into an Azure Worker Role (J.P. Hamilton) [...]