iis - 创建网站后运行的 Azure 启动任务

标签 iis azure azure-web-roles

我为 Azure 网站创建了一个启动任务,该任务执行以下操作:

  • 创建应用程序池
  • 将虚拟目录转换为虚拟应用程序

我创建了一个执行这些任务的 powershell 脚本。

我已经在服务定义中设置了启动元素

<Startup>
  <Task commandLine="MyStartup.cmd" executionContext="elevated" taskType="simple">
    </Task>
</Startup>

到目前为止一切都很好。

但是,I've found out, rather late ,即:

IIS may not be fully configured during the startup task stage in the startup process, so role-specific data may not be available.

我认为这意味着运行 powershell 脚本时该网站可能不存在于 IIS 上。我已经测试了该脚本,果然它失败了,因为它在 IIS 上找不到虚拟目录。

我的问题是:有没有办法确保在 IIS 上创建网站之后运行 powershell 脚本?

请注意,如果可能的话,我真的不想使用Microsoft.WindowsAzure.ServiceRuntime.RoleEntryPoint.OnStart

提前致谢。

最佳答案

我按照 @kwill 的建议创建了以下内容:

Powershell:

while(!($myWeb = Get-Website -name "*MyWeb*")){
    Write-Host "Website not installed. Waiting 30 seconds..."
    Start-Sleep 30
}

# Proceed with installation

and configuration

  <Task commandLine="MyBackground.cmd" executionContext="elevated" taskType="background">
  </Task>

这有效。

关于iis - 创建网站后运行的 Azure 启动任务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22106175/

相关文章:

c# - IIS 7.5 - Windows Server 2008 - 文件上传 405 错误。代码在 windows 2003 服务器中工作

asp.net - IIS 加载 ASP.NET Web 应用程序的哪些 dll 文件?

c# - 阻止用于访问资源的危险 IP

azure - 创建具有相同源主机名的多个 CDN 端点。在这种情况下CDN如何工作/

c# - 如何将文件上传到blob容器?

c# - 在 Azure 网站上使用 RSACryptoServiceProvider 会导致文件未找到错误

azure - 是否可以在 Azure WebRole (MVC) 中托管 WCF 服务

c# - .NET DateTime 对象字符串格式

azure - Azure 上的 PHP 应用程序

azure - 如何为 Azure 托管网站/Web 角色设置 A 记录?