Azure: How to execute startup tasks for each site entry at webrole?

与世无争的帅哥 提交于 2019-12-08 06:19:59

问题


We have WebRole, that hosting multiple sites. We made startup tasks for each site with some site specific actions. The problem is that only startup task of first site (first site listed in section), could be run during deployment.

Looks like this happens cause only first site (or that one from web-role defifnition) will be copied to [drive]:\approot folder at WebRole Instance. All other sites will be copied to [drive]:\sites\ (early it was another location so it could be a subject of future changes).

Is there any simple way to run batch files for each site in [drive]:\sites\ ?

Is there any tricks with RoleEnvironment object or xPath values (like here http://msdn.microsoft.com/en-us/library/windowsazure/hh404006.aspx) that can provide exact path where additional sites will be placed ?

ATM we have 2 options, both are hacky and unstable, imo: 1.Read data from IIS configuration and use it as main startup task input 2.Scan /sites/ for explicitly named scripts and execute it if found.


回答1:


Startup Task is meant to be for a Role and not for a site. You have to find your way out using the RoleEntryPoint descendant and utilize its OnStart method to manually run your startup tasks per site.

As for finding out the sites directories check out this question, as the answer completly covers the task. I use it, it is 100% reliable for production.



来源:https://stackoverflow.com/questions/9189638/azure-how-to-execute-startup-tasks-for-each-site-entry-at-webrole

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