How to manage settings in a custom IIS managed module - iis

I'm currently developing a IIS 7 managed module, that will be distributed along with a server-side software.
How can I manage settings/configurations within the IIS module itself? For example, how can I let the user set an API-key that will be internally used by the module?
I know that in Apache or in nginx I can add settings directly in the VirtualHosts file (apache) and in nginx configuration files (nginx). I wonder if is there a "best practice" for IIS modules.

Yes there is, you can use web.config files for that, optionally you could define your own Configuration Section, but depending on how complex your configuration is, maybe using the existing appSettings section is enough.
From your module you can just read appSettings like:
How to read appSettings section in the web.config file?
and the best thing is that this includes built-in UX in IIS Manager to manage Application Settings. The bad part is that it will not give validation for your customers, nor "intellisense" to guide them through the configuration.
If you want to define your own section you can look at:
http://www.iis.net/learn/develop/extending-iis-configuration/extending-iis-schema-and-accessing-the-custom-sections-using-mwa
when you add your Schema file, in IIS Manager you will be able to use "Configuration Editor" and will give a simple UI for your customers to set that with validation, data type, collection management, etc.

Related

How to script the install of openam

According to the above documentation, to create the initial configuration I need to open a web browser. This is sound really weird to me. I would like to script the deploy of OpenAM and it seems impossible.
https://wikis.forgerock.org/confluence/display/openam/Deploy+OpenAM
My actual script do the following
Download openam
extract openam
copy .war in tomcat webapp
extract administration tools
extract configuration tool
extract diagnostic tool
download opendj
lauch the setup of opendj with all args
Now I would like to launch the configuration tool of openam with the configuration file I would like to use but it seems OpenAM must be already configured;
The configuration tool require $HOME/openam/boostrap file where $HOME/openam is the configuration folder that should exists once you have already configure it.
Is this true ? To use configuration tool you must already have configured your service ?
Of course not ... 'configurator tool' is meant to initially configure OpenAM.
For the sake of simplicity, you should not use an external data store.
If you really want to use an external configuration store (OpenDJ or Oracle DSEE are the only supported ones currently), the external config store must be up and running before launching 'configurator tool'.
OpenDJ can be configurated in an automated way as well.
If you do not need an external configuration store, just deploy the OpenAM web-app and use 'configurator tool'
Some helpful links:
Using the CLI
configurator.jar documentation
Automated installation and configuration of OpenAM

VS2012 Web Deploy Package to create application pool

I have a web application project in VS2012 which I'm publishing using a "Web Deploy Package". I want this package to include app-pool settings, specifically creating an IIS app-pool and assigning the newly created application to it.
I'm familiar with the option "Include application pool settings used by this Web project" available when the project is configured to use an IIS instance (not IIS Express), but IIS configuration is not part of the project file, and thus not source controlled. What happens when somebody builds a deployment package on a machine that hasn't had IIS meticulously configured? Not ideal.
How else then, can I go about getting AppPool settings into my web deploy package? I understand that the appPoolConfig provider is IIS7+ only, I'm fine with that limitation. I've banged my head against this issue in the past and never found a solution. 18 months later, we've got a new VisualStudio version, and a new web-publishing-pipeline, are there new options to address this? Or maybe something I missed when I first tackled this problem?
Edit
OK, I'm seeing the following as options:
Configure my project to sync settings from an IIS instance. As mentioned, I'm not a fan of this given that it puts settings outside of the project, meaning the environment has to be meticulously configured to build + publish. Plus it drags along other IIS settings I don't want included.
Inject something into the web-publishing-pipeline (WPP) to modify the archive.xml. I've toyed with this in the past and had limited success. One problem is the pipeline isn't exactly co-operative with working directly on the archive.xml file, another problem is some of the more cryptic attributes involved, like MSDeploy.MSDeployProviderOptions which appears to have some Base64 encoded binary? No idea what to put in there.
Find an existing "provider" that can do what I want. I might be out of luck here, the appPoolConfig provider only seems to want to read / write IIS, not, say, an XML file of settings. Does anybody know otherwise?
Write my own "provider" to produce manifest output entries. I'm not sure, is it possible to write a custom provider that writes to a manifest using the name of an existing provider? As in, MyCustomPoolProvider writes appPoolConfig sections into a manifest? This sounds like a potentially painful exercise that may or may not work. Would I still need to figure out the encoding of whatever is going into MSDeploy.MSDeployProviderOptions?
I get the feeling that the fundamental obstacle with Web Deploy for what I'm trying to accomplish, is how strictly it leans on "providers". The pre-existing providers are largely designed for IIS synchronisation, not primary development and publication. It so happens that some of these providers can be relatively easily hooked into via MSBuild, but the majority insist on pulling data from IIS, and that's that.
You are correct in your understanding of the appPoolConfig provider, in that it can only sync between App Pools and can't be provided with the configuration directly. What you could potentially do is keep a copy of the appPool in question in package form (ie. msdeploy -verb:sync -source:appPoolConfig=PoolName -dest:package=apppool.zip) and attempt to hijack the pipeline so that the MSDeploy call adds the application content into the package, leaving the existing content there.
Alternatively, you could always keep the packages separate and deploy them with different calls to MSDeploy.
FYI, MSDeploy.MSDeployProviderOptions is simply an encoded version of the parameters supplied to the provider when it was packaged. For example, -source:dirPath=c:\,ignoreErrors=0x10293847 -dest:package=package.zip would package the ignoreErrors value.

Accessing Azure ServiceConfiguration settings in Node.js

I'm coming to the beta deployment phase of building a Node.js application running through iisnode on Windows Azure. Having set up multiple instances, as well as production/staging separation, my research has led me to the following conclusion:
If I want to change configuration settings on the fly without redeploying code, I need to use Service Configuration .cscfg files.
My problem is that I've stored various configuration settings in the <appSettings> and <iisnode> elements of web.config that I might want to change, which are currently exposed in my Node application via the process global object.
I've looked around MSDN, Node documentation and SO (the usual), and can't find if Node does or can expose Service Configuration settings in the same way. If not, is there a way I can expose them to my application?
Edit: To be more specific, I'm really only looking to move the node_env setting from web.config to Service Configuration, since I'd like to be able to switch from staging to production setup with just a config change. The reason - we're using IP switching to swap between staging and prod, and there are some very minor differences between the two (the URL of the RESTful web service it consumes, for example).
I also know I can configure node_env in an iisnode.yaml file read by iisnode, but that will still recycle the application, and I don't want to modify x yaml files and redeploy, where x is the number of instances of the production/staging application.
You can access the configuration settings via the Azure SDK for Node.js.
To install:
npm install azure
To get the configuration settings:
var azure = require('azure');
azure.RoleEnvironment.getConfigurationSettings(function(error, settings) {
if (!error) {
// You can get the value of setting "setting1" via settings['setting1']
}
});
These settings seem to be held in an XML file located in c:\Config\ folder of the Azure machine.
I'm certain that you're not supposed to access these directly, but you could easily parse this XML and read the settings when node starts.

Enterprise Web Library web.config not currently compatible with Azure?

I am trying to use Enterprise Web Library with Windows Azure. It appears that the web.config file for the EWL project works fine locally, but when I deploy to Azure the application cannot initialize. After logging in and viewing the site locally on Azure, it appears there are several web.config elements EWL requires that are locked on Azure. I've had to edit the following in order to have the application initialize on Azure:
Remove <serverRuntime uploadReadAheadSize="8388608" />.
Remove everything nested inside of the modules element.
The application seems to run fine on Azure after removing these parts.
The Web.config elements you removed are important to ensure that EWL works properly: uploadReadAheadSize fixes a problem with client certificate authentication, and using <clear/> in the <modules> section makes the behavior of EWL applications consistent across different servers by keeping the same set of modules in the pipeline regardless of what IIS features are installed on the machine.
There has to be a way to unlock these config sections in an Azure web role. Assuming they are locked in the web role's applicationHost.config file, maybe you can modify this file using a startup script as described in this answer: https://stackoverflow.com/a/10140024/35349.
I am not very familiar with Enterprise Library. If William’s suggestions do not help, please check your web.config to see if you’re missing any configuration sections. On your local machine, when you install Enterprise Library, it may modify machine.config to add certain configurations. But they may not exist in the cloud. So please search your local machine.config to see if there’re any Enterprise Library specific sections, and then add them to your web.config.
Best Regards,
Ming Xu.

Is Sharepoint local bin deployment possible?

I’ve inherited a SharePoint solution where all the projects have strong names and are deployed to the GAC.
I find that its difficult working with projects that are signed, it slows down development, testing and makes debugging difficult.
So, is it possible that SharePoint projects, WebParts, Codebehinds etc be deployed to the local bin instead of the GAC? Is it considered bad practice to deploy to the local bin?
It is always recommanded to use the Bin directory over to GAC, for all the WebParts & Code Behinds. As that will restrict the Trust given to the code, GAC provides full trust to the code.
After deploying to the bin you can gain the required permission using CAS.
I recommend you to read the chapter Application Security of Inside Windows SharePoint Services 3.0 Book
Note: You will have to deploy your code Feature Handler, Timer Job etc to the GAC
By default, SharePoint Web applications are only allowed to run with a very restrictive trust level of WSS_Minimal. If we want to have our Web Part deployed to the bin folder, then in order for it to run we must do one of two things: either set the trust level to WSS_Medium or WSS_Full in the web.config, or create a custom CAS policy that will allow this assembly's managed code to run. In a production environment, you will need to make an informed decision on this yourself.
I would use the GAC for local development and testing and use the bin in production.
To debug locally, check the following in your config file:
customErrors=off
Enable Stack Traces by adding CallStack=”true” to the SafeMode tag
Set the compilation debug attribute to "true"

Resources