章鱼部署变换SessionState的提供商
问题描述:
,为我们的本地调试,我们使用这个在我们的web.config章鱼部署变换SessionState的提供商
<sessionState mode="Custom" customProvider="MyAppStateStore" timeout="480">
<providers>
<add name="MyAppStateStore" type="Microsoft.Web.Redis.RedisSessionStateProvider"
applicationName="MyApp"
host="127.0.0.1"
accessKey=""
ssl="false" />
</providers>
</sessionState>
在我们的开发服务器,我们希望它是这样的:
<sessionState mode="Custom" customProvider="MyAppStateStore" timeout="480">
<providers>
<add name="MyAppStateStore" type="Microsoft.Web.Redis.RedisSessionStateProvider"
applicationName="MyApp"
host="www.oursite.com.backends"
port="1234"
databaseId="1"
accessKey=""
connectionTimeoutInMilliseconds="5000"
operationTimeoutInMilliseconds="1000"
throwOnError="true"
ssl="false" />
</providers>
</sessionState>
对于大多数我们的web.config appSettings我们使用OD的变量进行部署期间的转换。有没有办法在变换中包含像这样的复杂设置,而不使用变换.config
文件?
答
使用配置变换(web..config)是最简单的方法。如果要使用占位符,可以将它与“文件中的替代变量”功能结合使用。例如:
web.production.config:
<?xml version="1.0"?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<sessionState mode="Custom" customProvider="MyAppStateStore" timeout="480">
<providers>
<add
xdt:Transform="Replace"
xdt:Locator="Match(name)"
name="MyAppStateStore"
type="Microsoft.Web.Redis.RedisSessionStateProvider"
applicationName="MyApp"
host="#{Host}"
port="1234"
databaseId="1"
accessKey=""
connectionTimeoutInMilliseconds="5000"
operationTimeoutInMilliseconds="1000"
throwOnError="true"
ssl="false" />
</providers>
</sessionState>
</configuration>
然后,您可以定义Host
作为八达通的变量。
有大量的信息和例子在这里:
https://octopus.com/docs/deploying-applications/configuration-files