-
Notifications
You must be signed in to change notification settings - Fork 396
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
Provide an authentication and secrets mechanism for database access #992
Comments
It would be great if we could use the |
Thinking a little more broadly than databases, could we possibly get auth tokens via |
The input type hint system was intended to be used this way, so now it's hopefully just a matter of building the providers. |
This work depends on #3567. |
This is fairly simple to do if you provide the connection string in the connect command as a variable. I would appreciate if best practices are documented in the examples, and not just hard coded connection string. It takes me so much time to figure out how to do this properly #r "nuget:Microsoft.DotNet.Interactive.SqlServer,*-*"
#r "nuget:Microsoft.Extensions.Configuration, 7.0.0"
#r "nuget:Microsoft.Extensions.Configuration.UserSecrets, 7.0.0"
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Configuration.UserSecrets;
// In memory config
var inMemoryConfigSettings = new Dictionary<string, string> {
{"Some:Setting", "asdf"},
};
// Go to %APPDATA%/Microsoft/UserSecrets and create a folder with this name containing a secrets.json file
var userSecretsId = "e8ce9a26-4485-4002-b685-4fdedbb1e521";
IConfiguration configuration = new ConfigurationBuilder()
.AddInMemoryCollection(inMemoryConfigSettings)
.AddUserSecrets(userSecretsId)
.Build();
var connectionString = $"Data Source={configuration["Sql:Server"]}.database.windows.net;Initial Catalog={configuration["Sql:Database"]};user id={configuration["Sql:Username"]};password={configuration["Sql:Password"]}";
#!connect mssql --kernel-name mykernel @csharp:connectionString |
@KristofferBerge I'm working on the documentation for this now but secrets management is a new feature of Polyglot Notebooks that you can try out in VS Code Insiders now. |
I'm replacing ADS with VS Code, I've already set up the MSSQL extension to have all my connections nicely aliased and have those passwords stored securely. Isn't there a way for Polyglot Notebooks to reuse those? In a perfect world, I would right-click the connection and select "New Notebook" and have it be already connected. But as a consolation prize, I would happily use the magic command with one of the MSSQL aliases. Is this doable? |
There isn't, but Polyglot Notebooks does have its own secret storage mechanism, which you can read about here: https://github.com/dotnet/interactive/blob/main/docs/input-prompts.md#saving-a-value We've recently added a menu to make it easier to establish data connections and give you easier access to previously-used connections. You can see these menu options using the command palette command If you have any feedback on these features we'd love to hear it. |
In order to prevent people from having to paste connection strings into notebooks, we should have proper authentication support. This could include:
#!connect
magic command.The text was updated successfully, but these errors were encountered: