Configuring a Deployment Environment
You can use the configuration tools at design time to customize the run-time settings of your configuration to suit a particular deployment environment. This feature is useful if you have multiple environments that share the same basic configuration but require different property settings. For example, you may have a development environment that uses one connection string for the Data Access Application Block and a test environment that uses a different one.
Every environment you configure maintains its own environment delta file (using the file name extension .dconfig), which is updated after you save the configuration. This environment delta file contains the differences between this environment and the standard environment, plus some additional metadata for merging the differences into a new complete configuration file that you can deploy. The main advantage is that you can distribute an environment delta file separately from the original configuration file and allow management by users or administrators who have access to all the passwords, server names, and other details of that environment.
Therefore, instead of maintaining multiple configuration files or having to change a file manually or programmatically, you can create a base configuration file (.config) and an environment delta file that contains the differences (.dconfig).
You can use environmental property overrides to override specific properties for a block and for the properties of the child elements for a block, and then create a deployment environment by saving the configuration delta. Then you can export the merged configuration file and copy or deploy it to production.
The lifetime of the main configuration and the lifetime of the environmental overrides are linked only through the structure of the files. The following operations can be performed on environment delta files:
- File | Save: Saving the main configuration also saves any related environments. The environment .dconfig file is saved using the path specified in the Environment Delta File property of the environment override.
- File | Save As: Specifying a new path or name only affects the main configuration file. You must change the path and name specified in the Environment Delta File property of the environment override to change the environment name and path.
- File | New: Creating a new configuration clears the existing configuration and all open environments, creates a new empty configuration file, and clears the validation results. You are prompted to save the file being cleared if it has any changes.
- Validation: You can save configuration and environment files only if all files are valid. Either all are saved or none are saved.
To open or create a configuration file in order to create a deployment environment
- Click on Open in the File menu to open an existing .config file, or click New on the File menu to create a new file, and then add the appropriately configured application blocks in the configuration tool.
- Browse to the configuration file you want or the location where you want to save the new file.
- Select a configuration file and view the configured application blocks.
To customize a block's properties for a run time environment
- On the Environments menu, click New Environment to open a new environment configuration file. You must have an environment open in order for the property overrides to be displayed.
- Click the Environment property expander chevron to open or close the environment properties edit pane.
Note: You can have multiple environment configuration files open simultaneously. Each is displayed by name.
- In the edit pane, set the properties. The Environment Delta File property is the name of the delta file. If you want to encrypt the file, set the Protection Provider property by selecting a provider from the drop-down list. The Environment Configuration File property is the name of the merged configuration file. The Environment Name property is the name of the environment.
- Repeat the previous steps for each environment you want to create.
- To customize a block's properties for this environment, add the application block to the configuration. Open the Blocks menu and select the block you require by clicking on its settings; for example, Add Logging Settings.
- Click the blocks properties expander arrow to view the list of properties. In the Overrides on [environment name] drop-down box, click Override Properties to enable setting the block's properties for this environment.
Note: If you rename an environment, the updated name may not be displayed in the Overrides on [environment name] property. However, it will be shown the next time you open the configuration in the tool.
- Click the expander arrow on the left of the named environment listed under the block's properties, in this screen shot to the left of Overrides on TestPlatform, to display the properties for that named environment. You can then use each property drop-down edit box to edit the properties appropriately for your requirements.
- Repeat steps 4, 5 and 6 for each block you want to customize.
|The configuration tool allows you to add more than one additional environment. Each configured item then displays a set of properties for the base configuration file and a set of properties specific to each of the named environments (with the exception of properties that cannot be overridden). This enables you to edit the base configuration file properties or the delta file properties for a specific named environment.|
To customize a block's child element properties for a run-time environment
- Click on the child expander arrow to the left of the block name—Logging Settings in this example—to display the child elements if they are not already visible.
- In each of the child elements that you want to configure for different environments, click on the property expander for the environment you want to edit—Overrides on TestPlatform in this example.
- Set the Overrides on [environment name] property to Override Properties, and then edit the properties you want to override for that environment. This screenshot shows how you can specify different property values for a Logging block category filter and a target listener in different environments.
To save a configuration (.config) file and a delta environment (.dconfig) file
- Select Save or Save As on the File menu to save both the named environment configuration file and the delta file; if either file name is blank you will be prompted to select a path and file name.
- Click Save. The configuration file is saved and you are prompted for a path and name to save the delta environment file.
- Click SaveAs and you are prompted first for a path and name to save the configuration file. Then you are prompted for a path and name to save the delta environment file.
To create a merged environment configuration file
- Right-click on the named Environment for which you want to create a merged deployment configuration file, then click Export Merged Environment Configuration File.
- To save just the differences between the main and an environment override configuration, click Save Environment Delta File.
You can also merge your main configuration file and your environment delta file from the command line. This is useful if you want to use build scripts or automate deployment. To merge the configuration files, you must provide both the main configuration file and the environment delta file in your command. The following command shows the syntax.
MergeConfiguration.exe configFile deltaFile [mergedFile]
The parameters are the following:
- configFile. This is the main configuration file (.config). It is merged with the environment delta file.
- deltaFile. This is the environment delta file (.dconfig). It contains the information that is merged into the main configuration file.
- mergedFile. This is the output file. This file results from merging configFile with deltaFile. If you do not specify the mergedFile, the file name stored in deltaFile is used.
|The environment delta files (.dconfig) you create must be reloaded each time you close and reopen the configuration file.|
To reload an environment delta configuration file
- Start the Enterprise Library configuration console or open the configuration file in the Visual Studio configuration editor. For more information on the Enterprise Library configuration console see Using the Configuration Tools.
- On the File menu, click Open.
- In the Open dialog box, browse to and select the application .config file you want to reload.
- In the Enterprise Library configuration tool, left-click Environments, and then click OpenDelta File.
- In the Open dialog box, select the environment delta configuration (.dconfig) file you want to reload, and then click the Open button.
- Save the changes through the File menu or the right-click shortcut menu on the environment item, as described in the previous procedure.