IIS AppPool naming convention - iis

Is there a naming convention for naming AppPool (IIS)?
Explicit is great but should we add something like "AppPool" for external purpose (third party)? maybe for distinction between his site.
site name : MyProject
appPool name : MyProject
site name : MyProject
appPool name : AppPool_MyProject

There are no convention for application pool naming.
By default, There was a naming convention for application pool identity. I mean if your application pool named MyProject. Then its application pool identity would be "IIS APPPOOL\MyProject".
Since application pool is only used to isolate different applications, you could naming anything you like. Most of time, we just use site name or sub-application's name as application pool's name.

Related

Which application pool does an application use by default

If I create a number of application pools, and then create an application but don't specify which application pool it should run in, which one does it use?
Is it random? Does it always take the first one? Something else?
When you do not specify an existing application pool when you create the site, the site will create a new application pool with the same name as the site.
If you use IIS Manager and add an application to your website, by default the application uses the application pool you selected when the website was created.
However, if you use appcmd.exe or PowerShell to add applications, the situation is different from using IIS Manager. By default, applications use the DefaultAppPool instead of random.
Using appcmd.exe:
appcmd add app/site.name:test/path:/blig/physicalPath:C:\inetpub\app1 ---Create app1
appcmd list app "test/app1" ---Verify the Apppool used by app1 by default
Using PowerShell:
New-Item 'IIS:\Sites\test\app2' -physicalPath C:\inetpub\app2 -type Application
The default application pool used is defined in applicationHost.config.
Both the sites element and the site element have a child element named applicationDefaults. This has an optional attribute named "applicationPool".
If the application element doesn't have it's optional "applicationPool" element set, it takes it from site.applicationDefaults, and then from sites.applicationDefaults. If none are set the application will fail to run.

Change EnvironmentName in IIS (vNext MVC6)

I try to use MVC6 and I want to use new feature "Changing configs by environment" in my apps
So as far as I understand I can choose proper config by changing environment variable ASPNET_ENV. I know two ways to change value of this variable
1) I change variable at Debug tab at Project Properties
2) I change variable at Azure Portal for my Azure Web Site
But how can I specify this variable in IIS after publishing website?
You can set specific user for the AppPool of your website, and then set environment variable for the user.

Get Azure Web App name in code

Is there any way to obtain the name of the web app from within code. i.e. if I have deployed my app to a web app called my-webapp-dev-ne I need to be able to get this name in code. The reason I cannot add it to an app config file or any other method is that the same app can be deployed to multiple places.
Adding to Rick's answer, you can find more informative environment settings here
WEBSITE_SKU - The sku of the site (Possible values: Free, Shared, Basic, Standard).
WEBSITE_COMPUTE_MODE - Specifies whether website is on a dedicated or shared VM/s (Possible values: Shared, Dedicated).
WEBSITE_SITE_MODE - The mode for the site (can be Limited for a free site, Basic for a shared site or empty for a standard site).
WEBSITE_HOSTNAME - The Azure Website's primary host name for the site (For example: site.azurewebsites.net). Note that custom hostnames are not accounted for here.
WEBSITE_INSTANCE_ID - The id representing the VM that the site is running on (If site runs on multiple instances, each instance will have a different id).
WEBSITE_NODE_DEFAULT_VERSION - The default node version this website is using.
WEBSOCKET_CONCURRENT_REQUEST_LIMIT - The limit for websocket's concurrent requests.
The web app environment provides an environment variable called WEBSITE_SITE_NAME that contains the name. You can access it from C# code like this.
var siteName = Environment.GetEnvironmentVariable("WEBSITE_SITE_NAME");
You can do this if you installed the Microsoft.WindowsAzure.ConfigurationManager nuget.
var siteName = CloudConfigurationManager.GetSetting("WEBSITE_SITE_NAME");
Reference:
CloudConfigurationManager Class
I would set this as a configuration in your web.config - for example:
<appSettings>
<add key="sitename" value="my-webapp-dev-ne" />
</appSettings>

How can I set the deployment path for an iisApp Provider using MsDeploy?

I am creating Web Deployment Package zip files for my Web Applications
I found I am able to specify the Site Name of the application by including a pubxml during the packaging of my site and using the PublishProfile property during the build to specify that profile.
The pubxml has <DeployIisAppPath>WebSiteName</DeployIisAppPath> in it and that creates the site name as seen in the IIS Management screen.
I'd like to specify the location on disk of the website when it is deployed to a server that doesn't already have this app installed.
What property can I use to do this?
I see that I could use -replace arguments as shown here: Specify different path for provider iisApp when creating package with msdeploy but I would rather the value be set in my pubxml.
You have two options:
Choose the checkbox for "Include IIS settings ...". When you do this a text box will light up with the title "physical Path of web application on destination server". Using the value for the parameter that is generated for this you can modify the destination app path.
Another option for you is to use msdeploy.exe directly and recreate the package using "apphostconfig" provider instead of iisApp provider and then parameterize the application path on the destination server.

Can a script update the Identity tab fields of Application Pool properties in IIS 6.0+

I am a developer and I have arrived at a solution to a webservice authentication problem that involved ensuring Kerberos was maintained because of multiple network hops. In short:
A separate application pool for the virtual directory hosting the webservice was established
The Identity of this application pool is set to a configurable account (DOMAINname\username which will remain constant but the strong password is somehow changed every 90 days I think); at a given point in time, the password is known or obtainable somehow by our system admin).
Is there a script language that could be used to setup a new application pool for this application and then set the identity as described (rather than manual data entry into property pages in IIS)?
I think our system admin knows a little about Powershell but can someone help me offer him something to use (he will need to repeat this on 2 more servers as the app is rolled out). Thanks.
You can use such PowerShell script:
Import-Module WebAdministration
$appPool = New-WebAppPool -Name "MyAppPool"
$appPool.processModel.userName = "domain\username"
$appPool.processModel.password = "ReallyStrongPassword"
$appPool.processModel.identityType = "SpecificUser"
$appPool | Set-Item

Resources