Share via


Scripted Configuration of AppFabric

This sample walks you through the series of actions necessary to configure AppFabric to use domain accounts in conjunction with integrated security authentication to connect to a remote database.

Note

Samples are provided for educational purposes only. They are not intended to be used in a production environment and have not been tested in a production environment. Microsoft does not provide technical support for these samples.

Prerequisites

Users should be familiar with Windows PowerShell scripting and general scripting concepts as well as with the Security Model in AppFabric. The sample assumes the following:

  • Default AppFabric installation has been performed.

  • Databases have been prepared. (Monitoring and persistence databases have been initialized with the proper security settings on a remote computer.)

    • Databases can be prepared by using the following cmdlets: Initialize-ASMonitoringDatabase, Initialize-ASPersistenceSqlDatabase.

    • Databases can be customized in the script by editing the $Persistence_ConnectionStringName, $Persistence_ConnectionString, $Monitoring_ConnectionString, and $Monitoring_ConnectionStringName variables in the User Defined Variables section of the sample.

  • Domain users and groups have been created. The sample is prepopulated with values matching the following table.

Domain: corp.contoso.com

AppFabric Role Domain Group Domain User

Administrators

AS_Administrators

dubAdmin

Users

AS_Users

dubUser

Observers

AS_Observers

dubObserver

  • The users of the Administrator role must have the “Logon as a service” privileges because they will be used to run the event collection and workflow management services.

  • The identity of the application pool used to run AppFabric applications must be a member of the Users role.

  • The application pool must be a .NET Framework 4 application pool.

Sample Location and Files

The sample files include the following:

  • Readme.mhtml

  • code\scriptedConfigurationOfDublin.ps1

  • code\scriptedUnconfigurationOfDublin.ps1

Setting Up and Running This Sample

To run this script:

  1. Open a command prompt as administrator.

  2. Navigate to the folder containing the sample .ps1 files.

  3. Execute the following command: powershell -ExecutionPolicy RemoteSigned -File scriptedConfigurationOfDublin.ps1

Understanding This Sample

The script has four functions and three sections.

Functions

  • GetUserCredential prompts the user to provide a user name and password and stores the information securely in a PSCredential object to be used in the script.

  • SetServiceCredential modifies the logon user and password for a specified service.

  • GetSqlConnectionString generates a SQL connection string to the specified server and database.

  • UpdateConnectionString adds or updates the specified connection string to the root web.config configuration file.

Sections

  • In the User Defined Variables section you can find the list of variables used in the script. You can modify these variables to customize the script to the specifics of the environment.

  • In the Collect Credentials section, the script calls the GetUserCredential function to obtain credentials from the user for use in the configuration of the system services (Workflow Management service and Event Collection service).

  • In the Update Configuration section, the configuration is applied based on the defined variables and the collected information.

The script performs the following configuration actions:

  1. Add the AppFabric Administrator user to the local Administrators group.

  2. Set Event Collection service configuration.

  3. Set Workflow Management service configuration.

  4. Add connection strings to the connection strings section in root web.config.

  5. Create an Instance Store entry for the persistence connection string.

  6. Set the persistence behavior.

  7. Set the monitoring behavior.

Removing This Sample

To revert the configuration, run scriptedUnConfigurationOfDublin.ps1.

powershell -ExecutionPolicy RemoteSigned -File scriptedUnConfigurationOfDublin.ps1

This script performs the following actions:

  1. Remove the AppFabric Administrator user from the local Administrators group

  2. The Administrator user needs to be customized in the unconfiguration script to match the custom user used in the configuration.

  3. Revert Event Collection service configuration.

  4. Revert Workflow Management service configuration.

  5. Remove the persistence behavior.

  6. Remove the Instance Store registration for the persistence connection string.

After the script is run, you must manually delete monitoring behavior from the root web.config file.

<default enabled="true" connectionStringName="monitoringDB" monitoringLevel="HealthMonitoring" />

Any connection strings added by the configuration script must also be removed manually.

  2012-09-12