Skip to content

Commit 1c17fa1

Browse files
committed
Enable for Azure SQL
1 parent 10db6b7 commit 1c17fa1

File tree

5 files changed

+23
-11
lines changed

5 files changed

+23
-11
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*.user
99
*.userosscache
1010
*.sln.docstates
11-
appsettings.localuser.json
11+
appsettings.localhost.json
1212

1313
# User-specific files (MonoDevelop/Xamarin Studio)
1414
*.userprefs

demo/DemoServer/Program.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using IntelliTect.SignalR.SqlServer;
1+
using IntelliTect.AspNetCore.SignalR.SqlServer;
22
using Microsoft.AspNetCore.Hosting;
33
using Microsoft.Extensions.Configuration;
44
using Microsoft.Extensions.Hosting;
@@ -21,7 +21,12 @@ public static IHostBuilder CreateHostBuilder(string[] args) =>
2121
Host.CreateDefaultBuilder(args)
2222
.ConfigureWebHostDefaults(webBuilder =>
2323
{
24-
webBuilder.UseStartup<Startup>();
24+
webBuilder.UseStartup<Startup>()
25+
.ConfigureAppConfiguration((builder, config) => config
26+
.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
27+
.AddJsonFile("appsettings.localhost.json", optional: true, reloadOnChange: true)
28+
.AddEnvironmentVariables()
29+
);
2530
});
2631
}
2732
}

demo/DemoServer/Startup.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using IntelliTect.SignalR.SqlServer;
1+
using IntelliTect.AspNetCore.SignalR.SqlServer;
22
using Microsoft.AspNetCore.Builder;
33
using Microsoft.AspNetCore.Hosting;
44
using Microsoft.AspNetCore.HttpsPolicy;
@@ -26,7 +26,7 @@ public void ConfigureServices(IServiceCollection services)
2626
{
2727
services.AddRazorPages();
2828
services.AddSignalR()
29-
.AddSqlServer("Server=localhost;Database=SignalRTestDb;Trusted_Connection=True;MultipleActiveResultSets=True;");
29+
.AddSqlServer(Configuration.GetConnectionString("Default"));
3030
}
3131

3232
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.

src/IntelliTect.AspNetCore.SignalR.SqlServer/Internal/SqlServer/ObservableDbOperation.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ protected virtual void SqlDependency_OnChange(SqlNotificationEventArgs e, Action
307307
{
308308
_logger.LogError("{0}Unexpected SQL notification details: Type={1}, Source={2}, Info={3}", TracePrefix, e.Type, e.Source, e.Info);
309309

310-
Faulted(new SqlMessageBusException(String.Format(CultureInfo.InvariantCulture, Resources.Error_UnexpectedSqlNotificationType, e.Type, e.Source, e.Info)));
310+
Faulted(new SqlMessageBusException($"Unexpected SQL notification Type={e.Type}, Source={e.Source}, Info={e.Info}"));
311311
}
312312
}
313313
else if (e.Type == SqlNotificationType.Subscribe)
@@ -368,7 +368,14 @@ protected virtual bool StartSqlDependencyListener()
368368
catch (InvalidOperationException)
369369
{
370370
Trace.TraceInformation("{0}SQL Service Broker is disabled, disabling query notifications", TracePrefix);
371+
_notificationState = NotificationState.Disabled;
372+
return false;
373+
}
374+
catch (NullReferenceException)
375+
{
376+
// Workaround for https://github.com/dotnet/SqlClient/issues/1264
371377

378+
Trace.TraceInformation("{0}SQL Service Broker is disabled, disabling query notifications", TracePrefix);
372379
_notificationState = NotificationState.Disabled;
373380
return false;
374381
}

src/IntelliTect.AspNetCore.SignalR.SqlServer/Internal/SqlServer/SqlInstaller.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Copyright (c) .NET Foundation. All rights reserved.
22
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
33

4-
using IntelliTect.SignalR.SqlServer;
4+
using IntelliTect.AspNetCore.SignalR.SqlServer;
55
using Microsoft.Extensions.Logging;
66
using System;
77
using System.Diagnostics;
@@ -29,10 +29,10 @@ public void Install()
2929
{
3030
_logger.LogInformation("Start installing SignalR SQL objects");
3131

32-
if (!IsSqlEditionSupported(_options.ConnectionString))
33-
{
34-
throw new PlatformNotSupportedException(Resources.Error_UnsupportedSqlEdition);
35-
}
32+
//if (!IsSqlEditionSupported(_options.ConnectionString))
33+
//{
34+
// throw new PlatformNotSupportedException(Resources.Error_UnsupportedSqlEdition);
35+
//}
3636

3737
var script = GetType().Assembly.StringResource("install.sql");
3838

0 commit comments

Comments
 (0)