Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature req: identity-based connection #73

Open
kumkee opened this issue Nov 29, 2023 · 6 comments
Open

Feature req: identity-based connection #73

kumkee opened this issue Nov 29, 2023 · 6 comments

Comments

@kumkee
Copy link

kumkee commented Nov 29, 2023

Do you only support Connection-String connections?

Please add support for identity-based connection.

In the upstream, this is done using the DefaultAzureCredential class provided by the Azure.Identity client library.

This would be a function called Cosmos.fromCredential which works like

open Microsoft.Azure.Cosmos
open Azure.Identity
open FSharp.CosmosDb

let credential = new DefaultAzureCredential()

let insertUsers data =
    credential 
    |> Cosmos.fromCredential
    |> Cosmos.database "UserDb"
    |> Cosmos.container "UserContainer"
    |> Cosmos.insertMany<User> data
    |> Cosmos.execAsync

Many thanks.

@kumkee
Copy link
Author

kumkee commented Dec 4, 2023

@aaronpowell, I'd like to contribute and make identity-based connections a reality if no one has the time. To achieve that, I'll need to communicate with you and/or other authors of the library first. This is because it is going to change a major type, ConnectionOperation and I don't want to waste time onto the wrong direction.

My idea for the implementation is to add a new boolean member WithIdenty to type ConnectionOperation. When it is false the type would work as what it does now. When it is true, it is connecting using endpoint and the identity provided by DefaultAzureCredential().

The next step after DefaultAzureCredential() would be adding an option for the user to specify which identity to use with DefaultAzureCredentialOptions.

@aaronpowell, please let me know what you think especially whether these implementation ideas are too intrusive to the existing codebase.

Thank you.

@aaronpowell
Copy link
Owner

The change is probably not that huge, it'd just be adding another two properties to the ConnectionOperation type and having an expanded match on what the connection mode should be when creating the CosmosClient.

In the future, maybe it'd be better to refactor to use the AzureKeyCredential but I'd have to check to ensure the constructor for CosmosClient works with it.

Submit a PR and I'll review and we can iterate as needed.

@kumkee
Copy link
Author

kumkee commented Dec 6, 2023

Submit a PR and I'll review and we can iterate as needed.

Hi @aaronpowell,

  1. CI build process failed. I see this happens to your one other GitHub Action build attempt. Have you found out why it failed?
  2. Can you give me some light on how to test or install the locally built library?

@fwaris
Copy link

fwaris commented Apr 25, 2024

looking for the same capability

I tried to build it myself also but I think the build tooling needs to be updated, first

@kumkee
Copy link
Author

kumkee commented Apr 25, 2024

looking for the same capability

I tried to build it myself also but I think the build tooling needs to be updated, first

@fwaris, if you don't use the Analyzer, you can use my build for now.

@fwaris
Copy link

fwaris commented Apr 25, 2024

ok great. thanks!

BTW I was able to build by updating dotnet tools and using a global.json for .Net 6

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants