Skip to content

Instantly share code, notes, and snippets.

@ealsur
Last active Jun 24, 2021
Embed
What would you like to do?
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