Skip to content

Commit 5753705

Browse files
carlosscastroTom Laird-McConnell
authored and
Tom Laird-McConnell
committed
State API deprecation: Samples to use InMemoryStore (#3858)
* State api deprecation: Update samples to default to InMemoryStore and… (#3791) * State api deprecation: Update samples to default to InMemoryStore and simplify moving to Azure +Add reference to Microsoft.Bot.Builder.Azure in samples +Register azure module and InMemoryStore in samples +Adjust comments to simplify using table storage or docdb in samples * Alarm bot sample: fix bug in global asax update * Samples now reference the nuget package + separating samples to another solution
1 parent c5689fb commit 5753705

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+1861
-627
lines changed

CSharp/Microsoft.Bot.Builder.sln

Lines changed: 1 addition & 174 deletions
Large diffs are not rendered by default.

CSharp/Samples/AlarmBot/Global.asax.cs

Lines changed: 33 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@
33
using System.Web.Http;
44
using Autofac;
55
using Autofac.Integration.WebApi;
6+
using Microsoft.Bot.Builder.Azure;
7+
using Microsoft.Bot.Builder.Dialogs;
68
using Microsoft.Bot.Builder.Dialogs.Internals;
9+
using Microsoft.Bot.Connector;
710
using Microsoft.Bot.Sample.AlarmBot.Models;
811

912
namespace Microsoft.Bot.Sample.AlarmBot
@@ -12,52 +15,47 @@ public class Global : System.Web.HttpApplication
1215
{
1316
protected void Application_Start(object sender, EventArgs e)
1417
{
15-
{
16-
// http://docs.autofac.org/en/latest/integration/webapi.html#quick-start
17-
var builder = new ContainerBuilder();
18-
19-
// register the Bot Builder module
20-
builder.RegisterModule(new DialogModule());
21-
// register the alarm dependencies
22-
builder.RegisterModule(new AlarmModule());
23-
24-
// Get your HttpConfiguration.
25-
var config = GlobalConfiguration.Configuration;
18+
var config = GlobalConfiguration.Configuration;
2619

27-
// Register your Web API controllers.
28-
builder.RegisterApiControllers(Assembly.GetExecutingAssembly());
20+
Conversation.UpdateContainer(
21+
builder =>
22+
{
23+
// Register the Bot Builder module
24+
builder.RegisterModule(new DialogModule());
25+
// Register the alarm dependencies
26+
builder.RegisterModule(new AlarmModule());
2927

30-
// OPTIONAL: Register the Autofac filter provider.
31-
builder.RegisterWebApiFilterProvider(config);
28+
builder.RegisterModule(new AzureModule(Assembly.GetExecutingAssembly()));
3229

33-
// Bot Storage: This is a great spot to register the private state storage for your bot.
34-
// We provide adapters for Azure Table, CosmosDb, SQL Azure, or you can implement your own!
35-
// For samples and documentation, see: https://github.com/Microsoft/BotBuilder-Azure
30+
// Bot Storage: Here we register the state storage for your bot.
31+
// Default store: volatile in-memory store - Only for prototyping!
32+
// We provide adapters for Azure Table, CosmosDb, SQL Azure, or you can implement your own!
33+
// For samples and documentation, see: https://github.com/Microsoft/BotBuilder-Azure
34+
var store = new InMemoryDataStore();
3635

37-
// Uncomment the block below to register the private state storage for your bot
38-
// builder.RegisterModule(new AzureModule(Assembly.GetExecutingAssembly()));
36+
// Other storage options
37+
// var store = new TableBotDataStore("...DataStorageConnectionString..."); // requires Microsoft.BotBuilder.Azure Nuget package
38+
// var store = new DocumentDbBotDataStore("cosmos db uri", "cosmos db key"); // requires Microsoft.BotBuilder.Azure Nuget package
3939

40-
//// Uncomment one of the lines below to choose your store
41-
//// var store = new TableBotDataStore("...DataStorageConnectionString..."); // requires Microsoft.BotBuilder.Azure Nuget package
42-
//// var store = new DocumentDbBotDataStore("cosmos db uri", "cosmos db key"); // requires Microsoft.BotBuilder.Azure Nuget package
43-
//// var store = new InMemoryDataStore(); // volatile in-memory store
40+
builder.Register(c => store)
41+
.Keyed<IBotDataStore<BotData>>(AzureModule.Key_DataStore)
42+
.AsSelf()
43+
.SingleInstance();
4444

45-
//builder.Register(c => store)
46-
// .Keyed<IBotDataStore<BotData>>(AzureModule.Key_DataStore)
47-
// .AsSelf()
48-
// .SingleInstance();
45+
// Register your Web API controllers.
46+
builder.RegisterApiControllers(Assembly.GetExecutingAssembly());
47+
builder.RegisterWebApiFilterProvider(config);
48+
});
4949

50-
// Set the dependency resolver to be Autofac.
51-
var container = builder.Build();
52-
config.DependencyResolver = new AutofacWebApiDependencyResolver(container);
53-
}
50+
// Set the dependency resolver to be Autofac.
51+
config.DependencyResolver = new AutofacWebApiDependencyResolver(Conversation.Container);
5452

5553
// WebApiConfig stuff
56-
GlobalConfiguration.Configure(config =>
54+
GlobalConfiguration.Configure(cfg =>
5755
{
58-
config.MapHttpAttributeRoutes();
56+
cfg.MapHttpAttributeRoutes();
5957

60-
config.Routes.MapHttpRoute(
58+
cfg.Routes.MapHttpRoute(
6159
name: "DefaultApi",
6260
routeTemplate: "api/{controller}/{id}",
6361
defaults: new { id = RouteParameter.Optional }

CSharp/Samples/AlarmBot/Microsoft.Bot.Sample.AlarmBot.csproj

Lines changed: 81 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -78,20 +78,6 @@
7878
<Compile Include="Models\ExternalEvent.cs" />
7979
<Compile Include="Properties\AssemblyInfo.cs" />
8080
</ItemGroup>
81-
<ItemGroup>
82-
<ProjectReference Include="..\..\Library\Microsoft.Bot.Builder.Autofac\Microsoft.Bot.Builder.Autofac.csproj">
83-
<Project>{2c145824-38dd-409c-ab52-b3538997726c}</Project>
84-
<Name>Microsoft.Bot.Builder.Autofac</Name>
85-
</ProjectReference>
86-
<ProjectReference Include="..\..\Library\Microsoft.Bot.Builder\Microsoft.Bot.Builder.csproj">
87-
<Project>{cdfec7d6-847e-4c13-956b-0a960ae3eb60}</Project>
88-
<Name>Microsoft.Bot.Builder</Name>
89-
</ProjectReference>
90-
<ProjectReference Include="..\..\Library\Microsoft.Bot.Connector.NetFramework\Microsoft.Bot.Connector.NetFramework.csproj">
91-
<Project>{DF397EFC-91DB-4911-9971-C509926FC288}</Project>
92-
<Name>Microsoft.Bot.Connector</Name>
93-
</ProjectReference>
94-
</ItemGroup>
9581
<ItemGroup>
9682
<Reference Include="Autofac, Version=3.5.0.0, Culture=neutral, PublicKeyToken=17863af14b0044da, processorArchitecture=MSIL">
9783
<HintPath>..\..\packages\Autofac.3.5.2\lib\net40\Autofac.dll</HintPath>
@@ -101,20 +87,98 @@
10187
<HintPath>..\..\packages\Autofac.WebApi2.3.4.0\lib\net45\Autofac.Integration.WebApi.dll</HintPath>
10288
<Private>True</Private>
10389
</Reference>
90+
<Reference Include="Chronic, Version=0.3.2.0, Culture=neutral, PublicKeyToken=3bd1f1ef638b0d3c, processorArchitecture=MSIL">
91+
<HintPath>..\..\packages\Chronic.Signed.0.3.2\lib\net40\Chronic.dll</HintPath>
92+
</Reference>
93+
<Reference Include="EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
94+
<HintPath>..\..\packages\EntityFramework.6.1.3\lib\net45\EntityFramework.dll</HintPath>
95+
</Reference>
96+
<Reference Include="EntityFramework.SqlServer, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
97+
<HintPath>..\..\packages\EntityFramework.6.1.3\lib\net45\EntityFramework.SqlServer.dll</HintPath>
98+
</Reference>
99+
<Reference Include="Microsoft.Azure.Documents.Client, Version=1.11.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
100+
<HintPath>..\..\packages\Microsoft.Azure.DocumentDB.1.11.0\lib\net45\Microsoft.Azure.Documents.Client.dll</HintPath>
101+
</Reference>
102+
<Reference Include="Microsoft.Azure.KeyVault.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
103+
<HintPath>..\..\packages\Microsoft.Azure.KeyVault.Core.1.0.0\lib\net40\Microsoft.Azure.KeyVault.Core.dll</HintPath>
104+
</Reference>
105+
<Reference Include="Microsoft.Bot.Builder, Version=3.12.2.4, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
106+
<HintPath>..\..\packages\Microsoft.Bot.Builder.3.12.2.4\lib\net46\Microsoft.Bot.Builder.dll</HintPath>
107+
<Private>True</Private>
108+
</Reference>
109+
<Reference Include="Microsoft.Bot.Builder.Autofac, Version=3.12.2.4, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
110+
<HintPath>..\..\packages\Microsoft.Bot.Builder.3.12.2.4\lib\net46\Microsoft.Bot.Builder.Autofac.dll</HintPath>
111+
<Private>True</Private>
112+
</Reference>
113+
<Reference Include="Microsoft.Bot.Builder.Azure, Version=3.2.4.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
114+
<HintPath>..\..\packages\Microsoft.Bot.Builder.Azure.3.2.4\lib\net46\Microsoft.Bot.Builder.Azure.dll</HintPath>
115+
</Reference>
116+
<Reference Include="Microsoft.Bot.Builder.History, Version=3.0.6.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
117+
<HintPath>..\..\packages\Microsoft.Bot.Builder.History.3.0.6\lib\net46\Microsoft.Bot.Builder.History.dll</HintPath>
118+
</Reference>
119+
<Reference Include="Microsoft.Bot.Connector, Version=3.12.2.4, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
120+
<HintPath>..\..\packages\Microsoft.Bot.Connector.3.12.2.4\lib\net46\Microsoft.Bot.Connector.dll</HintPath>
121+
<Private>True</Private>
122+
</Reference>
104123
<Reference Include="Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
105124
<HintPath>..\..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.1\lib\net45\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.dll</HintPath>
106125
<Private>True</Private>
107126
</Reference>
127+
<Reference Include="Microsoft.Data.Edm, Version=5.6.4.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
128+
<HintPath>..\..\packages\Microsoft.Data.Edm.5.6.4\lib\net40\Microsoft.Data.Edm.dll</HintPath>
129+
<Private>True</Private>
130+
</Reference>
131+
<Reference Include="Microsoft.Data.OData, Version=5.6.4.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
132+
<HintPath>..\..\packages\Microsoft.Data.OData.5.6.4\lib\net40\Microsoft.Data.OData.dll</HintPath>
133+
<Private>True</Private>
134+
</Reference>
135+
<Reference Include="Microsoft.Data.Services.Client, Version=5.6.4.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
136+
<HintPath>..\..\packages\Microsoft.Data.Services.Client.5.6.4\lib\net40\Microsoft.Data.Services.Client.dll</HintPath>
137+
<Private>True</Private>
138+
</Reference>
139+
<Reference Include="Microsoft.IdentityModel.Logging, Version=1.1.4.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
140+
<HintPath>..\..\packages\Microsoft.IdentityModel.Logging.1.1.4\lib\net451\Microsoft.IdentityModel.Logging.dll</HintPath>
141+
</Reference>
142+
<Reference Include="Microsoft.IdentityModel.Protocol.Extensions, Version=1.0.40306.1554, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
143+
<HintPath>..\..\packages\Microsoft.IdentityModel.Protocol.Extensions.1.0.4.403061554\lib\net45\Microsoft.IdentityModel.Protocol.Extensions.dll</HintPath>
144+
</Reference>
145+
<Reference Include="Microsoft.IdentityModel.Protocols, Version=2.1.4.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
146+
<HintPath>..\..\packages\Microsoft.IdentityModel.Protocols.2.1.4\lib\net451\Microsoft.IdentityModel.Protocols.dll</HintPath>
147+
</Reference>
148+
<Reference Include="Microsoft.IdentityModel.Protocols.OpenIdConnect, Version=2.1.4.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
149+
<HintPath>..\..\packages\Microsoft.IdentityModel.Protocols.OpenIdConnect.2.1.4\lib\net451\Microsoft.IdentityModel.Protocols.OpenIdConnect.dll</HintPath>
150+
</Reference>
151+
<Reference Include="Microsoft.IdentityModel.Tokens, Version=5.1.4.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
152+
<HintPath>..\..\packages\Microsoft.IdentityModel.Tokens.5.1.4\lib\net451\Microsoft.IdentityModel.Tokens.dll</HintPath>
153+
</Reference>
154+
<Reference Include="Microsoft.Rest.ClientRuntime, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
155+
<HintPath>..\..\packages\Microsoft.Rest.ClientRuntime.2.3.2\lib\net45\Microsoft.Rest.ClientRuntime.dll</HintPath>
156+
</Reference>
157+
<Reference Include="Microsoft.WindowsAzure.Storage, Version=7.2.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
158+
<HintPath>..\..\packages\WindowsAzure.Storage.7.2.1\lib\net40\Microsoft.WindowsAzure.Storage.dll</HintPath>
159+
</Reference>
108160
<Reference Include="Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
109161
<HintPath>..\..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
110162
</Reference>
111163
<Reference Include="System" />
164+
<Reference Include="System.ComponentModel.DataAnnotations" />
165+
<Reference Include="System.Data" />
166+
<Reference Include="System.IdentityModel.Tokens.Jwt, Version=5.1.4.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
167+
<HintPath>..\..\packages\System.IdentityModel.Tokens.Jwt.5.1.4\lib\net451\System.IdentityModel.Tokens.Jwt.dll</HintPath>
168+
</Reference>
169+
<Reference Include="System.Net" />
112170
<Reference Include="System.Data.DataSetExtensions" />
113171
<Reference Include="System.Net.Http" />
114172
<Reference Include="System.Net.Http.Formatting, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
115173
<HintPath>..\..\packages\Microsoft.AspNet.WebApi.Client.5.2.3\lib\net45\System.Net.Http.Formatting.dll</HintPath>
116174
<Private>True</Private>
117175
</Reference>
176+
<Reference Include="System.Net.Http.WebRequest" />
177+
<Reference Include="System.Runtime.Serialization" />
178+
<Reference Include="System.Spatial, Version=5.6.4.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
179+
<HintPath>..\..\packages\System.Spatial.5.6.4\lib\net40\System.Spatial.dll</HintPath>
180+
<Private>True</Private>
181+
</Reference>
118182
<Reference Include="System.Web" />
119183
<Reference Include="System.Web.ApplicationServices" />
120184
<Reference Include="System.Web.DynamicData" />
@@ -128,6 +192,7 @@
128192
<HintPath>..\..\packages\Microsoft.AspNet.WebApi.WebHost.5.2.3\lib\net45\System.Web.Http.WebHost.dll</HintPath>
129193
<Private>True</Private>
130194
</Reference>
195+
<Reference Include="System.Xml" />
131196
<Reference Include="System.Xml.Linq" />
132197
</ItemGroup>
133198
<PropertyGroup>
@@ -161,7 +226,9 @@
161226
</PropertyGroup>
162227
<Error Condition="!Exists('..\..\packages\Microsoft.Net.Compilers.1.0.0\build\Microsoft.Net.Compilers.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\Microsoft.Net.Compilers.1.0.0\build\Microsoft.Net.Compilers.props'))" />
163228
<Error Condition="!Exists('..\..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.1\build\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.1\build\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props'))" />
229+
<Error Condition="!Exists('..\..\packages\Microsoft.Azure.DocumentDB.1.11.0\build\Microsoft.Azure.DocumentDB.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\Microsoft.Azure.DocumentDB.1.11.0\build\Microsoft.Azure.DocumentDB.targets'))" />
164230
</Target>
231+
<Import Project="..\..\packages\Microsoft.Azure.DocumentDB.1.11.0\build\Microsoft.Azure.DocumentDB.targets" Condition="Exists('..\..\packages\Microsoft.Azure.DocumentDB.1.11.0\build\Microsoft.Azure.DocumentDB.targets')" />
165232
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
166233
Other similar extension points exist, see Microsoft.Common.targets.
167234
<Target Name="BeforeBuild">

CSharp/Samples/AlarmBot/Web.config

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44
http://go.microsoft.com/fwlink/?LinkId=169433
55
-->
66
<configuration>
7+
<configSections>
8+
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
9+
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
10+
</configSections>
711
<!--
812
For a description of web.config changes see http://go.microsoft.com/fwlink/?LinkId=235367.
913
@@ -30,6 +34,22 @@
3034
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
3135
<bindingRedirect oldVersion="0.0.0.0-9.0.0.0" newVersion="9.0.0.0" />
3236
</dependentAssembly>
37+
<dependentAssembly>
38+
<assemblyIdentity name="Microsoft.Bot.Connector" publicKeyToken="31bf3856ad364e35" culture="neutral" />
39+
<bindingRedirect oldVersion="0.0.0.0-3.12.2.4" newVersion="3.12.2.4" />
40+
</dependentAssembly>
41+
<dependentAssembly>
42+
<assemblyIdentity name="Microsoft.Bot.Builder" publicKeyToken="31bf3856ad364e35" culture="neutral" />
43+
<bindingRedirect oldVersion="0.0.0.0-3.12.2.4" newVersion="3.12.2.4" />
44+
</dependentAssembly>
45+
<dependentAssembly>
46+
<assemblyIdentity name="Microsoft.Bot.Builder.Autofac" publicKeyToken="31bf3856ad364e35" culture="neutral" />
47+
<bindingRedirect oldVersion="0.0.0.0-3.12.2.4" newVersion="3.12.2.4" />
48+
</dependentAssembly>
49+
<dependentAssembly>
50+
<assemblyIdentity name="System.IdentityModel.Tokens.Jwt" publicKeyToken="31bf3856ad364e35" culture="neutral" />
51+
<bindingRedirect oldVersion="0.0.0.0-5.1.4.0" newVersion="5.1.4.0" />
52+
</dependentAssembly>
3353
</assemblyBinding>
3454
</runtime>
3555
<system.codedom>
@@ -46,4 +66,14 @@
4666
<add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="*" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
4767
</handlers>
4868
</system.webServer>
69+
<entityFramework>
70+
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
71+
<parameters>
72+
<parameter value="mssqllocaldb" />
73+
</parameters>
74+
</defaultConnectionFactory>
75+
<providers>
76+
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
77+
</providers>
78+
</entityFramework>
4979
</configuration>

0 commit comments

Comments
 (0)