Configure Azure WebJobs
  • 1 Minute to read
  • Dark
    Light
  • PDF

Configure Azure WebJobs

  • Dark
    Light
  • PDF

Article Summary

Retrace supports profiling Azure WebJobs.  Azure WebJobs provide an easy way to run scripts or programs as background processes in the context of an Azure App Service.

Retrace will provide all of the same great insights to application performance as it does for web applications and windows services. Within Retrace, WebJobs will be monitored in 'Other Apps' and will be listed as 'Azure WebJob".

Installation

Step 1: Add Site Extension in the Azure Portal

This is done just like it is for normal App Services with Retrace. For WebJobs, select your app and then go to Platform Features -> Extensions -> Add -> Select the Stackify APM or Retrace extension.

Step 2: Add  App Settings in the Azure Portal

Within your Web App, go to Platform Features -> Settings -> Application Settings Under "Application settings" add these 3 settings:

Stackify.ApiKey=enter_your_key
COR_ENABLE_PROFILING=1
COR_PROFILER={de70e25c-02b5-4556-a837-8aa6fe502668}

Add one of the following, depending on if you are running the app in 32 or 64 bit mode:

COR_PROFILER_PATH_32=D:\home\Stackify\Profiler\Latest\x86\StackifyProfiler_x86.dll

COR_PROFILER_PATH_64=D:\home\Stackify\Profiler\Latest\x64\StackifyProfiler_x64.dll

Step 3: Create a "ProfileProcess.txt" file

This is a JSON formatted file that can define one or many EXEs to profile. It is recommended to save this with ANSI encoding to prevent issues parsing the JSON.

[{
    "exe": "WebJobContinuous.exe"
}]
Note:
"WebJobContinuous.exe" is the name of the executable that the profiler looks for, so be sure to format the "ProfileProcess.txt" file exactly as shown above

Save this file in the same folder as the .exe that is being profiled. This would allow you to easily “bin deploy” the file with your app.

Step 4: Define Operations to be Tracked

Tracking custom transactions is done by using the ProfilerTracer object within StackifyLib. This creates a defined operation from start to finish that can be named and tracked as a single operation. Here is a simple code example:

  //Create a new ID for the operation for correlation
  Trace.CorrelationManager.ActivityId = Guid.NewGuid();
  
  //name the operation whatever you want
  var tracer = StackifyLib.ProfileTracer.CreateAsOperation("Operation Name", Trace.CorrelationManager.ActivityId.ToString());

  tracer.Exec(() =>   //FYI, async code is also supported via tracer.ExecAsync()
  {
      //Do some stuff here
  });

Was this article helpful?

What's Next