Walkthrough: Enabling the DAM connector in an environment deployed to XM Cloud

To use Sitecore DAM in an environment deployed to XM Cloud, you must configure and enable the DAM connector.

This walkthrough describes how to:

  • Configure and enable the DAM connector

  • Configure a DAM connection

  • Configure CORS for DAM

Prerequisites

Before you enable the DAM connector in an environment deployed to XM Cloud, you must have:

Configure and enable the DAM connector in the XM Cloud Deploy app

To configure and enable the DAM connector:

  1. Log in to the XM Cloud Deploy app.

  2. On the navigation pane of the XM Cloud Deploy app, click Projects.

  3. On the Projects page, click the project that contains the environment where you want to enable the DAM connector.

  4. On the project page, click the environment where you want to enable the DAM connector.

  5. On the environment page, click Variables, then click Create variable.

  6. Create the following variables. For each variable, set the Target to CM.

    Variable

    Value

    Description

    Sitecore_ConnectionStrings_DAM_dot_ContentHub

    ClientId={client_id};ClientSecret={client_secret};UserName={username};Password={password};URI={uri};

    Example: ClientId=App;ClientSecret=a51a8fb6-4f57-1234;UserName=john;Password=hunter2;URI=https://example.com/;

    The Client ID and Client Secret of the connector's OAuth client.

    The username and password of the user you created in Content Hub.

    uri of your Content Hub instance.

    Sitecore_ConnectionStrings_DAM_dot_SearchPage

    Sitecore Content Hub search page URI

    Example: https://sitecore-contenthub-dam-uri/en-us/sitecore-dam-connect/approved-assets

    The URI for the page that opens the DAM in an IFrame.

    Sitecore_ConnectionStrings_DAM_dot_ExternalRedirectKey

    Sitecore

    SITECORE_AppSettings_damEnabled__define

    yes

    By default, when you deploy an environment to XM Cloud, the DAM connector is disabled. To enable the connector, set this value to yes.

Configure a DAM connection

To configure a DAM connection:

  1. Clone the source control repository linked to your XM Cloud environment.

  2. In the XM Cloud repository folder, create the following subfolder:

    RequestResponse
    {Project Repo Name}/src/platform/App_Data/Xdts
  3. Open the Xdts subfolder, create a file named Web.config.xdt, and open it for editing. Add the instructions to modify the web.config file for the DAM configuration. For example:

    RequestResponsexml
    <?xml version="1.0" encoding="utf-8"?>
    <configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
        <location path="sitecore">
            <system.webServer>
                <httpProtocol>
                    <customHeaders>
    	            <!--DO NOT USE THIS CONTENT SECURITY POLICY EXAMPLE IN YOUR SOLUTION-->
                        <add name="Content-Security-Policy" value="default-src 'self' 'unsafe-inline' 'unsafe-eval' https://apps.sitecore.net; img-src 'self' data: https://your-content-hub-url.cloud/ https://s.gravatar.com https://*.wp.com/cdn.auth0.com/avatars; style-src 'self' 'unsafe-inline' https://fonts.googleapis.com; font-src 'self' 'unsafe-inline' https://fonts.gstatic.com; block-all-mixed-content; child-src 'self' https://your-content-hub-url.cloud/; connect-src 'self' https://your-content-hub-url.cloud/; media-src https://your-content-hub-url.cloud/" xdt:Transform="Replace" xdt:Locator="Match(name)"/> 
                    </customHeaders>
                </httpProtocol>
            </system.webServer>
        </location>
    </configuration>

    Ensure that the Content-Security-Policy tag contains the URL of the Content Hub instance (for example, content-hub-url.stylelabs.com), other delivery hostnames (for example, content-hub-url-delivery.stylelabs.cloud), and generated public links (for example, content-hub-url.stylelabs.com:8686).

    Note

    In Content Hub, you can configure different delivery hostnames for public links by using the AssetExtensionDataConfigurationSetting setting.

    If you have configured different hostnames, you must add all the hostnames as sources to the Content-Security-Policy parameter, in the img-src, child-src, and connect-src properties.

  4. Save the file.

  5. To include the web.config file transformation in the XM Cloud build configuration, navigate to the root folder, and open the xmcloud.build.json file for editing. Add the following properties:

    RequestResponsejson
    "transforms": [
        {
            "xdtPath": "/app_data/xdts/web.config.xdt",
            "targetPath": "/web.config"
        }
    ]
  6. In the src/platform folder, open the Platform.csproj file and add the following:

    RequestResponsexml
    <ItemGroup>
        <Content Include="App_Data\**" />
    </ItemGroup>
  7. Commit your changes and push them to the remote repository.

  8. In the XM Cloud Deploy app, create a build and deploy it to your environment.

Configure CORS for DAM

To enable the Content Hub DAM iframe to successfully display in the Content Editor and XM Cloud Pages media item picker, you need to add the Pages and environment host name URLs to Content Hub CORS configuration.

To configure CORS for DAM:

  1. On the Sitecore DAM main menu, click Manage, then Settings.

  2. On the Settings page, click PortalConfiguration, then click CORSConfiguration.

  3. In URL field, enter the URL of XM Cloud Pages: https://pages.sitecorecloud.io/, then click Add.

  4. In URL field, enter https://, then the environment host name of your XM Cloud environment, for example: https://my-xmc-environment-host-name.cloud/, then click Add. You can find your environment host name in your environment details.

    You can now display DAM assets in the Content Editor.

Do you have some feedback for us?

If you have suggestions for improving this article,