Creating Application pool in WIX Installer - iis

I'm creating website with custom application pool settings using WIX. After installation my new website is using Default Application Pool instead of using the one that I'm creating during installation.
I could find ways for virtual directory to point to newly created app pool but seems iis:WebSite does not have attribute for setting app pool.
Here is my code:
<iis:WebSite Id="MyWebSite" Description='MyWebsiteDesc' SiteId='*' Directory='MyWebFolder'>
<iis:WebAddress Id="AllUnassigned" Port="80" />
</iis:WebSite>
<util:User Id="MyAppPoolUser"
CreateUser="no"
Name="[APPPOOL_USER]"
Password="[APPPOOL_PASS]"
Domain="." />
<iis:WebAppPool Id="MyAppPool"
Name="[WEB_APP_NAME]"
Identity="other"
User="MyAppPoolUser"
ManagedRuntimeVersion="v4.0"
ManagedPipelineMode="Integrated" />

Use IIS:WebVirtualDir/IIS:WebApplication to point to your AppPool.
Hope, this might help you.

You have created an application pool but you have only created a web site. To use the application pool, you must create a virtual directory or application within the website. Both the WebVirtualDir and WebApplication elements have a WebAppPool attribute that you can use to configure IIS to use the application pool you are creating.

I recently faced this issue. All my web application inside website were assigned new app pool I created but base website was having DefaultAppPool.
This is the trick to assign app pool to base website
<iis:WebAppPool Id="MyAppPool" Name="YourAppPoolName" Identity="applicationPoolIdentity" />
<iis:WebSite Id='MyWebSite' Description='Dummy' Directory='APPLICATIONFOLDER'>
<iis:WebApplication Id="AnyId" Name="Dummy" WebAppPool="MyAppPool" />
</iis:WebSite>

Related

Monitoring triggers in web.config not working for .net core web app

I'm trying to implement a setting (see below) in a web.config file in a .NET Core web app. Web app is hosted in Azure.
The setting is placed in system.webServer section and should restart the worker process on slow responses according to article:
https://azure.microsoft.com/sv-se/blog/auto-healing-windows-azure-web-sites/
<monitoring>
<triggers>
<slowRequests timeTaken="00:01:00" count="10" timeInterVal="00:02:00" />
</triggers>
</monitoring>
But when publishing the config file with this setting the web app crashes with error messages:
HTTP Error 500.19 - Internal Server Error
The worker process is unable to read the applicationhost.config or web.config file.
The requested page cannot be accessed because the related configuration data for the page is invalid.
Anyone successfully implemented this setting in a .net core app hosted in Azure?
I found that one setting was missing. The complete monitoring tag should be:
<monitoring>
<triggers>
<slowRequests timeTaken="00:01:00" count="10" timeInterval="00:02:00" />
</triggers>
<actions value="Recycle" />
</monitoring>

Can Web Deploy create IIS Site and Application Pool

I am working on automation of deployment process and I need to find a way to build and deploy an asp.net web site.
On top of this I would also like to create IIS Site and Application Pool for newly created IIS if one doesn't already exist.
Is this possible with Web Deploy (or is there an even better way/tool/approach to achieve these goals?)
Consider using ServerManager class from Miceosoft.Web.Administration namespace. Specifically, ApplicationPools and Sites properties.
For example,
ServerManager sm = new ServerManager();
Site site = serverMgr.Sites.Add(“MySiteName”, “C:\\inetpub\\wwwroot”, 8080);
sm.ApplicationPools.Add(“MyAppPool”);
sm.CommitChanges()
For more information see https://msdn.microsoft.com/en-us/library/microsoft.web.administration.servermanager(v=vs.90).aspx
Hope this helps.
There's also MSBuildExtensionPack:
https://github.com/mikefourie/MSBuildExtensionPack
I imagine that said msbuild-family-of-actions employs the Microsoft.Web.Administration namespace to work its magic in terms of creating a new website in IIS 7 and the scripting looks something like this (haven't tested this on my own server yet):
<Target Name="ProvisionIIS7WebSite" DependsOnTargets="CreateDeploymentNumber">
<PropertyGroup>
<WebSiteName>$(BaseDeploymentName)$(DeploymentNumber)</WebSiteName>
<PortNumber>$(DeploymentNumber)</PortNumber>
</PropertyGroup>
<ItemGroup>
<WebApplication Include="/MyApp">
<PhysicalPath>$(WebSitePath)</PhysicalPath>
</WebApplication>
<VirtualDirectory Include="/MyVdir">
<ApplicationPath>/MyApp</ApplicationPath>
<PhysicalPath>$(WebSitePath)</PhysicalPath>
</VirtualDirectory>
</ItemGroup>
<!-- Create new site -->
<MSBuild.ExtensionPack.Web.Iis7Website TaskAction="Create"
Name="$(WebSiteName)"
Port="$(PortNumber)"
Path="$(WebSitePath)"
AppPool="$(WebSiteAppPool)"
Applications="#(WebApplication)"
VirtualDirectories="#(VirtualDirectory)">
<Output TaskParameter="SiteID" PropertyName="WebSiteID" />
</MSBuild.ExtensionPack.Web.Iis7Website>
<Message Text="Created website with ID $(WebSiteID)" />
</Target>

MaxBufferPoolSize and MaxBufferSize?

This is my first post to Stack Overflow so please apologies if there is any non-conformity in it.
Question
I have developed a Windows Azure based site (similar to eBay) and hosted it on Azure platform. I have deployed multiple instances of web role with Azure caching enabled. Till last week everything was going fine but suddenly product search page started freezing while loading the data from db. It hangs only for specific categories which returns huge amount of data.
I read somewhere that we should enable localCache and transportProperties if we are expecting large messages. Hence I modified datacache item in my web.config as below but no luck. The page still hangs for those categories!
Could somebody please tell me what is wrong in following and show me some pointers?
<dataCacheClient name="default" channelOpenTimeout="20000" maxConnectionsToServer="4" requestTimeout="30000">
<localCache isEnabled="true" sync="TimeoutBased" ttlValue="300" objectCount="10000"/>
<clientNotification pollInterval="300" maxQueueLength="10000"/>
<transportProperties connectionBufferSize="64000" maxBufferPoolSize="5242880"
maxBufferSize="1242880" maxOutputDelay="2" channelInitializationTimeout="60000"
receiveTimeout="600000"/>
<hosts>
<host name="<<AZURE CACHE URL>>" cachePort="22233" />
</hosts>
<securityProperties mode="Message">
<messageSecurity
authorizationInfo="<<KEY>>">
</messageSecurity>
</securityProperties>
</dataCacheClient>
<dataCacheClient name="SslEndpoint" channelOpenTimeout="20000" maxConnectionsToServer="4" requestTimeout="30000">
<localCache isEnabled="true" sync="TimeoutBased" ttlValue="300" objectCount="10000"/>
<clientNotification pollInterval="300" maxQueueLength="10000"/>
<transportProperties connectionBufferSize="64000" maxBufferPoolSize="15242880"
maxBufferSize="5242880" maxOutputDelay="2" channelInitializationTimeout="60000"
receiveTimeout="600000"/>
<hosts>
<host name="<<AZURE CACHE URL>>" cachePort="22243" />
</hosts>
<securityProperties mode="Message" sslEnabled="true">
<messageSecurity
authorizationInfo="<<KEY>>">
</messageSecurity>
</securityProperties>
</dataCacheClient>
My dev env,
Azure SDK 1.8 (Oct 12), SQL Server 2008 R2, ASP.Net MVC 3
UPDATE
Today I deployed a build with CustomerErrors off to see the if it throws any exception, and this is what I got.
Thanks in advance
ND
I would advice to first find out which component is truly causing your intermittent slowdowns. Is it cache or is it SQL Azure?
If it is indeed cache, and since you're using Azure Shared Cache (previously known as Azure AppFabric Cache)
I would suggest looking at Dedicated cache as a solution instead of Shared cache. Performance of Shared Cache can sometimes be... unpredictable since it is a multi-tenant service and data travels over a network.

How to remove WebApplication on uninstall?

I install WCF service to IIS.
Installer creates Virtual dir and convert it to web application. Unintallation removes all but Web application name remains under IIS site. How to remove it? There is the code
<iis:WebVirtualDir Id="VDir"
Alias="[WEB_APP_NAME]"
Directory="INSTALLDIR"
WebSite="TheWebSite" >
<!--Turn the Virtual Directory into a web application.-->
<iis:WebApplication Id="TestWebApplication"
Name="[WEB_APP_NAME]"
WebAppPool="TheAppPool"/>
</iis:WebVirtualDir>
<iis:WebAppPool Id="TheAppPool" Name="[APP_POOL_NAME]"/>
Also, Web site code is outside of component to prevent removing defaultwebsite:
<iis:WebSite Id='TheWebSite' Description='[WEBSITE_NAME]' Directory='INSTALLDIR'>
<iis:WebAddress Id="AllUnassigned" IP="*" Port="80"/>
</iis:WebSite>
Please check whether SKIPCONFIGUREIIS property was not set. If not (property was set) application will not be deleted

Convert Virtual Directory to Web Application in WiX

I am creating a new WebSite whenever Feature A or B is installed:
<Component Id="IIS.HelloWorld" Guid="6FA5EF90-C9D9-463C-9CC7-0410670AFBD1" Directory="TARGETDIR">
<iis:WebSite Id="IIS.HelloWorld" Description="Hello World for Web" Directory="INSTALLDIR">
<iis:WebAddress Id="HelloWorldAddress" IP="*" Port="8080"/>
</iis:WebSite>
</Component>
The WebSite is pointed to the INSTALLDIR (Say C:\MyFiles). Below the INSTALLDIR, I have 2 additional folders: Service (C:\MyFiles\Service) and Web (C:\MyFiles\Web)
Since the WebSite is pointed to INSTALLDIR, all sub-directories (Service and Web) were automatically treated as Virtual Directories (?) -- I can see them linked via IIS Management Console and I can access them via my browser.
However, they need to be "converted" to Applications (done manually by right-clicking the Virtual Directory and selecting "Convert to Application) in order for them to work properly (they contain ASPX and ASMX files).
So I've added the following component to try to convert them to "Applications":
<Component Id="IIS.HelloWorld.WebSite.VirtualDirectory" Guid="GUID-44D1-48D9-BB3C-4B0126FB83E5" Directory="TARGETDIR">
<iis:WebVirtualDir Id="IIS.HelloWorld.WebSite.VirtualDirectory" Alias="Service" Directory="INSTALLDIR.WebSite" WebSite="IIS.HelloWorld">
<iis:WebApplication Id="IIS.HelloWorld.WebSite.VirtualDirectory" Name="Service"/>
</iis:WebVirtualDir>
</Component>
But the Virtual Directories wasn't converted to "Applications"; they are still just virtual directories.
Question: How do I convert virtual directories to applications in WiX? Or what is the proper way to handle this situation?
Thanks!
My bad. I was binding the wrong Virtual Directory Alias to the wrong Web Application Name.
This code works:
<Component Id="IIS.HelloWorld.WebSite.VirtualDirectory" Guid="GUID-44D1-48D9-BB3C-4B0126FB83E5" Directory="TARGETDIR">
<iis:WebVirtualDir Id="IIS.HelloWorld.WebSite.VirtualDirectory" Alias="Web" Directory="INSTALLDIR.WebSite" WebSite="IIS.HelloWorld">
<iis:WebApplication Id="IIS.HelloWorld.WebSite.VirtualDirectory" Name="Web"/>
</iis:WebVirtualDir>
</Component>

Resources