Question

Using the June 2012 version of the SDK and emulator, I'm trying to install the Java runtime executable on an Azure worker role, following this example: http://code.msdn.microsoft.com/windowsazure/Installing-Java-in-Web-94f145dd#content.

I've uploaded the x64 installer as a blob, and renamed it 'Java.exe' (simply to make the file name a little easier on the eye):

Blobs

When I check with Azure Storage Explorer, I can see the blob is there, and that it is the correct size (31MB).

Following the example, I then use this startup task:

<Startup>
    <Task commandLine="Run.cmd" executionContext="elevated" taskType="background" />
</Startup>

To call this command:

powershell -executionpolicy unrestricted -file .\Launch.ps1

start /w Java.exe /s

Which in turn calls this powershell script:

function download_from_storage ($container, $blob, $connection, $destination) {
Add-Type -Path ((Get-Location).Path + '\Microsoft.WindowsAzure.StorageClient.dll')
$storageAccount = [Microsoft.WindowsAzure.CloudStorageAccount]::Parse($connection)
$blobClient = New-Object Microsoft.WindowsAzure.StorageClient.CloudBlobClient($storageAccount.BlobEndpoint, $storageAccount.Credentials)   
$remoteBlob = $blobClient.GetBlobReference($container + '/' + $blob)
$remoteBlob.DownloadToFile($destination + "\" + $blob)
}

$connection_string = 'DefaultEndpointsProtocol=https;AccountName=devstoreaccount1; AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw=='

# JRE
$jre = 'Java.exe'
download_from_storage 'startuputil' $jre $connection_string (Get-Location).Path

This works, and if I browse to the approot that the emulator creates on my local disk, I can see Java.exe there, but its file size is 0KB, and running it fails with the error 'Not a valid Win32 application'

Empty Java.exe

Clearly the download is beginning, but for some reason it doesn't seem to be completing. Can anybody tell me why?

I wondered if it was related to this issue: Exception Downloading Azure Blob, but running it against our live storage account fails in exactly the same way.

I should add I'm a reasonably experienced C# programmer, but know very little about powershell, so am more or less following the example line by line. And I'm not really looking for a workaround - it's straightforward enough to package this file by including it in the project and setting it to always copy, but I'm going to need this technique for other, larger files and so would like to get it working if possible.

Was it helpful?

Solution

(converting my comment to an answer)

I believe that error message could mean that the container doesn't exist. Are you sure that "startuputil" is the correct name of the container you created?

OTHER TIPS

Try specifying your connection string like this:

$connection_string = 'UseDevelopmentStorage=true'

Hope this helps.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top