-
Notifications
You must be signed in to change notification settings - Fork 389
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. |
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: