Question

I have an issue with obtaining data from Windows Azure's runtime using the newest (at the time of writing) PHP SDK from Github. Here is a test I am running on one of our hosted services:

<?php

include 'WindowsAzure/WindowsAzure.php';
use \WindowsAzure\ServiceRuntime\RoleEnvironment;
use \WindowsAzure\ServiceRuntime\Internal\RoleEnvironmentNotAvailableException;

try {
    echo RoleEnvironment::getDeploymentId();
}
catch (RoleEnvironmentNotAvailableException $Exception) {
    die('Failed to find deployment id');
}

RoleEnvironmentNotAvailableException is always thrown. Looking at the source, it seems to try sending commands through a named pipe (\.\pipe\WindowsAzureRuntime). Do I need to specify something within my ServiceConfiguration.csdef/cscfg in order to have access to this named pipe?

Any advice would be most welcome!

Was it helpful?

Solution

Got confirmation from MS EMEA Developer Support that current SDK does not support this function. They suggested similar workaround to jonnu above - use the previous SDK's functionality for role environment / configuration settings.

OTHER TIPS

The ServiceRuntime APIs run only on Cloud so if this code snippet runs on local machine it'll throw an exception as you've pointed out. Further, if you want to debug your ServiceRuntime code you've to deploy your service to WA then use remote desktop connection to access the cloud machine and debug your code.

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