0

I'm trying like crazy to figure out what is going wrong in WebRole.OnStart(). I know where the issue is occurring. I just don't know what the issue is.

I have added the following to web.config:

<system.diagnostics>
    <trace>
      <listeners>
        <add type="Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitorTraceListener, 
            Microsoft.WindowsAzure.Diagnostics, 
            Version=2.4.0.0, 
            Culture=neutral, 
            PublicKeyToken=31bf3856ad364e35"
           name="AzureDiagnostics">
          <filter type="" />
        </add>
      </listeners>
    </trace>
  </system.diagnostics>

I have also added the following to WebRole.OnStart()

Trace.TraceInformation("OnStart()");

try
{
    CallMethodThatCausesException();
}
catch (Exception ex)
{
    Trace.TraceError("Exception: " + ex.ToLogString());
    throw;
}

I have also set a custom plan in the WebRole Diagnostics:

However, I can't find any log files, tables in TableStorage, or blobs in BlobContainers that contain either of the Trace statements above.

I do see WADLogsTable but The only entries that I see are Loaded "Microsoft.WindowsAzure.ServiceRuntime, Version=2.4.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35".

Within the event logs I do see an exception:

Description: The process was terminated due to an unhandled exception. Exception Info: System.IO.FileLoadException Stack: at Microsoft.WindowsAzure.ServiceRuntime.Implementation.Loader.RoleRuntimeBridge.&lt;InitializeRole&gt;b__0() at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean) at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean) at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object) at System.Threading.ThreadHelper.ThreadStart()

Any help would be greatly appreciated!

devlife
  • 15,275
  • 27
  • 77
  • 131
  • Have you configured diagnostics for the web role? Right click on web role (under Roles inside Cloud Service project) --> Properties --> Configuration Tab --> Diagnostics. – Gaurav Mantri Aug 30 '14 at 06:02
  • @GauravMantri Yes. I just updated the question with a screenshot. – devlife Aug 30 '14 at 15:06
  • Trace logs information is stored in WADTraceLogs table. You should see this table in the storage account you have configured for storing diagnostics information. Does your role crashes in emulator as well or in cloud only? Another thing you could try is enable Remote Desktop on the web role and connect to that box and check event logs there. – Gaurav Mantri Aug 30 '14 at 15:09
  • Added some event log information.... – devlife Aug 30 '14 at 15:21
  • It looks like some of the assemblies are not included as part of your package. The role may not crash on local machine because it might pick up those assemblies from GAC or some other place. Can you please ensure that for all the required assemblies, `Copy Local` is set to `true`. HTH. – Gaurav Mantri Aug 30 '14 at 15:32
  • 1
    You may also want to read this blog post:http://candordeveloper.com/2013/12/31/azure-problems-at-deployment-resolved/ (Go to section titled Diagnostics). Even though the post is somewhat old, it may give you some ideas as to why your role is crashing. (Or so a search on `Microsoft.WindowsAzure.ServiceRuntime.Implementation.Loader.RoleRuntimeBridge`). HTH. – Gaurav Mantri Aug 30 '14 at 15:35
  • That link lead me to the answer! I needed to add `Trace.Listeners.Add(new DiagnosticMonitorTraceListener());` before my first `Trace` statement. – devlife Aug 30 '14 at 16:43
  • Have you added a reference to Windows.WindowsAzure.Diagnostics assembly (version 2.4.0.0) to your project? Do you have Copy-to-local set to True? I had similar problems with on worker role. In my local environment they only occurred when I tried to run the release build (debug started up correctly). – Juha Palomäki Aug 31 '14 at 10:26

1 Answers1

1

You can use the troubleshooting scenarios at http://blogs.msdn.com/b/kwill/archive/2013/08/09/windows-azure-paas-compute-diagnostics-data.aspx to debug pretty much any role startup type of issue you encounter. In particular, check http://blogs.msdn.com/b/kwill/archive/2013/10/03/troubleshooting-scenario-7-role-recycling.aspx which walks through pretty much the same scenario that you are encountering.

I suspect that your issue is that another DLL you are referencing has a reference to a version of Microsoft.WindowsAzure.ServiceRuntime that is older than the 2.4 version you are deploying. You can either upgrade that dependent DLL to the latest ServiceRuntime, or you can add a binding redirect in your config file to force that dependent DLL to use the 2.4 ServiceRuntime.

kwill
  • 10,867
  • 1
  • 28
  • 26