---
title: "Configure your environment"
slug: "configure-your-environment"
abstract: "Create an environment-specific configuration to control your environment settings, using a transformation file and custom environment variables."
---
# Configure your environment

You can create an environment configuration file that allows you to define and control environment settings for all your environments (for example, development and production) in one place. You do this by creating a new application setting that's specific to the current environment, and overrides other environment configurations.

To create an environment-specific configuration:

1. Create a `web.config.xdt` transformation file that includes a new app setting, for example, setting the environment name to `DEV`:

    ```xml
    <?xml version="1.0" encoding="utf-8"?>
    <configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
      <appSettings>
        <add xdt:Transform="InsertIfMissing" xdt:Locator="Match(key)" key="customenvironment:define" value="DEV" />
      </appSettings>
    </configuration>
    ```

2. Include the web config file in the Platform project:

    ```xml
    <ItemGroup>
        <Content Include="xdts\Web.config.xdt">
          <CopyToOutputDirectory>Always</CopyToOutputDirectory>
        </Content>
     </ItemGroup>
    ```

3. In the build configuration file `(xmcloud.build.json`), create a mapping for the `xdt` file:

    ```json
    "transforms": [
          {
            "xdtPath": "/xdts/web.config.xdt",
            "targetPath": "/web.config"
          }
        ]
    ```
    > [!note]
    > **XM Cloud is now SitecoreAI**
    > Some code examples, images, and UI labels may still use XM Cloud while engineering assets are being updated.

4. [Create an environment variable](https://doc.sitecore.com/sai/en/developers/sitecoreai/deploying-sitecoreai/deploy-app/manage-an-environment/environment-variables/manage-environment-variables-in-the-deploy-app.html "Manage environment variables in the Deploy app") named `SITECORE_APPSETTINGS_customenvironment__define`. This overrides the `customenvironment` app setting. Enter a meaningful value for the variable: in this example, in step 1, the default name is set to DEV, and you can use this variable to change it to PROD.
5. Create an environment-specific configuration in the `settings` attribute and include it in the project. This example shows how you use the new app setting to drive other configurations:

    ```xml
    <?xml version="1.0" encoding="utf-8" ?>
    <configuration xmlns:patch="http://www.sitecore.net/xmlconfig/" xmlns:customenvironment="http://www.sitecore.net/xmlconfig/pskenvironment/">
      <sitecore>
        <settings>
          <setting name="Xdt.Test" value="None">
            <patch:attribute name="value" value="DEV" customenvironment:require="DEV" />
            <patch:attribute name="value" value="QA" customenvironment:require="QA" />
          </setting>
        </settings>
      </sitecore>
    </configuration>
    ```

6. Create a build and deploy it. This is required for the changes to take effect.
