3

My program is currently reading from a service bus queue, and I am planning to scale out instances. But before doing so I want to confirm if scaling is actually working tried getting the thread details but its not providing any concrete evidence

  • Maybe [this](http://developers.de/blogs/damir_dobric/archive/2016/11/28/how-to-manage-azure-webjobs-programmatically.aspx) article may help you. – Jeroen Heier Jun 11 '17 at 06:00
  • thanks Jeroen, It was informative but I am having only one webjob which I will be running on multiple instances, I am just trying to get the proof of approach if its actually doing so – Prateek P J Jun 11 '17 at 06:21
  • Have also a look at [this](https://stackoverflow.com/questions/21710755/will-an-azure-web-job-run-on-multiple-instances) SO question and [this](http://www.samulihaverinen.com/web-development/dotnet/2016/02/24/guide-to-azure-webjobs/) guide. – Jeroen Heier Jun 11 '17 at 06:44
  • Any update? If you feel my answer is useful /helpful.Please mark it as an answer so that other folks could benefit from it. – Brando Zhang Jun 15 '17 at 09:36

1 Answers1

2

How to log the instance ids for webjob scaled out to multiple instances

As far as I know, the each web app's instance will have its own instance id.

It will save as an environment variable in its web app server.

If you want to get the current webjobs instance id, I suggest you could get its environment-variable(WEBSITE_INSTANCE_ID).

The id representing the VM that the site is running on (If site runs on multiple instances, each instance will have a different id)

More details, you could refer to below codes:

public static void ProcessQueueMessage([QueueTrigger("queue3")]  string thumbnail, TextWriter log)
        {

            string instanceid = Environment.GetEnvironmentVariable("WEBSITE_INSTANCE_ID");

            log.Write( "Current instance ID : "  +  instanceid);
        }

Result:

enter image description here

Brando Zhang
  • 22,586
  • 6
  • 37
  • 65