We have a custom session state applied only on the content delivery
server. so we created a patch configuration for web.config.xdt and included that line
<system.web >
<sessionState xdt:Transform="Replace" mode="Custom" cookieless="false" cookieSameSite="None" timeout="20"
sessionIDManagerType="Sitecore.SessionManagement.ConditionalSessionIdManager, Sitecore.Kernel" customProvider="redis">
<providers>
<add name="mssql" type="Sitecore.SessionProvider.Sql.SqlSessionStateProvider, Sitecore.SessionProvider.Sql" sessionType="Standard"
connectionStringName="session" pollingEnabled="true" pollingInterval="60" pollingMaxExpiredSessionsPerSecond="0" pollingMaxInstances="1"
compression="true"/>
<add name="redis" type="Sitecore.SessionProvider.Redis.RedisSessionStateProvider, Sitecore.SessionProvider.Redis" applicationName="private"
connectionString="redis.sessions" pollingInterval="60" compression="true"/>
</providers>
</sessionState>
</system.web>
But this line should work on CD only not for CM.
How to add this config only for Content Delivery.
I had tried below method but this shows error
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform" xmlns:search="http://www.sitecore.net/xmlconfig/search/" xmlns:role="http://www.sitecore.net/xmlconfig/role/">
<system.web >
<sessionState role:require="ContentDelivery" xdt:Transform="Replace" mode="Custom" cookieless="false" cookieSameSite="None" timeout="20"
sessionIDManagerType="Sitecore.SessionManagement.ConditionalSessionIdManager, Sitecore.Kernel" customProvider="redis">
<providers>
<add name="mssql" type="Sitecore.SessionProvider.Sql.SqlSessionStateProvider, Sitecore.SessionProvider.Sql" sessionType="Standard"
connectionStringName="session" pollingEnabled="true" pollingInterval="60" pollingMaxExpiredSessionsPerSecond="0" pollingMaxInstances="1"
compression="true"/>
<add name="redis" type="Sitecore.SessionProvider.Redis.RedisSessionStateProvider, Sitecore.SessionProvider.Redis" applicationName="private"
connectionString="redis.sessions" pollingInterval="60" compression="true"/>
</providers>
</sessionState>
</system.web>
</configuration>