Adliance.AspNetCore.Buddy.GuiKit.Infrastructure
10.2.0.14
Prefix Reserved
dotnet add package Adliance.AspNetCore.Buddy.GuiKit.Infrastructure --version 10.2.0.14
NuGet\Install-Package Adliance.AspNetCore.Buddy.GuiKit.Infrastructure -Version 10.2.0.14
<PackageReference Include="Adliance.AspNetCore.Buddy.GuiKit.Infrastructure" Version="10.2.0.14" />
<PackageVersion Include="Adliance.AspNetCore.Buddy.GuiKit.Infrastructure" Version="10.2.0.14" />
<PackageReference Include="Adliance.AspNetCore.Buddy.GuiKit.Infrastructure" />
paket add Adliance.AspNetCore.Buddy.GuiKit.Infrastructure --version 10.2.0.14
#r "nuget: Adliance.AspNetCore.Buddy.GuiKit.Infrastructure, 10.2.0.14"
#:package Adliance.AspNetCore.Buddy.GuiKit.Infrastructure@10.2.0.14
#addin nuget:?package=Adliance.AspNetCore.Buddy.GuiKit.Infrastructure&version=10.2.0.14
#tool nuget:?package=Adliance.AspNetCore.Buddy.GuiKit.Infrastructure&version=10.2.0.14
Adliance.AspNetCore.Buddy.GuiKit.Infrastructure
Hosting infrastructure for Adliance ASP.NET Core applications: Application Insights and Azure Key Vault, each set up with one call and only enabled when it is configured. Apps therefore run unchanged locally, where neither is needed, and in Azure, where both are configured.
The package is a dependency of Adliance.AspNetCore.Buddy.GuiKit, so apps using GuiKit already have it.
Setup
using Adliance.AspNetCore.Buddy.GuiKit.Infrastructure.Extensions;
var builder = WebApplication.CreateBuilder(args);
builder.Configuration.AddKeyVaultIfConfigured(builder.Environment);
builder.Services.AddApplicationInsightsIfConfigured();
Application Insights
AddApplicationInsightsIfConfigured enables Application Insights telemetry if the
APPLICATIONINSIGHTS_CONNECTION_STRING environment variable is set (as Azure App Service does when Application
Insights is enabled), and writes to the console whether it did. The app's InformationalVersion is reported as the
application version, so telemetry can be told apart by release.
It also registers AppInsightsJavaScript, which renders the Application Insights JavaScript snippet for browser
telemetry. GuiKit's _AgkLayout already renders it; in other layouts, inject it:
@inject Adliance.AspNetCore.Buddy.GuiKit.Infrastructure.AppInsightsJavaScript AppInsights
@AppInsights.GetString(nonce)
GetString renders the <script> tag (with the nonce for a Content Security Policy, if given), ScriptBody only its
content. Both are empty when Application Insights is not configured.
App version
AppVersion.Current is the app's version: the InformationalVersion of its entry assembly (eg. set by the build
pipeline), or an empty string without one. It's the application version reported to Application Insights, and the
cache buster of GuiKit's layouts - use it for the app's own static files as well, so browsers load them again after
an update (see UseGuiKitStaticFiles in the GuiKit README):
@using Adliance.AspNetCore.Buddy.GuiKit.Infrastructure
<link rel="stylesheet" href="~/styles.css?v=@AppVersion.Current"/>
Azure Key Vault
AddKeyVaultIfConfigured adds an Azure Key Vault as a configuration source if the KeyVault connection string is
configured, eg. as the KeyVault environment variable or in appsettings.json. Secret names use -- where the
configuration key uses :, eg. the secret Claude--ApiKey is the configuration value Claude:ApiKey.
The configuration sources are ordered (lowest to highest precedence) as:
appsettings.json- Key Vault
- environment variables
appsettings.{Environment}.json
so Key Vault overrides the shared defaults, while environment variables and environment-specific appsettings can still override Key Vault. Sources added after these (eg. user secrets, command line arguments) keep their position.
Connection string
The connection string is the vault URI, optionally followed by credentials:
VaultUri=https://my-vault.vault.azure.net/;TenantId=...;ClientId=...;ClientSecret=...
The URI alone (https://my-vault.vault.azure.net/) is a valid connection string, too. Keys are case-insensitive;
VaultUrl, Uri and Url are accepted for VaultUri.
How the app authenticates against the vault depends on what the connection string contains:
| Connection string | Credential |
|---|---|
TenantId, ClientId and ClientSecret |
the app registration with this client secret, anywhere |
no client secret, in Development |
the developer logged in with the Azure CLI (az login) |
| no client secret, otherwise | the app's managed identity: the user-assigned one with ClientId, else the system-assigned one |
Unlike DefaultAzureCredential, which tries every credential source in turn (and spends ~25 seconds probing for a
managed identity on a development machine), this picks the one credential that can work, so startup is not delayed.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- Adliance.Buddy.CodeStyle (>= 8.0.0.10)
- Azure.Extensions.AspNetCore.Configuration.Secrets (>= 1.5.2)
- Azure.Identity (>= 1.21.0)
- Microsoft.ApplicationInsights.AspNetCore (>= 3.1.2)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Adliance.AspNetCore.Buddy.GuiKit.Infrastructure:
| Package | Downloads |
|---|---|
|
Adliance.AspNetCore.Buddy.GuiKit
Library of CSS, JavaScript, TagHelpers and layouts for a commonly shared Adliance UI. |
GitHub repositories
This package is not used by any popular GitHub repositories.