0

May I know How to use keyvault to retrieve the access key

<sessionState mode="Custom" customProvider="MySessionStateStore">
  <providers>
    <add name="MySessionStateStore" type="Microsoft.Web.Redis.RedisSessionStateProvider"
         host=""
         accessKey="I want this from keyvault"
         ssl="true" />
  </providers>
</sessionState>

There is similar post here Adding Session State Provider using Azure KeyVault for the connection string

but it does not seem to provide the solution. Any simple sample code?

Thanks

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
jay
  • 1,055
  • 3
  • 15
  • 35

1 Answers1

0

The link you shared above has one answer (at the time of this writing) that recommends that you use the settingsClassName and settingsMethodName configuration settings to provide a classs and method name that will be invoked to get the connection string. Looking at the code in ProviderConfiguratio, it seems like there is support for both of these configuration values, so it should be possible there.

In this documentation there is a description of what these settings should look like. It says:

Using settingsClassName and settingsMethodName to provide connection string: settingsClassName should be assembly qualified class name that contains method specified by settingsMethodName. settingsMethodName should be public, static, should not take any parameters and should have a return type of String, which is basically actual connection string value. You can get connection string from anywhere in this method.

In your implementation of the "settingsMethodName" method, you can do whatever you want in order to get the connection string. Your method would call into Key Vault to get the connection string, then return that value back to the session state provider through the return value.

JonCole
  • 2,902
  • 1
  • 17
  • 19