Will Autoupdate Startup task work in azure application?

时光怂恿深爱的人放手 提交于 2019-12-12 17:41:08

问题


I have built one startup task for Azure application contain exe file(running periodically with some time interval) and now i would like to make it autoupdating at every week as i have asked before here

However i'll do some logic of replacing that file through that exe(startup task) then also it is not going to take any effect of new file. I have concluded that new startup task will take effect only if we upgrade/created that azure project with new file. (Correct me if i understood something wrong)

So is there any way to do my logic works by rebooting instance (by exe/startuptask) ? I think it will also take original file(added in startuptask at the time of upgrading/creating application) instead of new file!

Is it possible anyway?


回答1:


After I studied your problem i can propose a very simple solution as below which I have done before for a Tomcat/Java Sample:

Prepare your EXE to Reboot the VM along with your original code:

  1. In your EXE, create a method to look for specific XML file on Azure storage at certain interval, also add retry logic to access XML
  2. Parse XML for specific value and if certain value is set reboot the Machine
  3. Package your EXE in ZIP format and place at your Azure Storage
  4. Be sure to place the XML on Cloud and set the reboot = false value

What to do in Startup Task:

  1. Create a startup task and download the ZIP from Azure Storage which contains your EXE
  2. After the download, unzip the file and place the EXE to specific folder
  3. launch the EXE

What to do when you want to update the EXE:

  1. Update your EXE, package into ZIP and place at same place at Azure Storage with same name
  2. Update your XML to enable Reboot

How update will occur:

  1. The EXE will look for XML after certain internal as designed
  2. Once it sees Reboot is set, it will reboot the VM
  3. After the reboot, the Startup task will be launched and your new EXE will be downloaded to Azure VM and will be updated. Be sure that download and update is done at same folder.

Take a look at Startup tak in the sample below which use similar method: http://tomcatazure.codeplex.com/




回答2:


This is a very unreliable solution. If an Azure instance crashes or is taken down for updates you will have a new instance started from the original service package. All the state of the modified instance will be lost.

A much more reliable way would be to have the volatile executable stored somewhere like Azure Blob storage. You upload a new version to the blob storage and the role somehow sees that (either by polling the storage or by some user-invoked operation - doesn't matter), downloads the new version and replaces the existing version with the new one.

This way if your role crashes it will reliably fetch the newest version from the persistent storage on startup.



来源:https://stackoverflow.com/questions/10785650/will-autoupdate-startup-task-work-in-azure-application

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!