I've used appcmd to set environment variables on one application pool, but now I need to set it on all but 2 application pools, on some servers that have dozens of application pools running.
The idea was to set it in all and then remove it from the couple I need to remove it from instead of running the command 40 or 50 times to set it one by one.
Is it possible to do this ?
Thank you
You can try to this command:
appcmd.exe set config -section:system.applicationHost/applicationPools /+"environmentVariables.[name='foo',value='bar']" /commit:apphost
More infor you can refer to this link:
https://stackoverflow.com/a/44688613/13336642.
Related
I've understood that, in order to make IIS read a new environmental variable, I have to reset it via an administrator's command:
iireset /restart
I know that one can also restart IIS from the admin panel at server level.
More context to my complete web app setup in my previous question/answer: in brief it is a Python Flask app running on IIS through WSGI and FastCGI.
What is still surprising me is that now, if I delete a previously created environmental variable, IIS keep seeing it, even after restarting it, as done above.
Why is that possibly happening? And how should I delete the variable for IIS?
If you insist that you want to go with environmental variables (notice that you also have the alternative .env file), then you need to set them via the IIS FastCGI Settings from the IIS admin at server level for your specific application (the one you enabled via wfastcgi-enable).
Edit the specific row as said above and you'll find the Environment Variables collection under the "General" group of FastCGI Properties.
Now you can add and delete any of those variables and it will take effect immediately, without the need of any IIS reboot.
Was looking at the docs to set up a few apps deployed to strong-pm but ran into a cart-before-the-horse type issue:
It's not possible to set environment variables using slc ctl env-set <service> FOO=bar... before an app is deployed and given a service name.
This means that you are forced to run your app initially in a failure state upon first deploy, which is inconvenient and probably not a huge deal, but was curious if this is known.
Would be awesome if the slc ctl env-set command could set up a service name just like slc deploy does, but without the deploy itself.
As an aside, was curious if slc pm-install/sl-pm-install -e "FOO=bar" actually works to set common/shared/global env vars, but I couldn't find where these vars were set when the command was run.
When you deploy an app for the first time it auto-creates a service if one doesn't exist as part of the process. This can also be done manually with slc ctl create default. If you do that manually, you can modify the environment with slc ctl env-set default FOO=bar BAR=foo before running slc deploy.
Note that default is just a name, and if you want to use a name other then default you will have to specify it when you deploy with slc deploy -s customName since default is the default name.
Is it possible to set environment variables per nodejs app?
The azure module will read the environment variables
AZURE_SERVICEBUS_NAMESPACE and AZURE_SERVICEBUS_ACCESS_KEY for
information required to connect to your Windows Azure Service Bus. If
these environment variables are not set, you must specify the account
information when calling createServiceBusService.
I would like to set different namespaces/key on a per app lvl instead of global?
(i am hosting it in a ubuntu vm)
Not sure if that is possible. But there is something you can do.
In your application just set those environment variables based on others:
process.env.AZURE_SERVICEBUS_NAMESPACE = process.env.<APP>_AZURE_SERVICEBUS_NAMESPACE
process.env.AZURE_SERVICEBUS_ACCESS_KEY = process.env.<APP>_AZURE_SERVICEBUS_ACCESS_KEY
Its a little more verbose but I am not sure if you can set dynamic environment variables.
I'm trying to deploy website with MSDeploy and team build using some of this ...
/p:DeployOnBuild
/p:DeployTarget=MsDeployPublish
/p:CreatePackageOnPublish=True
/p:MSDeployPublishMethod=InProc
/p:MSDeployServiceURL=localhost
/p:DeployIISAppPath="Default Web Site"
Is there a way to set this website in custom application pool?
If you're using IIS 7, you can use the appPoolProvider to sync application pools to a remote server. See:
http://technet.microsoft.com/en-us/library/dd569070(WS.10).aspx
and
http://blog.torresdal.net/2010/08/16/NoClickWebDeploymentPart2WebDeployAkaMsdeploy.aspx
However, I wasn't able to really get that to work well, and if you're using IIS 6 this won't work anyway. What you can do though is leverage MSDeploy to run a couple commands on the remote server to set the application pool (and register the .NET version on the website).
First, create a batch file that contains something similar to the following:
cscript //nologo C:\Inetpub\AdminScripts\adsutil.vbs
SET w3svc/<IIS number>/Root/<virtual directory>/AppPoolid "<app pool name>"
So, if the IIS number is 1, your virtual directory is "MyDirectory" and the App Pool is named ".NET4.0", the command would be.
cscript //nologo C:\Inetpub\AdminScripts\adsutil.vbs
SET w3svc/1/Root/MyDirectory/AppPoolid ".NET4.0"
You can then run MSDeploy, passing this batch file in as an argument and running it on the remote machine:
MSDeploy
-verb:sync
-source:runCommand="<path to batch file>",waitinterval=5000
-dest:auto,computername=<computer name>
where <path to batch file> is the full path to the batch file you just created above, and is the computer against which you want to run this. Here is a link describing the runCommand argument: http://technet.microsoft.com/en-us/library/ee619740(WS.10).aspx
I'm sure you can set this up as a build step in TFS. We made a little .NET utility that we call as part of our deployment process that creates these batch files and runs the MSDeploy command.
There are also other things you can do in this same method that might prove useful to you:
Register an IIS version:
%windir%\Microsoft.NET\Framework\v4.0.30319\aspnet_regiis.exe
-s w3svc/1/root/MyDirectory
Create an App Pool:
CSCRIPT //nologo %dir%\adsutil.vbs
CREATE w3svc/AppPools/AppPoolName IISApplicationPool
Thanks to http://justsamson.com/2010/06/14/create-virtual-directory-in-iis-6-0-via-command-line/ for the command-line scripts to do the various functionality.
Part of the trick is with /p:IncludeAppPool=true. That changes the deploy script to enable AppPoolExtension. But I haven't figured out how best to actually set the app pool yet. :)
I am trying to automate some of the build process for my asp.net apps by creating the virtual directories it needs and setting all their settings in a batch file. So far I have been able to figure out how to create virtual directories, but how to do you configure them beyond that?
For example I need to be able to set them as an application, set the default document, change framework version, turn on integrated authentication, etc. Does anyone know of any scripts that can do all this without a third party utility? Does the adsutil.vbs admin script do any of this?
Thanks, that documentation helped a lot. I wanted to post the script I ended up with. It generates the virtual directory, sets access settings, makes it an application, sets its isoloation level, sets default document, sets authentication, and even sets the framework version. Its everything I have been looking for. It does it all with the admin scripts that come with IIS5.
mkwebdir -c LocalHost -w "Default Web Site" -v "myvirdirectory","C:\Website Path\..."
adsutil APPCREATEINPROC w3svc/1/root/myvirdirectory
adsutil SET w3svc/1/root/myvirdirectory/AppFriendlyName myvirdirectory
adsutil SET w3svc/1/root/myvirdirectory/AccessScript True
adsutil SET w3svc/1/root/myvirdirectory/AppIsolated 2
adsutil SET w3svc/1/root/myvirdirectory/AuthAnonymous True
adsutil SET w3svc/1/root/myvirdirectory/AuthNTLM False
adsutil SET w3svc/1/root/myvirdirectory/AuthBasic False
adsutil SET w3svc/1/root/myvirdirectory/DefaultDoc index.aspx
adsutil SET w3svc/1/root/myvirdirectory/EnableDefaultDoc True
%windir%\microsoft.net\framework\v2.0.50727\aspnet_regiis -s w3svc/1/root/myvirdirectory
Look at http://msdn.microsoft.com/en-us/library/ms524830%28VS.90%29.aspx and http://msdn.microsoft.com/en-us/library/ms524579%28VS.90%29.aspx.