Fetching an Azure Local Storage (LocalResource) from PHP

This post is written in English for the benefit of search engines.

I had a client meeting this week where we deployed a PHP based solution to Windows Azure. One of the issues we faced was accessing Local Storage on an Azure VM from PHP. In a .NET environment this is done by getting a LocalResource instance from the RoleEnvironment object, then querying the RootPath property of the LocalResource instance.

However, the official Azure SDK for PHP does not include functionality to do this, and the Contrib library we found threw various errors and did not work.

So I whipped up a quick utility that helps to do this. It is a .NET command line program that reads the RootPath and either writes it to an environment variable or prints it to its output. The environment variable or the printed output can then be accessed from PHP code (or from any other code, for that matter) and the Local Storage can be used.

“Usage: GetAzureLocalResource [ResourceName] [VariableMode]

This will get the [ResourceName] local resource’s root path and write it to the LR_[ResourceName] environment variable. [VariableMode] can be User, Process, Machine or PrintOnly; the environment variable will be written to the specified store, or only printed to the output. Exception information is written to the LR_ERROR machine environment variable.

For example:
GetAzureLocalResource Res1 Machine — Gets the Res1 local resource’s root path and writes it to the LR_Res1 machine environment variable.”

Click here to download the application.

Vélemény, hozzászólás?

Adatok megadása vagy bejelentkezés valamelyik ikonnal:

WordPress.com Logo

Hozzászólhat a WordPress.com felhasználói fiók használatával. Kilépés / Módosítás )

Twitter kép

Hozzászólhat a Twitter felhasználói fiók használatával. Kilépés / Módosítás )

Facebook kép

Hozzászólhat a Facebook felhasználói fiók használatával. Kilépés / Módosítás )

Google+ kép

Hozzászólhat a Google+ felhasználói fiók használatával. Kilépés / Módosítás )

Kapcsolódás: %s