Skip to content

Commit

Permalink
Move SignalR and Custom Bicep articles (#1093)
Browse files Browse the repository at this point in the history
* Move SignalR and Custom Bicep articles

* Add back all the mistakenly deleted SignalR bits
  • Loading branch information
IEvangelist authored Jun 19, 2024
1 parent 3d42805 commit ed248d0
Show file tree
Hide file tree
Showing 13 changed files with 216 additions and 21 deletions.
2 changes: 1 addition & 1 deletion docs/real-time/azure-signalr-scenario.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: .NET Aspire support for Azure SignalR Service
description: Learn how to use the Azure SignalR Service with .NET Aspire.
ms.topic: how-to
ms.date: 04/18/2024
ms.date: 06/13/2024
---

# .NET Aspire support for Azure SignalR Service
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"profiles": {
"SignalR.ApiService": {
"commandName": "Project",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"applicationUrl": "https://localhost:53282;http://localhost:53285"
}
}
}
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
{
"$schema": "http://json.schemastore.org/launchsettings.json",
"profiles": {
"http": {
"https": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"applicationUrl": "http://localhost:15267",
"applicationUrl": "https://localhost:15267",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development",
"DOTNET_ENVIRONMENT": "Development",
"DOTNET_DASHBOARD_OTLP_ENDPOINT_URL": "http://localhost:16046"
"DOTNET_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:16046"
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsAspireHost>true</IsAspireHost>
<UserSecretsId>8d495870-a988-4f2c-80fe-ebe614c94d35</UserSecretsId>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\SignalR.ApiService\SignalR.ApiService.csproj" />
<ProjectReference Include="..\SignalR.Web\SignalR.Web.csproj" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Aspire.Hosting.AppHost" Version="8.0.1" />
<PackageReference Include="Aspire.Hosting.Azure" Version="8.0.1" />
<PackageReference Include="Aspire.Hosting.Azure.SignalR" Version="8.0.1" />
</ItemGroup>

</Project>
117 changes: 117 additions & 0 deletions docs/real-time/snippets/signalr/SignalR.ServiceDefaults/Extensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Diagnostics.HealthChecks;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Diagnostics.HealthChecks;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.ServiceDiscovery;
using OpenTelemetry;
using OpenTelemetry.Metrics;
using OpenTelemetry.Trace;

namespace Microsoft.Extensions.Hosting;
// Adds common .NET Aspire services: service discovery, resilience, health checks, and OpenTelemetry.
// This project should be referenced by each service project in your solution.
// To learn more about using this project, see https://aka.ms/dotnet/aspire/service-defaults
public static class Extensions
{
public static IHostApplicationBuilder AddServiceDefaults(this IHostApplicationBuilder builder)
{
builder.ConfigureOpenTelemetry();

builder.AddDefaultHealthChecks();

builder.Services.AddServiceDiscovery();

builder.Services.ConfigureHttpClientDefaults(http =>
{
// Turn on resilience by default
http.AddStandardResilienceHandler();
// Turn on service discovery by default
http.AddServiceDiscovery();
});

// Uncomment the following to restrict the allowed schemes for service discovery.
// builder.Services.Configure<ServiceDiscoveryOptions>(options =>
// {
// options.AllowedSchemes = ["https"];
// });

return builder;
}

public static IHostApplicationBuilder ConfigureOpenTelemetry(this IHostApplicationBuilder builder)
{
builder.Logging.AddOpenTelemetry(logging =>
{
logging.IncludeFormattedMessage = true;
logging.IncludeScopes = true;
});

builder.Services.AddOpenTelemetry()
.WithMetrics(metrics =>
{
metrics.AddAspNetCoreInstrumentation()
.AddHttpClientInstrumentation()
.AddRuntimeInstrumentation();
})
.WithTracing(tracing =>
{
tracing.AddAspNetCoreInstrumentation()
// Uncomment the following line to enable gRPC instrumentation (requires the OpenTelemetry.Instrumentation.GrpcNetClient package)
//.AddGrpcClientInstrumentation()
.AddHttpClientInstrumentation();
});

builder.AddOpenTelemetryExporters();

return builder;
}

private static IHostApplicationBuilder AddOpenTelemetryExporters(this IHostApplicationBuilder builder)
{
var useOtlpExporter = !string.IsNullOrWhiteSpace(builder.Configuration["OTEL_EXPORTER_OTLP_ENDPOINT"]);

if (useOtlpExporter)
{
builder.Services.AddOpenTelemetry().UseOtlpExporter();
}

// Uncomment the following lines to enable the Azure Monitor exporter (requires the Azure.Monitor.OpenTelemetry.AspNetCore package)
//if (!string.IsNullOrEmpty(builder.Configuration["APPLICATIONINSIGHTS_CONNECTION_STRING"]))
//{
// builder.Services.AddOpenTelemetry()
// .UseAzureMonitor();
//}

return builder;
}

public static IHostApplicationBuilder AddDefaultHealthChecks(this IHostApplicationBuilder builder)
{
builder.Services.AddHealthChecks()
// Add a default liveness check to ensure app is responsive
.AddCheck("self", () => HealthCheckResult.Healthy(), ["live"]);

return builder;
}

public static WebApplication MapDefaultEndpoints(this WebApplication app)
{
// Adding health checks endpoints to applications in non-development environments has security implications.
// See https://aka.ms/dotnet/aspire/healthchecks for details before enabling these endpoints in non-development environments.
if (app.Environment.IsDevelopment())
{
// All health checks must pass for app to be considered ready to accept traffic after starting
app.MapHealthChecks("/health");

// Only health checks tagged with the "live" tag must pass for app to be considered alive
app.MapHealthChecks("/alive", new HealthCheckOptions
{
Predicate = r => r.Tags.Contains("live")
});
}

return app;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsAspireSharedProject>true</IsAspireSharedProject>
</PropertyGroup>

<ItemGroup>
<FrameworkReference Include="Microsoft.AspNetCore.App" />

<PackageReference Include="Microsoft.Extensions.Http.Resilience" Version="8.6.0" />
<PackageReference Include="Microsoft.Extensions.ServiceDiscovery" Version="8.0.1" />
<PackageReference Include="OpenTelemetry.Exporter.OpenTelemetryProtocol" Version="1.8.1" />
<PackageReference Include="OpenTelemetry.Extensions.Hosting" Version="1.8.1" />
<PackageReference Include="OpenTelemetry.Instrumentation.AspNetCore" Version="1.8.1" />
<PackageReference Include="OpenTelemetry.Instrumentation.Http" Version="1.8.1" />
<PackageReference Include="OpenTelemetry.Instrumentation.Runtime" Version="1.8.1" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ protected override async Task OnAfterRenderAsync(bool firstRender)

protected override async Task OnInitializedAsync()
{
var api = Configuration.GetServiceHttpUri("apiservice");
var api = Configuration.GetServiceHttpsUri("apiservice");

var builder = new UriBuilder(api)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
public static class ConfigurationExtensions
{
public static Uri GetServiceHttpUri(this IConfiguration config, string name) =>
config.GetServiceUri(name, 0);
config.GetServiceUri(name, "http", 0);

public static Uri GetServiceHttpsUri(this IConfiguration config, string name) =>
config.GetServiceUri(name, 1);
config.GetServiceUri(name, "https", 0);

private static Uri GetServiceUri(this IConfiguration config, string name, int index)
private static Uri GetServiceUri(this IConfiguration config, string name, string scheme, int index)
{
var url = config[$"services:{name}:{index}"];
var url = config[$"services:{name}:{scheme}:{index}"];

ArgumentException.ThrowIfNullOrWhiteSpace(url);

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"profiles": {
"SignalR.Web": {
"commandName": "Project",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"applicationUrl": "https://localhost:53283;http://localhost:53284"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Blazor.LocalStorage" Version="8.0.1" />
<PackageReference Include="Blazor.LocalStorage" Version="8.0.0" />
<PackageReference Include="Microsoft.AspNetCore.SignalR.Client" Version="8.0.5" />
</ItemGroup>

Expand Down
12 changes: 6 additions & 6 deletions docs/real-time/snippets/signalr/signalr.sln
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,28 @@ VisualStudioVersion = 17.10.34627.106
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SignalR.AppHost", "SignalR.AppHost\SignalR.AppHost.csproj", "{DE7B2BE2-F1C2-4AA8-A8A6-7F28DE99E1F4}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SignalR.ServiceDefaults", "SignalR.ServiceDefaults\SignalR.ServiceDefaults.csproj", "{4873AF5C-93A1-4C07-A6C0-6ABBB2721B99}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SignalR.ApiService", "SignalR.ApiService\SignalR.ApiService.csproj", "{EACFAEC3-5A43-4E80-99EA-EA80135800B2}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SignalR.Web", "SignalR.Web\SignalR.Web.csproj", "{70C02EE1-2BBF-4555-9F3F-9B7A2205EFF1}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SignalR.Shared", "SignalR.Shared\SignalR.Shared.csproj", "{41EF3167-A20F-4963-8613-A455FFF53E97}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SignalR.ServiceDefaults", "SignalR.ServiceDefaults\SignalR.ServiceDefaults.csproj", "{232C3754-6A31-49F4-A246-5AD43538F8EE}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{232C3754-6A31-49F4-A246-5AD43538F8EE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{232C3754-6A31-49F4-A246-5AD43538F8EE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{232C3754-6A31-49F4-A246-5AD43538F8EE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{232C3754-6A31-49F4-A246-5AD43538F8EE}.Release|Any CPU.Build.0 = Release|Any CPU
{DE7B2BE2-F1C2-4AA8-A8A6-7F28DE99E1F4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{DE7B2BE2-F1C2-4AA8-A8A6-7F28DE99E1F4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DE7B2BE2-F1C2-4AA8-A8A6-7F28DE99E1F4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DE7B2BE2-F1C2-4AA8-A8A6-7F28DE99E1F4}.Release|Any CPU.Build.0 = Release|Any CPU
{4873AF5C-93A1-4C07-A6C0-6ABBB2721B99}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4873AF5C-93A1-4C07-A6C0-6ABBB2721B99}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4873AF5C-93A1-4C07-A6C0-6ABBB2721B99}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4873AF5C-93A1-4C07-A6C0-6ABBB2721B99}.Release|Any CPU.Build.0 = Release|Any CPU
{EACFAEC3-5A43-4E80-99EA-EA80135800B2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{EACFAEC3-5A43-4E80-99EA-EA80135800B2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{EACFAEC3-5A43-4E80-99EA-EA80135800B2}.Release|Any CPU.ActiveCfg = Release|Any CPU
Expand Down
10 changes: 5 additions & 5 deletions docs/toc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,9 @@ items:
- name: Azure Key Vault
displayName: key vault,security
href: security/azure-security-key-vault-component.md
- name: Azure SignalR Service
displayName: azure signalr service,signalr,real-time
href: real-time/azure-signalr-scenario.md
- name: Azure Service Bus
displayName: service bus,messaging
href: messaging/azure-service-bus-component.md
Expand Down Expand Up @@ -199,8 +202,6 @@ items:
href: database/sql-server-component-deployment.md
- name: Deploy .NET Aspire + Redis
href: caching/caching-components-deployment.md
- name: Use custom Bicep templates
href: deployment/azure/custom-bicep-templates.md
- name: Tool-builder manifest schemas
href: deployment/manifest-format.md

Expand All @@ -210,9 +211,8 @@ items:
items:
- name: Local Azure provisioning
href: deployment/azure/local-provisioning.md
- name: Azure SignalR Service scenario
displayName: azure signalr service,signalr,real-time
href: real-time/azure-signalr-scenario.md
- name: Use custom Bicep templates
href: deployment/azure/custom-bicep-templates.md

- name: Frameworks
items:
Expand Down

0 comments on commit ed248d0

Please sign in to comment.