# Configure multi-regional deployment with authentication

To configure the delivery of static personalized content in multiple regions, while allowing users to login and submit forms, you need to make several adjustments to some of the configuration files.# Configure multi-regional deployment with authentication

## 1. Modify the Web.config file

Open the web.config file of all Sitefinity CMS instances that are part of the Primary and the Secondary region and make the following configurations:

* Turn on read-only mode of configurations, by adding `restrictionLevel` in section `<telerik>`.
* Ensure that all Sitefinity CMS instances in each region have the same values for `machineKey` property.

> success **EXAMPLE**: Use the following configuration for the **Primary region** and the **Secondary region(s)**.\
> The `<telerik>` section of all Sitefinity CMS instances that are in the primary and the secondary regions, should look in the following way:
>
> ````XML
> <telerik>
>     <sitefinity>
>        <sitefinityConfig storageMode="Auto" restrictionLevel="ReadOnlyConfigFile" />
>  </sitefinity>
> </telerik>
> ```# Configure multi-regional deployment with authentication
> ````

## 2. Modify the DataConfig.config file

Open the `DataConfig.config` file and make the following configurations:

* Define the connection strings to the primary, the secondary, and the session database.\
  The *Primary region* must have a connection to the *Primary database* and the *Session database*. The *Secondary region* should have a connection to the *Secondary database* and the *Session database*.
* Define the replication type.\
  You should set the *Primary database* to have `replication="Master"` and the *Secondary database* to have `replication="Slave"`.
* Define the read-only state.\
  The *Primary database* must not be read-only, while the *Secondary database* must be read-only.
* In *Secondary region(s)* define database connection named `SitefinityShared`. Point this connection to *Primary database*.

> success **EXAMPLE**: Use the following samples for the configuration of both regions:
> **Primary region**: The `DataConfig.config` file of all Sitefinity CMS instances that participate in the *Primary region* should look in the following way:
>
> ```XML
> <?xml version="1.0" encoding="utf-8"?>
> <dataConfig xmlns:config="urn:telerik:sitefinity:configuration" xmlns:type="urn:telerik:sitefinity:configuration:type" initialized="True">
>    <connectionStrings>
>        <add connectionString="" dbType="SqlAzure" replication="Master" readOnly="false" name="Sitefinity" />
>        <add connectionString="" dbType="SqlAzure" name="SessionConnection" />
>    </connectionStrings>
> </dataConfig>
> ```
>
> **Secondary region(s)**: The `DataConfig.config` file of all Sitefinity CMS instances that participate in the *Secondary region* should look in the following way:
>
> ```XML
> <?xml version="1.0" encoding="utf-8"?>
> <dataConfig xmlns:config="urn:telerik:sitefinity:configuration" xmlns:type="urn:telerik:sitefinity:configuration:type" config:version="11.1.7000.0" initialized="True">
>    <connectionStrings>
>        <add connectionString="" dbType="SqlAzure" replication="Slave" readOnly="true" name="Sitefinity" />
>        <add connectionString="" dbType="SqlAzure" name="SessionConnection" replication="None" />
>      <add connectionString="" dbType="SqlAzure" name="SitefinityShared" />
>    </connectionStrings>
> </dataConfig>
> ```

> info **NOTE**: Take note of the following configurations:
>
> * The `replication="Master"` attribute is mandatory in the database connection string for the *Primary region*.
> * The `replication="Slave"` attribute is mandatory in the database connection string for the *Secondary region(s)*.
> * The `replication="None"` attribute in the *Session database* connection string is not required and could be omitted.

## 3. Modify the LibrariesConfig.config file

Open the `LibrariesConfig` file of the *Secondary region* and for every Sitefinity CMS instance that is part of the region, make the following configurations:

* Enable dynamic resizing of images.
* Because dynamic resizing of images requires database writes operations, reconfigure the metadata provider in the *Secondary region(s)* to use the *Primary database*.

> success **EXAMPLE**: Use the following configuration for the *Secondary region(s)*.\
> The `LibrariesConfig.config` file of all Sitefinity CMS instances that are part of the *Secondary region*, should look like this:
>
> ```XML
> <?xml version="1.0" encoding="utf-8"?>
> <librariesConfig xmlns:config="urn:telerik:sitefinity:configuration" xmlns:type="urn:telerik:sitefinity:configuration:type">
>    <images allowDynamicResizing="False" storeDynamicResizedImagesAsThumbnails="True" />
>        <providers>
>        <add connectionString="SitefinityShared" name="OpenAccessDataProvider" config:flags="1" />
>    </providers>
> </librariesConfig>
> ```

> info **NOTE**: If you do not have a `LibrariesConfig.config` file, create one and place it in folder `~\App_Data\Sitefinity\Configuration`.# Configure multi-regional deployment with authentication

## 4. Modify the SchedulingConfig.config file

Open the `SchedulingConfig` file of the *Primary* and the *Secondary* *region* and for every Sitefinity CMS instance that is part of the respective region, reconfigure the config file to use the respective Session database, which is dedicated per region.

> success **EXAMPLE**: Use the following configuration for the *Primary region* and the *Secondary region(s)*.\
> The `SchedulingConfig.config` file of all Sitefinity CMS instances that are part of the *Primary* and the *Secondary region*, should look like this:
>
> ```XML
> <?xml version="1.0" encoding="utf-8"?>
> <schedulingConfig xmlns:config="urn:telerik:sitefinity:configuration" xmlns:type="urn:telerik:sitefinity:configuration:type">
>    <providerSettings>
>        <add connectionString="SessionConnection" name="OASchedulingProvider" config:flags="1" />
>    </providerSettings>
> </schedulingConfig>
> ```

> info **NOTE**: If you do not have a `SchedulingConfig.config` file, create one and place it in folder `~\App_Data\Sitefinity\Configuration`.

##

5. Modify the StatisticsConfig.config file

Statistics must be stored in the respective *Session database*. Open the `StatisticsConfig.config` file of the *Primary* and the *Secondary region* and for every Sitefinity CMS instance that is part of the respective region, reconfigure the config file to use the respective *Session database*, which is dedicated per region.

> success **EXAMPLE**: Use the following configuration for the *Primary region* and the *Secondary region(s)*.\
> The `StatisticsConfig.config` file of all Sitefinity CMS instances that are part of the *Primary* and the *Secondary region*, should look like this:
>
> ```XML
> <?xml version="1.0" encoding="utf-8"?>
> <statisticsConfig xmlns:config="urn:telerik:sitefinity:configuration" xmlns:type="urn:telerik:sitefinity:configuration:type">
>    <providers>
>        <add connectionString="SessionConnection" name="OpenAccessDataProvider" config:flags="1" />
>    </providers>
> </statisticsConfig>
> ```

> info  **NOTE**: If you do not have a `StatisticsConfig.config` file, create one and place it in folder `~\App_Data\Sitefinity\Configuration`.

## 6. Modify the UserActivityConfig.config file

User activities must be stored in the respective Session database. Open the `UserActivityConfig.config` file of the *Primary* and the *Secondary region* and for every Sitefinity CMS instance that is part of the respective region, reconfigure the config file to use the respective *Session database*, which is dedicated per region.

> success **EXAMPLE**: Use the following configuration for the *Primary region* and the *Secondary region(s)*.\
> The `UserActivityConfig.config` file of all Sitefinity CMS instances that are part of the *Primary* and the *Secondary region*, should look like this:
>
> ```XML
> <?xml version="1.0" encoding="utf-8"?>
> <userActivityConfig xmlns:config="urn:telerik:sitefinity:configuration" xmlns:type="urn:telerik:sitefinity:configuration:type">
>    <providers>
>        <add connectionString="SessionConnection" name="OpenAccessUserActivityProvider" config:flags="1" />
>    </providers>
> </userActivityConfig>
> ```

> info  **NOTE**: If you do not have a `UserActivityConfig.config` file, create one and place it in folder `~\App_Data\Sitefinity\Configuration`.# Configure multi-regional deployment with authentication

## 7. Modify the UserProfilesConfig.config file

Because user profiles requires database write operations, open the `UserProfilesConfig.config` of all Sitefinity CMS instances that are part of the *Secondary region(s)* and reconfigure the corresponding provider to use the *Primary database*.

> success **EXAMPLE**: Use the following configuration for the *Secondary region(s)*.\
> The `UserProfilesConfig.config` file of all Sitefinity CMS instances that are part of the *Secondary region*, should look like this:
>
> ```XML
> <?xml version="1.0" encoding="utf-8"?>
> <userProfilesConfig xmlns:config="urn:telerik:sitefinity:configuration" xmlns:type="urn:telerik:sitefinity:configuration:type">
>    <providers>
>        <add connectionString="SitefinityShared" name="OpenAccessProfileProvider" config:flags="1" />
>    </providers>
> </userProfilesConfig>
> ```

> info **NOTE**: If you do not have a `UserProfilesConfig.config` file, create one and place it in folder `~\App_Data\Sitefinity\Configuration`.# Configure multi-regional deployment with authentication

## 8. Modify the MetadataConfig.config file

You should add a metadata provider that uses the respective *Session database*. Open the `MetadataConfig.config` file of the *Primary* and the *Secondary region* and for every Sitefinity CMS instance that is part of the respective region, reconfigure the config file to use the respective *Session database*, which is dedicated per region.

> success **EXAMPLE**: Use the following configuration for the *Primary region* and the *Secondary region(s)*.\
> The `MetadataConfig.config` file of all Sitefinity CMS instances that are part of the *Primary* and the *Secondary region*, should look like this:
>
> ```XML
> <?xml version="1.0" encoding="utf-8"?>
> <metadataConfig xmlns:config="urn:telerik:sitefinity:configuration" xmlns:type="urn:telerik:sitefinity:configuration:type" >
>    <providers>
>        <add connectionString="SessionConnection" type="Telerik.Sitefinity.Data.Metadata.OpenAccessMetaDataProvider, Telerik.Sitefinity" name="SessionProvider" />
>    </providers>
> </metadataConfig>
> ```

> info  **NOTE**: If you do not have a `MetadataConfig.config` file, create one and place it in folder `~\App_Data\Sitefinity\Configuration`.

## 9. Modify the OutputCacheConfig.config file

Output cache feature must use the respective Session database. Open the `OutputCacheConfig.config` file of the *Primary* and the *Secondary region* and for every Sitefinity CMS instance that is part of the respective region, reconfigure the config file to use the respective Session database, which is dedicated per region.

> success **EXAMPLE**: Use the following configuration for the *Primary region* and the *Secondary region(s)*.\
> The `OutputCacheConfig.config` file of all Sitefinity CMS instances that are part of the *Primary* and the *Secondary region*, should look like this:
>
> ```XML
> <?xml version="1.0" encoding="utf-8"?>
> <outputCacheConfig xmlns:config="urn:telerik:sitefinity:configuration" xmlns:type="urn:telerik:sitefinity:configuration:type"><providers>	<add connectionString="SessionConnection" type="Telerik.Sitefinity.Web.OutputCache.Data.OpenAccessOutputCacheRelationsProvider, Telerik.Sitefinity"  name="OpenAccessOutputCacheRelationsProvider"  /></providers>
> </outputCacheConfig>
> ```

> info  **NOTE:** If you do not have a `OutputCacheConfig.config` file, create one and place it in folder `~\App_Data\Sitefinity\Configuration`.# Configure multi-regional deployment with authentication

## 10. Modify the FormsConfig.config file

Because form submission requires database write operations, open the `FormsConfig.config` of all Sitefinity CMS instances that are part of the *Secondary region(s)* and reconfigure the corresponding provider to use the *Primary database*.

> success **EXAMPLE**: Use the following configuration for the *Secondary region(s)*.\
> The `FormsConfig.config` file of all Sitefinity CMS instances that are part of the *Secondary region* should look like this:
>
> ```XML
> <?xml version="1.0" encoding="utf-8"?>
> <formsConfig xmlns:config="urn:telerik:sitefinity:configuration" xmlns:type="urn:telerik:sitefinity:configuration:type">
>    <providers>
>        <add connectionString="SitefinityShared" name="OpenAccessDataProvider" config:flags="1" />
>    </providers>
> </formsConfig>
> ```

> info **NOTE**: If you do not have a `FormsConfig.config` file, create one and place it in folder `~\App_Data\Sitefinity\Configuration`.

## 11. Modify the SystemConfig.config file

Open the SystemConfig.config file and make the following configurations:

* To set the Load Balancing Redis instance used for communication among nodes in each region, perform the following:
  * Locate this setting: `systemConfig` » `loadBalancingConfig `» **`redisSettings`**
  * In the `redisSettings `node, change the `ConnectionString` attribute to the Redis  instance connection string
* Enable synchronization across the regions.
* To set the connection string to the replication transport Redis instance used as a communication channel between the regions, perform the following:
  * Locate this setting: `systemConfig `» `loadBalancingConfig `» `replicationSyncSettings » Transporter `» `add`
  * In the `add `node, change the `ConnectionString `attribute to the Redis instance connection string
* Define a prefix for cache records.
* Enable the backend UI of both regions.

> success **EXAMPLE**: Use the following configuration for the *Primary region* and the *Secondary region(s)*.\
> The `SystemConfig.config` file of all Sitefinity CMS instances that are part of the *Primary* and the *Secondary region* should look like this:
>
> ```XML
> <?xml version="1.0" encoding="utf-8"?>
> <systemConfig xmlns:config="urn:telerik:sitefinity:configuration" xmlns:type="urn:telerik:sitefinity:configuration:type" disableBackendUI="True" >
>    <loadBalancingConfig>
>        <redisSettings ConnectionString="***************" />
>        <replicationSyncSettings Enabled="True">
>            <Transporter>
>                <add ConnectionString="***************" Prefix="sf-replication" TypeName="Telerik.Sitefinity.LoadBalancing.Replication.RedisMessageTransporter" config:flags="1" />
>            </Transporter>
>        </replicationSyncSettings>
>    </loadBalancingConfig>
> </systemConfig>
> ```

> info **NOTE**: If you do not have a `SystemConfig.config` file, create one and place it in folder `~\App_Data\Sitefinity\Configuration`.

> info  **NOTE**: Depending on your needs, you may use the same Redis instance or use two Redis instances for load balancing and replication transport.

> info  **NOTE**: Ensure that the load balancing Redis setting is using a different value for the `Prefix `attribute from the replication transport Redis `Prefix`setting. Unless you explicitly change it, the default value for load balancing Redis prefix is "`sf-`".

# Configure multi-regional deployment with authentication

## 12. Modify the SecurityConfig.config file

Open the `SecurityConfig.config` file and make the following configurations:

* Ensure that all Sitefinity CMS instances in each region have exactly the same values for `authCookieName`, `rolesCookieName`, `loggingCookieName`, `validationKey` and `decryptionKey` properties.
* Configure membership, role, and security providers in the *Secondary region* to use `SitefinityShared` database connection. Point this connection to the *Primary database*.

> success **EXAMPLE**: Use the following configuration for the `Secondary region(s)`.\
> The `SecurityConfig.config` file of all Sitefinity CMS instances that are part of the Secondary region, should look like this:
>
> ```XML
> <?xml version="1.0" encoding="utf-8"?>
> <securityConfig xmlns:config="urn:telerik:sitefinity:configuration" xmlns:type="urn:telerik:sitefinity:configuration:type">… <securityProviders>	<add connectionString="SitefinityShared" name="Default" config:flags="1" /></securityProviders><roleProviders>	<add connectionString="SitefinityShared" name="Default" config:flags="1" />	<add connectionString="SitefinityShared" name="AppRoles" config:flags="1" /></roleProviders><membershipProviders>	<add connectionString="SitefinityShared" name="Default" config:flags="1" /></membershipProviders>
> </securityConfig>
> ```

## 13. Restart the application.

Restart Sitefinity CMS by restarting the IIS application pool.
