【发布时间】:2016-06-02 10:16:13
【问题描述】:
我正在使用RedisSessionStateProvider 使用这样的程序https://azure.microsoft.com/en-us/documentation/articles/web-sites-dotnet-session-state-caching/
我在web.config中定义了它的连接字符串,在这个例子中是XXXXXX。
<system.web>
<compilation debug="true" targetFramework="4.6.1" />
<httpRuntime targetFramework="4.5" />
<globalization culture="es-CO" uiCulture="es" />
<customErrors mode="Off" />
<sessionState mode="Custom" customProvider="SessionStateStore">
<providers>
<add name="SessionStateStore" type="Microsoft.Web.Redis.RedisSessionStateProvider" connectionString="XXXXXX" throwOnError="true" applicationName="NominappSession" />
</providers>
</sessionState>
</system.web>
我不想将连接字符串放在源代码中。那么如何使用 Azure 中的设置来定义这个连接字符串呢?
我从 github 部署到 azure,所以它使用 Kudu。我没有外部 CI 服务器。
有什么建议吗?
【问题讨论】:
-
请注意,Azure 应用设置成为环境变量。因此,如果连接字符串配置条目支持扩展 env 变量(例如
connectionString="%MY_CONN_STRING%"),那么您也许可以做到这一点。或者也许有一个 API 可以让您以编程方式设置 conn 字符串,这也可以让您从 env 变量中设置它。请注意确定是否可能,但只是一些想法......
标签: azure azure-web-app-service stackexchange.redis session-state-provider