none
Best way to Restart an Azure WebRole, so it will reinitialize correctly ? and keep the service available

    Question

  • So....

    I have my Azure application in production, running 2 instances.

    It is a Webservice, with a test html page

    The service, has some legacy Windows Services, running to provide data

    We put the Database, and the Bins for the legacy service into Zipped BLOBS - in blob storage

    The web role, downloads the blobs during startup, extracts the files, and configures the service

    If I package and deploy in Visual studio, the startup works great.

    BUT all the instances are shut down, and the service is unavailable during that cycle.

    Often what We will want to do, is provider new data files, but not new code in the Blobs

    so i just want the existing service to restart, and reload the new blobs and bring the service up again

    preferably one at a time - to keep the service running.

    I looked at the "UPGRADE" button in the ribbon bar, but it seemed to want me to upload

    a new package, and I couldn't find the one that it already had.

    I tried the REBOOT button to reboot just one instance at a Time

    AND i tried stop and Start on the instances.

    In both these cases, it was not a full restart, as the service remained installed

    and was left in a STOPPED state at the end of initialization

    I was able to RDP in to the VM and start the Service manually, but it was accepting calls and returning null responses

    until I was able to get in there manually.

     

    So .... my question is

    What is the Best correct way, to get the startup script to run, and load new data from the BLOBS

    in such a way that the services keep running, and it goes through the restart process, and my Service is refreshed.

    I am considering a seperate APP that would call the API - but I would prefer to do it with The console.

     

    Alternatively - is there a better way to tell that the service is not running, and have some code that can service start

    remotely without having To login or something

     

    Hope someone can help - thanks in advance

    - Mark Jones - Envision IT

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

    Wednesday, August 24, 2011 3:58 PM

Answers

  • You can implement Run() in a web role just like you do in a worker role. This Run() could periodically wake up and check if there is a new blob (BlobProperties.LastModifiedUtc). The Run() can run as an elevated user so should be able to stop and restart a service. Similarly it should be able to unzip the files. Indeed, you could presumably wrap all this so that it is accessible from either the startup or the web role code.

    I don't know of code that does all this. However, the Windows Azure Accelerator for Web Roles does some of this - except it adds web sites rather than the legacy service stuff. However, the general idea is the same.

    While all this sounds more complicated than simply stopping and starting a role it is automatic not manual. Another trick would be to change the configuration file and let the configuration change initiate a rolling upgrade.

    • Marked as answer by Wenchao Zeng Thursday, September 01, 2011 8:42 AM
    Wednesday, August 24, 2011 10:58 PM
    Answerer

All replies

  • Could you not do something like have the web role instances poll for changes to the data blob and upgrading themselves when they detect changes - without going through a recycle.

    On finding that the data blob has changed, an instance can lease it (a minute at a time) preventing other instances from accessing it. This instance could upgrade itself without going through a startup process. When the upgrade is complete it could release the lease allowing another instance to detect the change and upgrade itself.

    Wednesday, August 24, 2011 4:59 PM
    Answerer
  • the Web role would have to do that check, at the end of a normall request ?

    - look at the BLOB (how)

    - check The date (how)

    - stop the service (how)

    - unzip the files

    - restart the service

     

    Currently the Install.cmd happens automatically - i can see it embedded in the vbproj

    the BLOBS are accessed with a WGET command line - just using the URL

     

    Do you know of any code examples for any of those steps ? 

     

    It all sounds alot more complex than hitting an Upgrade button - which is what I was hoping for

     

     

     

     


    Mark Jones - Envision IT http://www.envisionit.com/
    Wednesday, August 24, 2011 10:00 PM
  • You can implement Run() in a web role just like you do in a worker role. This Run() could periodically wake up and check if there is a new blob (BlobProperties.LastModifiedUtc). The Run() can run as an elevated user so should be able to stop and restart a service. Similarly it should be able to unzip the files. Indeed, you could presumably wrap all this so that it is accessible from either the startup or the web role code.

    I don't know of code that does all this. However, the Windows Azure Accelerator for Web Roles does some of this - except it adds web sites rather than the legacy service stuff. However, the general idea is the same.

    While all this sounds more complicated than simply stopping and starting a role it is automatic not manual. Another trick would be to change the configuration file and let the configuration change initiate a rolling upgrade.

    • Marked as answer by Wenchao Zeng Thursday, September 01, 2011 8:42 AM
    Wednesday, August 24, 2011 10:58 PM
    Answerer