1

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.

Alexey Shcherbak
  • 3,394
  • 2
  • 27
  • 44

1 Answers1

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.

Community
  • 1
  • 1
astaykov
  • 30,768
  • 3
  • 70
  • 86
  • It could work reliable...Until RoleModel.xml will be moved, XML namespace or structure changed. Anyway its easier and looks less dirty than read IIS actual configuration. Thanks for hint – Alexey Shcherbak Feb 08 '12 at 15:33
  • the RoleModel.XML and structure are bound to SDK version. So the only issue would be if you upgrade your projects when new SDK comes and this new SDK has **breaking** changes in this file. But this is easily maintanable and catchable. – astaykov Feb 08 '12 at 19:53