Skip to content

Instantly share code, notes, and snippets.

@ealsur
Last active June 24, 2021 16:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ealsur/556960c552f4122ff7d35668be9ac741 to your computer and use it in GitHub Desktop.
Save ealsur/556960c552f4122ff7d35668be9ac741 to your computer and use it in GitHub Desktop.
public void ConfigureServices(IServiceCollection services)
{
/* Other service configurations */
services.AddCosmosCache((CosmosCacheOptions cacheOptions) =>
{
CosmosClientBuilder clientBuilder = new CosmosClientBuilder("myConnectionString")
.WithApplicationRegion("West US");
cacheOptions.ContainerName = "myContainer";
cacheOptions.DatabaseName = "myDatabase";
cacheOptions.ClientBuilder = clientBuilder;
/* Creates the container if it does not exist */
cacheOptions.CreateIfNotExists = true;
});
services.AddSession(options =>
{
options.IdleTimeout = TimeSpan.FromSeconds(3600);
options.Cookie.IsEssential = true;
});
/* Other service configurations */
}
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
/* Other configurations */
app.UseSession();
/* app.UseEndpoints and other configurations */
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment