feat: Expose a connection string parsing API
See original GitHub issueIs your feature request related to a problem? Please describe. I want to log the endpoint Uri (but not the key of course), but all I have is a connection string
Describe the solution you’d like
var (uri,key) = CosmosClient.ParseConnectionString(connectionString)
Describe alternatives you’ve considered https://stackoverflow.com/a/66746588/11635
Additional context I’ve previously arrived at this (not my original work), and wan’t to do better than that without replicating the logic @NoahStahl found.
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (6 by maintainers)
Top Results From Across the Web
Expose connection string parsing functions #1524 - jackc/pgx
I'm working on an internal package for managing multiple connection strings and connection pools. As part of this, I need to parse connection ......
Read more >Is there any connection string parser in C#? - ...
I have a connection string and I want to be able to peek out for example "Data Source". Is there a parser, or...
Read more >3.3 Connecting to Oracle Database
Connection String Attributes · Connection String Builder · Specifying the Data Source Attribute · Using Transport Layer Security and Secure Sockets Layer.
Read more >DbConnectionStringBuilder.ConnectionString Property
The ConnectionString property of the DbConnectionStringBuilder class acts generally as a mechanism for creating and parsing semicolon-delimited lists of key/ ...
Read more >Parsing a Connection String With Sprache
Sprache is a very cool lightweight parser library for C#. Today I was experimenting with parsing EasyNetQ connection strings, ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@ealsur I know I can (and thanks for trying to help) - I actually have, for now. I happen even to be able to squirrel it away in a wrapper lib without too much junk leaking into normal apps.
My point, and the reason for this issue, is that the SDK should provide an affordance that lets me naturally emit the Endpoint Uri for diagnostic purposes before I [fail to]
ConnectAndInitializeAsync
. For the normal lazy-initialized path, a credible solution exists: useCosmosClient.Endpoint
- me re-implementing clones of internal behavior of the SDK is not a good solution overall though. I’m raising this issue in the hope e.g. that the V4 SDK provides a better overall answer.While I’m overstepping the mark, I’m wondering whether overloading of constructors and CreateAndInitializeAsync by a) Connection String b) Endpoint and Key is sustainable and/or will become hard to maintain/add new mechanisms to over time.
@bartelink you can use
System.Data.Common.DbConnectionStringBuilder