2
votes

I have several web and worker roles in my solution, but I also have a non-Azure application running on a Azure hosted VM. That application connects to Azure storage for various things like reading and writing blobs and queues, and that works fine.

I'd like to use Azure diagnostics from within that same application (a .NET app running on a VM hosted in Azure). However, if I try to initialize diagnostics I get an exception that:

System.InvalidOperationException: Not running in a hosted service or the Development Fabric.

This makes sense, but I'm wondering if it's possible to use the diagnostics in some way without being a hosted service. In particular, I'm using azure diagnostics to gather logging information, written out by System.Diagnostics.Trace, and that's all hidden away from the application code, so if there were some other APIs I have a place I can probably slot that in.

Any ideas? Thanks, JC

1
Not really an answer, but...Would a regular logging assembly (Log4Net) work temporarily? Abstract the code out so, for a non-Windows app it logs to file/db etc and for Azure it does diagnostics. Maybe in the future they will support this and your code will be ready to go.Bart Czernicki
You could add your own trace listener that writes to table storage,blob storage or even SQL Azure.David Steele

1 Answers

2
votes

Unfortunately, no. At least not today. The agent has some hard-coded checks for the RoleEnvironment stuff and when it is not there, it fails. This is also the reason you cannot use the agent in the IaaS stuff today either.