Instances of Azure Cloud Service accessible during scale up

dsmwb 6 Reputation points

I have a Cloud Service classic service (web role) in my Azure account where I set up the autoscale.
Since my instances take some time to restart due to various initialization tasks, I manage the lifecycle with the class RoleEntryPoint and its events.
In ServiceDefinition.csdef I have:

   In ServiceDefinition.csdef I defined:  
   <WebRole name="web" vmsize="Standard_A2_v2">  
       <Runtime executionContext="elevated">  
   			<NetFxEntryPoint assemblyName="web.dll" targetFrameworkVersion="v4.0" />  

According to the documentation in

While the OnStart code is executing, the role instance is marked as Busy and no external traffic will be directed to it by the load balancer.

So I used the OnStart event to leave the instance in Busy until the initialization is complete

   public override bool OnStart()  
           if (!init())  
               return false;  
           return base.OnStart();  
       catch (Exception e)  
       return false;  

Everything works (almost) well because occasionally, during the scale up, azure gives access to the instances that are initializing and return an error.

Have any of you experienced the same thing?

Any help is welcome.

Azure Cloud Services
Azure Cloud Services
An Azure platform as a service offer that is used to deploy web and cloud applications.
672 questions
{count} votes

4 answers

Sort by: Most helpful
  1. prmanhas-MSFT 17,901 Reputation points Microsoft Employee

    @dsmwb Apologies for the delay in response.

    As per the documentation you posted if onstart returns true, it will release the busy, and if it returns false, it will terminate the process.

    So according to your code, is all the initialization code called in init()?

    Also, when you request restart, it will try to restart the instance, but then right after you call that you return false which will try to kill it. I'm not sure this is causing your issue, but I believe the request restart should be put in the onstop method.

    Hope it was helpful.

    Please 'Accept as answer' if it helped, so that it can help others in the community looking for help on similar topics

    0 comments No comments

  2. mpjl 1 Reputation point

    Thanks for your reply

    According to the documentation, requesting a recycle of the instance or returning false does not matter because the system still waits for onstart to be completed.
    Also, I've never seen init() fail, so that piece of code is superfluous. However, init() takes some time to complete.

  3. prmanhas-MSFT 17,901 Reputation points Microsoft Employee

    @mpjl-0109 Thank you for your response.

    Definitely we will need to reproduce the issue in order to carry out the investigation further on the cause. Since I don't have the required expertise to answer this query what I will suggest is that whenever you are able to reproduce same issue you can right away open a Support Ticket for same so they can assist you further with this.

    If you don't have the ability to open a technical Support Ticket, you can email me with Subject as "ATTN: Preeti" at and provide me with your Subscription ID and link to this thread. I can then enable your subscription for one time free support.

    Also, once you get the issue fixed, request you to reply back here on the thread with the resolution steps for the benefit of the community.

    Do let me know if I can be of any further help to you.

    Please 'Accept as answer' if it helped, so that it can help others in the community looking for help on similar topics


    0 comments No comments

  4. mpjl 1 Reputation point

    if I had been able to reproduce the issue, I would have already opened a ticket on the Azure dashboard, here the request was more of an attempt to find other people with the same problem and help each other in an attempt to reproduce the issue

    thanks anyway for your efforts