title: Azure start-up task to run after the website is created
body: <p>I've created a start-up task for an Azure website that does the following:</p>
  
  <ul>
  <li>Creates an AppPool</li>
  <li>Converts a Virtual Directory into a Virtual Application</li>
  </ul>
  
  <p>I've created a powershell script that carries out these tasks.</p>
  
  <p>I've set up the startup element in the Service Definition</p>
  
  <pre><code>&lt;Startup&gt;
    &lt;Task commandLine="MyStartup.cmd" executionContext="elevated" taskType="simple"&gt;
      &lt;/Task&gt;
  &lt;/Startup&gt;
  </code></pre>
  
  <p>All good so far. </p>
  
  <p>However, <a href="http://msdn.microsoft.com/en-us/library/windowsazure/hh180155.aspx" rel="nofollow">I've found out, rather late</a>, that:</p>
  
  <blockquote>
    <p>IIS may not be fully configured during the startup task stage in the
    startup process, so role-specific data may not be available.</p>
  </blockquote>
  
  <p>I take this to mean that the website may not exist on IIS when the powershell script is run. I've tested the script and sure enough it fails because it can't find the virtual directory on IIS.</p>
  
  <p>My question is: Is there a way to ensure the powershell script is run <strong><em>after</em></strong> the website is created on IIS?</p>
  
  <p>Please note, I don't really want to use <code>Microsoft.WindowsAzure.ServiceRuntime.RoleEntryPoint.OnStart</code> if possible.</p>
  
  <p>Thanks in advance.</p>