How to automatically install Application Initialization in Azure Web Role SDK v1 8

0 votes
I see that Application Initialization as a feature of the web server role is not enabled. How I can enable this from a start-up script? I'm not sure how to add a server role feature.
Apr 11, 2019 in Azure by sabby
• 4,370 points
900 views

1 answer to this question.

0 votes

Follow these steps -

  • Install the feature using a startup task:
PKGMGR.EXE /iu:IIS-ApplicationInit
  • 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();
    }
}
answered Apr 11, 2019 by Prerna
• 1,960 points

Related Questions In Azure

0 votes
1 answer

How to add an App Settings to existing Azure Web Application using Azure Power Shell?

The example is for slot-specific settings, if ...READ MORE

answered Jun 13, 2018 in Azure by club_seesharp
• 3,450 points
1,428 views
0 votes
1 answer

How to perfom "switching config" in Azure Websites Application Insights?

There was a new blog post about ...READ MORE

answered Sep 24, 2018 in Azure by club_seesharp
• 3,450 points
674 views
0 votes
1 answer

How to Schedule a task in Azure Worker role?

You can simply have a message on ...READ MORE

answered Jul 1, 2019 in Azure by Perry
• 17,100 points
1,418 views
0 votes
1 answer
0 votes
1 answer

Azure Storage Emulator shows error.

Check if you are running BitTorrent/uTorrent or similar ...READ MORE

answered Mar 16, 2019 in Azure by Prerna
• 1,960 points
1,706 views
0 votes
1 answer

Friendly filename when downloading Azure blob.

Azure blobs can be downloaded in four ...READ MORE

answered Mar 16, 2019 in Azure by Prerna
• 1,960 points
3,760 views
0 votes
1 answer

How to create a sub directory in a blob container?

There are two ways:  using the GetDirectoryReference looping through a containers ...READ MORE

answered Mar 26, 2019 in Azure by Prerna
• 1,960 points
12,567 views
0 votes
1 answer

How to debug Azure 500 internal server error?

You can simply turn off custom error in ...READ MORE

answered Mar 29, 2019 in Azure by Prerna
• 1,960 points
4,840 views
0 votes
1 answer

How to check if multiple files exist in Azure container?

foreach loop is the most efficient way though. ...READ MORE

answered Mar 4, 2019 in Azure by Prerna
• 1,960 points
3,840 views
0 votes
1 answer

How to install Windows Azure Storage Emulator?

There may be an issue with the ...READ MORE

answered Mar 7, 2019 in Azure by Prerna
• 1,960 points
2,778 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP