自动安装在Azure的Web角色应用程序初始化(SDK V1.8,Windows Server 2012中) [英] Automatically install Application Initialization in Azure Web Role (SDK v1.8, Windows Server 2012)

查看:222
本文介绍了自动安装在Azure的Web角色应用程序初始化(SDK V1.8,Windows Server 2012中)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我看到微软已经发布了应用程序初始化为IIS 8.0的一部分。不幸的是它不是在默认情况下,Web角色启用。 (我的意思是,应用程序初始化作为未启用Web服务器角色的功能。我知道Web角色有IIS 8)。

I see Microsoft have released Application Initialization as part of IIS 8.0. Unfortunately it isn't enabled in the Web Role by default. (by that I mean, "Application Initialization" as a feature of the web server role is not enabled. I know the Web Role has IIS 8.)

有谁知道我可以从启动脚本启用此?我已经许多启动脚本,但我不知道如何添加服务器角色的功能。

Does anyone know how I can enable this from a start-up script? I've already a number of start-up scripts, but I'm not sure how to add a server role feature.

模块本身服务器管理器里面会出现在服务器角色 - >Web服务器(IIS) - >网络服务器 - >应用程序开发 - >应用程序初始化

The module itself appears inside Server Manager under "Server Roles" -> "Web Server (IIS)" -> "Web Server" -> "Application Development" -> "Application Initialization".

这是一个耻辱,这不是默认启用的,因为这将是非常有用的。

It's a shame that this isn't enabled by default as it will be very useful.

感谢

克里斯

推荐答案

首先,您需要使用启动任务来安装该功能:

First you'll need to install the feature using a startup task:

PKGMGR.EXE /iu:IIS-ApplicationInit

和那么你就需要配置你的网站在IIS( STARTMODE preloadEnabled

And then you'll need to configure your site in IIS (startMode and preloadEnabled):

public class WebRole : RoleEntryPoint
{
    public override void Run()
    {
        using (var serverManager = new ServerManager())
        {
            var mainSite = serverManager.Sites[RoleEnvironment.CurrentRoleInstance.Id + "_Web"];
            var mainApplication = mainSite.Applications["/"];
            mainApplication["preloadEnabled"] = true;

            var mainApplicationPool = serverManager.ApplicationPools[mainApplication.ApplicationPoolName];
            mainApplicationPool["startMode"] = "AlwaysRunning";

            serverManager.CommitChanges();
        }

        base.Run();
    }

    public override bool OnStart()
    {
        // For information on handling configuration changes
        // see the MSDN topic at http://go.microsoft.com/fwlink/?LinkId=166357.

        return base.OnStart();
    }
}

<一个href=\"http://fabriccontroller.net/blog/posts/iis-8-0-application-initialization-module-in-a-windows-azure-web-role/\">I写了一篇博客文章中针对此,你可以找到在GitHub上一个示例应用程序。

I wrote a blog post about this and you can find a sample application on GitHub.

这篇关于自动安装在Azure的Web角色应用程序初始化(SDK V1.8,Windows Server 2012中)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆