CloudSql.Connector
1.3.0
dotnet add package CloudSql.Connector --version 1.3.0
NuGet\Install-Package CloudSql.Connector -Version 1.3.0
<PackageReference Include="CloudSql.Connector" Version="1.3.0" />
<PackageVersion Include="CloudSql.Connector" Version="1.3.0" />
<PackageReference Include="CloudSql.Connector" />
paket add CloudSql.Connector --version 1.3.0
#r "nuget: CloudSql.Connector, 1.3.0"
#:package CloudSql.Connector@1.3.0
#addin nuget:?package=CloudSql.Connector&version=1.3.0
#tool nuget:?package=CloudSql.Connector&version=1.3.0
CloudSql.Connector
In-process Google Cloud SQL connector for .NET — connect to Cloud SQL for PostgreSQL or MySQL directly from your application over mTLS, with no Cloud SQL Auth Proxy binary or sidecar process.
This is the in-process connector .NET has been missing — the equivalent of Google's Go, Java, and Python connectors.
What it does
- Discovers instance metadata via the Cloud SQL Admin API (
connectSettings). - Mints and automatically rotates a short-lived client certificate (
generateEphemeralCert) ahead of expiry. - Performs the mTLS handshake to the instance itself (port 3307), validating the server against the instance CA and identity (legacy CN or CAS SAN).
- Exposes an in-process loopback endpoint any ADO.NET driver can connect to.
- Supports IAM database authentication (access-token passwords, auto-refreshed).
- Selects public, private (VPC), or PSC IPs.
Packages
| Package | Use |
|---|---|
CloudSql.Connector |
Core connector + raw mTLS dialer + DI. |
CloudSql.Connector.Npgsql |
NpgsqlDataSource for Cloud SQL for PostgreSQL. |
CloudSql.Connector.MySqlConnector |
MySqlDataSource for Cloud SQL for MySQL. |
Quick start (PostgreSQL)
using CloudSql.Connector;
using CloudSql.Connector.Npgsql;
await using var connector = await CloudSqlConnector.CreateAsync();
await using var dataSource = await connector.CreateCloudSqlDataSourceAsync(
"my-project:europe-west1:my-instance",
"Database=mydb;Username=postgres;Password=...");
await using var cmd = dataSource.CreateCommand("SELECT version();");
Console.WriteLine(await cmd.ExecuteScalarAsync());
Dependency injection
builder.Services.AddCloudSqlNpgsqlDataSource(
"my-project:europe-west1:my-instance",
"Database=mydb;Username=postgres;Password=...");
Authentication uses Application Default Credentials.
See the project README for full documentation, IAM auth, private IP, and how it works.
| 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
- Google.Apis.Auth (>= 1.75.0)
- Google.Apis.SQLAdmin.v1 (>= 1.75.0.4166)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.0)
- Microsoft.Extensions.Hosting.Abstractions (>= 10.0.0)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.0)
- Microsoft.Extensions.Options (>= 10.0.0)
NuGet packages (2)
Showing the top 2 NuGet packages that depend on CloudSql.Connector:
| Package | Downloads |
|---|---|
|
CloudSql.Connector.MySqlConnector
MySqlConnector integration for CloudSql.Connector. Builds a MySqlDataSource that connects to a Google Cloud SQL for MySQL instance in-process over mTLS — no Cloud SQL Auth Proxy sidecar — with optional IAM database authentication. AddCloudSqlMySqlDataSource(). |
|
|
CloudSql.Connector.Npgsql
Npgsql integration for CloudSql.Connector. Builds an NpgsqlDataSource that connects to a Google Cloud SQL for PostgreSQL instance in-process over mTLS — no Cloud SQL Auth Proxy sidecar — with optional IAM database authentication. AddCloudSqlNpgsqlDataSource(). |
GitHub repositories
This package is not used by any popular GitHub repositories.