-
Notifications
You must be signed in to change notification settings - Fork 153
Azure SignalR Service content rewrite #2775
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
80e937d
Initial bits
IEvangelist 9c16270
Draft - WIP.
IEvangelist afe61c1
More updates
IEvangelist a3a907e
I think this is accurate
IEvangelist a89ca96
This still isn't working
IEvangelist b75c851
Remove logging, tracing, and metrics
IEvangelist a6ec9ad
More updates
IEvangelist 00b1914
Clarifying text
IEvangelist d0a918e
Address more feedback in SignalR content
IEvangelist b52e248
Apply suggestions from code review
IEvangelist File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Large diffs are not rendered by default.
Oops, something went wrong.
11 changes: 10 additions & 1 deletion
11
docs/real-time/snippets/signalr/SignalR.ApiService/GlobalUsings.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,12 @@ | ||
global using Microsoft.AspNetCore.SignalR; | ||
global using System.Text.Json; | ||
global using System.Text.Json.Serialization; | ||
|
||
global using Microsoft.AspNetCore.Http.Connections; | ||
global using Microsoft.AspNetCore.SignalR; | ||
global using Microsoft.Azure.SignalR.Management; | ||
global using Microsoft.Extensions.Caching.Memory; | ||
|
||
global using Scalar.AspNetCore; | ||
|
||
global using SignalR.ApiService; | ||
global using SignalR.Shared; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
docs/real-time/snippets/signalr/SignalR.ApiService/ServiceHubContextFactory.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
namespace SignalR.ApiService; | ||
|
||
internal sealed class ServiceHubContextFactory(ServiceManager serviceManager, IMemoryCache cache) | ||
{ | ||
public async Task<ServiceHubContext> GetOrCreateHubContextAsync(string hubName, CancellationToken cancellationToken) | ||
{ | ||
var context = await cache.GetOrCreateAsync(hubName, async _ => | ||
{ | ||
return await serviceManager.CreateHubContextAsync(hubName, cancellationToken); | ||
}); | ||
|
||
return context ?? throw new InvalidOperationException("Failed to create hub context."); | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 16 additions & 8 deletions
24
docs/real-time/snippets/signalr/SignalR.AppHost/Program.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,21 @@ | ||
var builder = DistributedApplication.CreateBuilder(args); | ||
using Aspire.Hosting.Azure; | ||
|
||
var signalr = builder.ExecutionContext.IsPublishMode | ||
? builder.AddAzureSignalR("signalr") | ||
: builder.AddConnectionString("signalr"); | ||
var builder = DistributedApplication.CreateBuilder(args); | ||
|
||
var isServerless = true; | ||
|
||
var signalR = builder.AddAzureSignalR("signalr", isServerless | ||
? AzureSignalRServiceMode.Serverless | ||
: AzureSignalRServiceMode.Default) | ||
.RunAsEmulator(); | ||
|
||
var apiService = builder.AddProject<Projects.SignalR_ApiService>("apiservice") | ||
.WithReference(signalr); | ||
|
||
builder.AddProject<Projects.SignalR_Web>("webfrontend") | ||
.WithReference(apiService); | ||
.WithReference(signalR) | ||
.WaitFor(signalR) | ||
.WithEnvironment("IS_SERVERLESS", isServerless.ToString()); | ||
|
||
var web = builder.AddProject<Projects.SignalR_Web>("webfrontend") | ||
.WithReference(apiService) | ||
.WaitFor(apiService); | ||
|
||
builder.Build().Run(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
docs/snippets/azure/AppHost/Program.ConfigureSignalRInfra.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
using Azure.Provisioning.SignalR; | ||
|
||
internal static partial class Program | ||
{ | ||
public static void ConfigureSignalRInfra(IDistributedApplicationBuilder builder) | ||
{ | ||
// <configure> | ||
builder.AddAzureSignalR("signalr") | ||
.ConfigureInfrastructure(infra => | ||
{ | ||
var signalRService = infra.GetProvisionableResources() | ||
.OfType<SignalRService>() | ||
.Single(); | ||
|
||
signalRService.Sku.Name = "Premium_P1"; | ||
signalRService.Sku.Capacity = 10; | ||
signalRService.PublicNetworkAccess = "Enabled"; | ||
signalRService.Tags.Add("ExampleKey", "Example value"); | ||
}); | ||
// </configure> | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.