Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
d628a49
Create Azure Npgsql client integration
sebastienros Mar 20, 2025
89b721d
Reuse code from npgsql and add tests
sebastienros Mar 21, 2025
a4635f3
Update component metadata
sebastienros Mar 21, 2025
7cceac6
Fix tests on CI
sebastienros Mar 21, 2025
f4cf620
Fix markdown
sebastienros Mar 21, 2025
6e9ebad
Improvements on non-azure database support
sebastienros Mar 21, 2025
c4a4d33
Refactor Npgsql usage
sebastienros Mar 22, 2025
bcf8d18
Removing playground app and refactoring
sebastienros Mar 22, 2025
8a6fa32
Update src/Components/Aspire.Azure.Npgsql/AssemblyInfo.cs
sebastienros Mar 24, 2025
81dbd63
Remove config schema metadata
sebastienros Mar 24, 2025
2b5c479
Remove unnecessary file references
sebastienros Mar 24, 2025
21fc9de
Merge remote-tracking branch 'upstream/main' into sebros/azurenpgsql
eerhardt Mar 24, 2025
2ee5339
Comment copies
sebastienros Mar 24, 2025
2f49ff8
Support getting the PrinicipalName for a user assigned managed identity
eerhardt Mar 24, 2025
ee2ee64
Merge remote-tracking branch 'upstream/sebros/azurenpgsql' into sebro…
eerhardt Mar 24, 2025
4f70984
Merge remote-tracking branch 'upstream/main' into sebros/azurenpgsql
eerhardt Mar 24, 2025
25d52db
Merge remote-tracking branch 'origin/sebros/azurenpgsql' into sebros/…
sebastienros Mar 24, 2025
35cbaef
Fix test
sebastienros Mar 24, 2025
1e3b0bd
Remove custom log categories
sebastienros Mar 24, 2025
7091de2
Handle username token extraction failures
sebastienros Mar 26, 2025
9d7e4d2
Fix code blocks
sebastienros Mar 26, 2025
3ea164b
Address PR feedback
eerhardt Mar 26, 2025
32fb819
Fix test project
eerhardt Mar 26, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 63 additions & 0 deletions Aspire.sln
Original file line number Diff line number Diff line change
Expand Up @@ -665,6 +665,16 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Aspire.Hosting.Docker.Tests
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Aspire.Hosting.Kubernetes.Tests", "tests\Aspire.Hosting.Kubernetes.Tests\Aspire.Hosting.Kubernetes.Tests.csproj", "{582B06FD-CC56-4C58-8138-D92F8FE62BBD}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Aspire.Azure.Npgsql", "src\Components\Aspire.Azure.Npgsql\Aspire.Azure.Npgsql.csproj", "{417C3703-058A-210D-7E9A-28198EFDB25F}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "AzurePostgres", "AzurePostgres", "{02EA681E-C7D8-13C7-8484-4AC65E1B71E8}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AzurePostgres.AppHost", "playground\AzurePostgres\AzurePostgres.AppHost\AzurePostgres.AppHost.csproj", "{99158965-9ADA-4C33-A061-7E12C26580C4}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AzurePostgres.Api", "playground\AzurePostgres\AzurePostgres.Api\AzurePostgres.Api.csproj", "{8F3A9BB2-7F44-4B3B-7E37-CCDBE2C3963D}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Aspire.Azure.Npgsql.Tests", "tests\Aspire.Azure.Npgsql.Tests\Aspire.Azure.Npgsql.Tests.csproj", "{201765B1-37A1-9F5B-DD7F-730347046BE1}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -3891,6 +3901,54 @@ Global
{582B06FD-CC56-4C58-8138-D92F8FE62BBD}.Release|x64.Build.0 = Release|Any CPU
{582B06FD-CC56-4C58-8138-D92F8FE62BBD}.Release|x86.ActiveCfg = Release|Any CPU
{582B06FD-CC56-4C58-8138-D92F8FE62BBD}.Release|x86.Build.0 = Release|Any CPU
{417C3703-058A-210D-7E9A-28198EFDB25F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{417C3703-058A-210D-7E9A-28198EFDB25F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{417C3703-058A-210D-7E9A-28198EFDB25F}.Debug|x64.ActiveCfg = Debug|Any CPU
{417C3703-058A-210D-7E9A-28198EFDB25F}.Debug|x64.Build.0 = Debug|Any CPU
{417C3703-058A-210D-7E9A-28198EFDB25F}.Debug|x86.ActiveCfg = Debug|Any CPU
{417C3703-058A-210D-7E9A-28198EFDB25F}.Debug|x86.Build.0 = Debug|Any CPU
{417C3703-058A-210D-7E9A-28198EFDB25F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{417C3703-058A-210D-7E9A-28198EFDB25F}.Release|Any CPU.Build.0 = Release|Any CPU
{417C3703-058A-210D-7E9A-28198EFDB25F}.Release|x64.ActiveCfg = Release|Any CPU
{417C3703-058A-210D-7E9A-28198EFDB25F}.Release|x64.Build.0 = Release|Any CPU
{417C3703-058A-210D-7E9A-28198EFDB25F}.Release|x86.ActiveCfg = Release|Any CPU
{417C3703-058A-210D-7E9A-28198EFDB25F}.Release|x86.Build.0 = Release|Any CPU
{99158965-9ADA-4C33-A061-7E12C26580C4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{99158965-9ADA-4C33-A061-7E12C26580C4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{99158965-9ADA-4C33-A061-7E12C26580C4}.Debug|x64.ActiveCfg = Debug|Any CPU
{99158965-9ADA-4C33-A061-7E12C26580C4}.Debug|x64.Build.0 = Debug|Any CPU
{99158965-9ADA-4C33-A061-7E12C26580C4}.Debug|x86.ActiveCfg = Debug|Any CPU
{99158965-9ADA-4C33-A061-7E12C26580C4}.Debug|x86.Build.0 = Debug|Any CPU
{99158965-9ADA-4C33-A061-7E12C26580C4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{99158965-9ADA-4C33-A061-7E12C26580C4}.Release|Any CPU.Build.0 = Release|Any CPU
{99158965-9ADA-4C33-A061-7E12C26580C4}.Release|x64.ActiveCfg = Release|Any CPU
{99158965-9ADA-4C33-A061-7E12C26580C4}.Release|x64.Build.0 = Release|Any CPU
{99158965-9ADA-4C33-A061-7E12C26580C4}.Release|x86.ActiveCfg = Release|Any CPU
{99158965-9ADA-4C33-A061-7E12C26580C4}.Release|x86.Build.0 = Release|Any CPU
{8F3A9BB2-7F44-4B3B-7E37-CCDBE2C3963D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8F3A9BB2-7F44-4B3B-7E37-CCDBE2C3963D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8F3A9BB2-7F44-4B3B-7E37-CCDBE2C3963D}.Debug|x64.ActiveCfg = Debug|Any CPU
{8F3A9BB2-7F44-4B3B-7E37-CCDBE2C3963D}.Debug|x64.Build.0 = Debug|Any CPU
{8F3A9BB2-7F44-4B3B-7E37-CCDBE2C3963D}.Debug|x86.ActiveCfg = Debug|Any CPU
{8F3A9BB2-7F44-4B3B-7E37-CCDBE2C3963D}.Debug|x86.Build.0 = Debug|Any CPU
{8F3A9BB2-7F44-4B3B-7E37-CCDBE2C3963D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8F3A9BB2-7F44-4B3B-7E37-CCDBE2C3963D}.Release|Any CPU.Build.0 = Release|Any CPU
{8F3A9BB2-7F44-4B3B-7E37-CCDBE2C3963D}.Release|x64.ActiveCfg = Release|Any CPU
{8F3A9BB2-7F44-4B3B-7E37-CCDBE2C3963D}.Release|x64.Build.0 = Release|Any CPU
{8F3A9BB2-7F44-4B3B-7E37-CCDBE2C3963D}.Release|x86.ActiveCfg = Release|Any CPU
{8F3A9BB2-7F44-4B3B-7E37-CCDBE2C3963D}.Release|x86.Build.0 = Release|Any CPU
{201765B1-37A1-9F5B-DD7F-730347046BE1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{201765B1-37A1-9F5B-DD7F-730347046BE1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{201765B1-37A1-9F5B-DD7F-730347046BE1}.Debug|x64.ActiveCfg = Debug|Any CPU
{201765B1-37A1-9F5B-DD7F-730347046BE1}.Debug|x64.Build.0 = Debug|Any CPU
{201765B1-37A1-9F5B-DD7F-730347046BE1}.Debug|x86.ActiveCfg = Debug|Any CPU
{201765B1-37A1-9F5B-DD7F-730347046BE1}.Debug|x86.Build.0 = Debug|Any CPU
{201765B1-37A1-9F5B-DD7F-730347046BE1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{201765B1-37A1-9F5B-DD7F-730347046BE1}.Release|Any CPU.Build.0 = Release|Any CPU
{201765B1-37A1-9F5B-DD7F-730347046BE1}.Release|x64.ActiveCfg = Release|Any CPU
{201765B1-37A1-9F5B-DD7F-730347046BE1}.Release|x64.Build.0 = Release|Any CPU
{201765B1-37A1-9F5B-DD7F-730347046BE1}.Release|x86.ActiveCfg = Release|Any CPU
{201765B1-37A1-9F5B-DD7F-730347046BE1}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -4210,6 +4268,11 @@ Global
{3AE2ED5B-4EC7-4E6D-A61D-C68B837E5FA7} = {B80354C7-BE58-43F6-8928-9F3A74AB7F47}
{43B560D6-F158-4A4C-8E43-981056EB9038} = {830A89EC-4029-4753-B25A-068BAE37DEC7}
{582B06FD-CC56-4C58-8138-D92F8FE62BBD} = {830A89EC-4029-4753-B25A-068BAE37DEC7}
{417C3703-058A-210D-7E9A-28198EFDB25F} = {27381127-6C45-4B4C-8F18-41FF48DFE4B2}
{02EA681E-C7D8-13C7-8484-4AC65E1B71E8} = {D173887B-AF42-4576-B9C1-96B9E9B3D9C0}
{99158965-9ADA-4C33-A061-7E12C26580C4} = {02EA681E-C7D8-13C7-8484-4AC65E1B71E8}
{8F3A9BB2-7F44-4B3B-7E37-CCDBE2C3963D} = {02EA681E-C7D8-13C7-8484-4AC65E1B71E8}
{201765B1-37A1-9F5B-DD7F-730347046BE1} = {C424395C-1235-41A4-BF55-07880A04368C}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {47DCFECF-5631-4BDE-A1EC-BE41E90F60C4}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

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

<ItemGroup>
<AspireProjectOrPackageReference Include="Aspire.Azure.Npgsql" />
<ProjectReference Include="..\..\Playground.ServiceDefaults\Playground.ServiceDefaults.csproj" />
</ItemGroup>

</Project>
20 changes: 20 additions & 0 deletions playground/AzurePostgres/AzurePostgres.Api/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using Npgsql;

var builder = WebApplication.CreateBuilder(args);

builder.AddServiceDefaults();

builder.AddAzureNpgsqlDataSource("db");

var app = builder.Build();

app.MapGet("/", (NpgsqlDataSource dataSource) =>
{
using var conn = dataSource.OpenConnection();
var command = conn.CreateCommand();
command.CommandText = "SELECT 1";
var result = command.ExecuteScalar();
return result;
});

app.Run();
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"$schema": "https://json.schemastore.org/launchsettings.json",
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:28791",
"sslPort": 44377
}
},
"profiles": {
"http": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"applicationUrl": "http://localhost:5161",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"https": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"applicationUrl": "https://localhost:7228;http://localhost:5161",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
}
}
9 changes: 9 additions & 0 deletions playground/AzurePostgres/AzurePostgres.Api/appsettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>$(DefaultTargetFramework)</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsAspireHost>true</IsAspireHost>
<UserSecretsId>bbbf3fcc-8512-4f9a-b56b-54d9edfb3904</UserSecretsId>
</PropertyGroup>

<ItemGroup>
<Compile Include="..\..\KnownResourceNames.cs" Link="KnownResourceNames.cs" />
</ItemGroup>

<ItemGroup>
<AspireProjectOrPackageReference Include="Aspire.Hosting.Azure" />
<AspireProjectOrPackageReference Include="Aspire.Hosting.Azure.PostgreSQL" />
<AspireProjectOrPackageReference Include="Aspire.Hosting.AppHost" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\AzurePostgres.Api\AzurePostgres.Api.csproj" />
</ItemGroup>

</Project>
22 changes: 22 additions & 0 deletions playground/AzurePostgres/AzurePostgres.AppHost/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

var builder = DistributedApplication.CreateBuilder(args);

var db = builder.AddAzurePostgresFlexibleServer("postgres").AddDatabase("db");

builder.AddProject<Projects.AzurePostgres_Api>("api")
.WithExternalHttpEndpoints()
.WithReference(db).WaitFor(db);

#if !SKIP_DASHBOARD_REFERENCE
// This project is only added in playground projects to support development/debugging
// of the dashboard. It is not required in end developer code. Comment out this code
// or build with `/p:SkipDashboardReference=true`, to test end developer
// dashboard launch experience, Refer to Directory.Build.props for the path to
// the dashboard binary (defaults to the Aspire.Dashboard bin output in the
// artifacts dir).
builder.AddProject<Projects.Aspire_Dashboard>(KnownResourceNames.AspireDashboard);
#endif

builder.Build().Run();
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"$schema": "https://json.schemastore.org/launchsettings.json",
"profiles": {
"https": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"applicationUrl": "https://localhost:17012;http://localhost:15019",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development",
"DOTNET_ENVIRONMENT": "Development",
"DOTNET_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:21146",
"DOTNET_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:22043"
}
},
"http": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"applicationUrl": "http://localhost:15019",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development",
"DOTNET_ENVIRONMENT": "Development",
"DOTNET_DASHBOARD_OTLP_ENDPOINT_URL": "http://localhost:19149",
"DOTNET_RESOURCE_SERVICE_ENDPOINT_URL": "http://localhost:20296"
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning",
"Aspire.Hosting.Dcp": "Warning"
}
}
}
26 changes: 26 additions & 0 deletions src/Components/Aspire.Azure.Npgsql/Aspire.Azure.Npgsql.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>$(DefaultTargetFramework)</TargetFramework>
<IsPackable>true</IsPackable>
<PackageTags>$(ComponentAzurePackageTags) postgresql postgres npgsql sql</PackageTags>
<Description>A client for Azure Database for PostgreSQL that integrates with Aspire, including health checks, logging and telemetry.</Description>
<PackageIconFullPath>$(SharedDir)AzurePostgreSQL_256x.png</PackageIconFullPath>
<EnablePackageValidation>false</EnablePackageValidation>
<NoWarn>$(NoWarn);SYSLIB1100;SYSLIB1101</NoWarn>
</PropertyGroup>

<ItemGroup>
<Compile Include="..\Common\ConfigurationSchemaAttributes.cs" Link="ConfigurationSchemaAttributes.cs" />
<Compile Include="..\Common\HealthChecksExtensions.cs" Link="HealthChecksExtensions.cs" />
<Compile Include="..\Common\ConnectionStringValidation.cs" Link="ConnectionStringValidation.cs" />
<Compile Include="..\Aspire.Npgsql\NpgsqlCommon.cs" Link="NpgsqlCommon.cs" />
<Compile Include="..\Aspire.Npgsql\NpgsqlDataSourceHelper.cs" Link="NpgsqlDataSourceHelper.cs" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Azure" />
<ProjectReference Include="..\Aspire.Npgsql\Aspire.Npgsql.csproj" />
</ItemGroup>

</Project>
Loading
Loading