Reputation: 15861
I have a C# console app called during the startup of a WebRole to perform customized instrumentation. I'd like for this program to be able to read the latest values from Service Config and act accordingly.
I've setup the startup script that calls my .EXE to run in elevated mode. I've added a reference to Azure's ServiceRuntime to the console app, however I'm getting the following error: role discovery data is unavailable
Upvotes: 0
Views: 134
Reputation: 6943
If you've put calling this executable as a start-up task in the .csdef, then the information you're asking for may not be available as the role has not yet been set up (see lifecycle of Web/Worker role).
This could also be the problem if you're calling the executable within OnStart in WebRole.cs - as IISConfigurator is called asynchronously with OnStart.
For the startup task, one work around for this is detailed at http://mvolo.com/configure-iis-websites-windows-azure-startup-tasks-appcmd/ (although it deals with changing IIS configuration).
For the WebRole issue, you could overload Run() and call your executable from there - possibly with retries like:
while (!RoleEnvironment.IsAvailable) {
Thread.Sleep(1000);
}
RunExecutable();
Upvotes: 1