-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGlobal.asax.cs
50 lines (43 loc) · 2.24 KB
/
Global.asax.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
using Autofac;
using System.Web.Http;
using System.Configuration;
using System.Reflection;
using Microsoft.Bot.Builder.Azure;
using Microsoft.Bot.Builder.Dialogs;
using Microsoft.Bot.Builder.Dialogs.Internals;
using Microsoft.Bot.Connector;
using System;
namespace SimpleEchoBot
{
public class WebApiApplication : System.Web.HttpApplication
{
protected void Application_Start()
{
// Bot Storage: This is a great spot to register the private state storage for your bot.
// We provide adapters for Azure Table, CosmosDb, SQL Azure, or you can implement your own!
// For samples and documentation, see: https://github.com/Microsoft/BotBuilder-Azure
var docDbServiceEndpoint = new Uri(ConfigurationManager.AppSettings["DocumentDbUrl"]);
var docDbEmulatorKey = ConfigurationManager.AppSettings["DocumentDbKey"];
Conversation.UpdateContainer(
builder =>
{
builder.RegisterModule(new AzureModule(Assembly.GetExecutingAssembly()));
var store = new DocumentDbBotDataStore(docDbServiceEndpoint, docDbEmulatorKey);
builder.Register(c => store)
.Keyed<IBotDataStore<BotData>>(AzureModule.Key_DataStore)
.AsSelf()
.SingleInstance();
// Using Azure Table Storage
//var store = new TableBotDataStore(ConfigurationManager.AppSettings["AzureWebJobsStorage"]); // requires Microsoft.BotBuilder.Azure Nuget package
//// To use CosmosDb or InMemory storage instead of the default table storage, uncomment the corresponding line below
//// var store = new DocumentDbBotDataStore("cosmos db uri", "cosmos db key"); // requires Microsoft.BotBuilder.Azure Nuget package
//// var store = new InMemoryDataStore(); // volatile in-memory store
//builder.Register(c => store)
// .Keyed<IBotDataStore<BotData>>(AzureModule.Key_DataStore)
// .AsSelf()
// .SingleInstance();
});
GlobalConfiguration.Configure(WebApiConfig.Register);
}
}
}