protected void Application_Start() { AreaRegistration.RegisterAllAreas(); RouteConfig.RegisterRoutes(RouteTable.Routes); _BotJwtRefreshWorker = new BotJwtRefreshWorker(); Conversation.UpdateContainer( builder => { var store = new InMemoryDataStore(); builder.RegisterModule(new AzureModule(Assembly.GetExecutingAssembly())); // Other storage options // var store = new TableBotDataStore("...DataStorageConnectionString..."); // requires Microsoft.BotBuilder.Azure Nuget package // var store = new DocumentDbBotDataStore("cosmos db uri", "cosmos db key"); // requires Microsoft.BotBuilder.Azure Nuget package builder.Register(c => store) .Keyed <IBotDataStore <BotData> >(AzureModule.Key_DataStore) .AsSelf() .SingleInstance(); }); GlobalConfiguration.Configure(WebApiConfig.Register); GlobalConfiguration.Configuration.MessageHandlers.Add(new TokenValidationHandler()); }
protected void Application_Start() { GlobalConfiguration.Configure(WebApiConfig.Register); VerifyConfigurationIsValid(); /* * // Use an in-memory store for bot data. * // This registers a IBotDataStore singleton that will be used throughout the app. * var store = new InMemoryDataStore(); * * Conversation.UpdateContainer(builder => * { * builder.Register(c => new CachingBotDataStore(store, * CachingBotDataStoreConsistencyPolicy * .ETagBasedConsistency)) * .As<IBotDataStore<BotData>>() * .AsSelf() * .InstancePerLifetimeScope(); * }); */ string connectionString = ConfigurationManager.AppSettings["StorageConnectionString"]; var tableStore = new TableBotDataStore(connectionString); var tableName = "ChatHistory"; var account = CloudStorageAccount.Parse(connectionString); Conversation.UpdateContainer( builder => { builder.Register(c => tableStore) .Keyed <IBotDataStore <BotData> >(AzureModule.Key_DataStore) .AsSelf() .SingleInstance(); builder.Register(c => new CachingBotDataStore(tableStore, CachingBotDataStoreConsistencyPolicy .ETagBasedConsistency)) .As <IBotDataStore <BotData> >() .AsSelf() .InstancePerLifetimeScope(); builder.RegisterModule(new TableLoggerModule(account, tableName)); }); _botJwtRefreshWorker = new BotJwtRefreshWorker(); }
protected void Application_End() { _BotJwtRefreshWorker.Dispose(); _BotJwtRefreshWorker = null; }