简体   繁体   English

雪花网络连接器连接字符串无效

[英]Snowflake Net Connector Connection string is invalid

I'm trying to connect to our Snowflake DB using SSO with the ff connection string but keeps on getting an error.我正在尝试使用带有 ff 连接字符串的 SSO 连接到我们的 Snowflake DB,但不断出现错误。 I'm using https://github.com/snowflakedb/snowflake-connector-net for my .NET 4.6.1 console application just to test things out.我将https://github.com/snowflakedb/snowflake-connector-net用于我的 .NET 4.6.1 控制台应用程序只是为了测试。 I have confirmed that my SSO is able to login to the Snowflake Web UI.我已确认我的 SSO 能够登录到 Snowflake Web UI。 Found related docs: https://docs.snowflake.com/en/user-guide/admin-security-fed-auth-use.html#native-sso-okta-only找到相关文档: https : //docs.snowflake.com/en/user-guide/admin-security-fed-auth-use.html#native-sso-okta-only

connection string:连接字符串:

AUTHENTICATOR=https://{okta_account_name}.okta.com;ACCOUNT={org}.{region};HOST={org}.{region}.snowflakecomputing.com;PORT=443;ROLE={role};WAREHOUSE={warehouse};USER={sso email};password={sso password};DB={db};SCHEMA={schema}

error:错误:

Exception: Error: Connection string is invalid: Unable to connect SqlState: 08006, VendorCode: 270008, QueryId:

Maybe I posted a question too soon.也许我发布的问题太早了。 Following the Readme.md for Snowflake Dotnet Connector, I was able to generate the logs thru log4net.按照 Snowflake Dotnet Connector 的 Readme.md,我能够通过 log4net 生成日志。 The underlying exception was潜在的例外是

[2021-08-11 23:09:04,732] [1] [ERROR] [Snowflake.Data.Core.SFSession] Unable to connect
System.PlatformNotSupportedException: Operation is not supported on this platform.
   at Snowflake.Data.Core.HttpUtil.setupCustomHttpHandler(HttpClientConfig config)
   at Snowflake.Data.Core.HttpUtil.<>c__DisplayClass10_0.<RegisterNewHttpClientIfNecessary>b__1()
   at Microsoft.Extensions.DependencyInjection.HttpClientBuilderExtensions.<>c__DisplayClass5_0.<ConfigurePrimaryHttpMessageHandler>b__1(HttpMessageHandlerBuilder b)
   at Microsoft.Extensions.Http.DefaultHttpClientFactory.<>c__DisplayClass17_0.<CreateHandlerEntry>g__Configure|0(HttpMessageHandlerBuilder b)
   at Microsoft.Extensions.Http.LoggingHttpMessageHandlerBuilderFilter.<>c__DisplayClass3_0.<Configure>b__0(HttpMessageHandlerBuilder builder)
   at Microsoft.Extensions.Http.DefaultHttpClientFactory.CreateHandlerEntry(String name)
   at Microsoft.Extensions.Http.DefaultHttpClientFactory.<>c__DisplayClass14_0.<.ctor>b__1()
   at System.Lazy`1.CreateValue()
   at System.Lazy`1.LazyInitValue()
   at System.Lazy`1.get_Value()
   at Microsoft.Extensions.Http.DefaultHttpClientFactory.CreateHandler(String name)
   at Microsoft.Extensions.Http.DefaultHttpClientFactory.CreateClient(String name)
   at Snowflake.Data.Core.HttpUtil.GetHttpClient(HttpClientConfig config)
   at Snowflake.Data.Core.SFSession..ctor(String connectionString, SecureString password)

After browsing the web with similar exception it was mostly about the target .NET framework not satisfying the requirement.浏览网页后出现类似异常,主要是目标 .NET 框架不满足要求。 I was initially targeting .NET Framework 4.6.1 but after changing it to 4.7.2 everything worked fine as expected.我最初的目标是 .NET Framework 4.6.1,但在将其更改为 4.7.2 后,一切正常。 It was indeed mentioned on the repo that the driver is now targeting 4.7.2 but I don't recall seeing it being unable to support lower framework versions.在 repo 中确实提到该驱动程序现在针对 4.7.2,但我不记得看到它无法支持较低的框架版本。 I tried downgrading the driver to the earliest version and upgrading it to the latest one by one with no avail.我尝试将驱动程序降级到最早的版本,然后将其逐个升级到最新版本,但无济于事。 Hope this help others facing the same issue.希望这可以帮助其他面临同样问题的人。

You may also try browser-based SSO:您也可以尝试基于浏览器的 SSO:

In the connection string, set AUTHENTICATOR=externalbrowser, and set USER to the login name for your IdP.在连接字符串中,设置 AUTHENTICATOR=externalbrowser,并将 USER 设置为 IdP 的登录名。

using (IDbConnection conn = new SnowflakeDbConnection()) { conn.ConnectionString = "account=testaccount;authenticator=externalbrowser;user={login_name_for_IdP};db=testdb;schema=testschema";使用 (IDbConnection conn = new SnowflakeDbConnection()) { conn.ConnectionString = "account=testaccount;authenticator=externalbrowser;user={login_name_for_IdP};db=testdb;schema=testschema";

conn.Open();

conn.Close();

} where: } 在哪里:

{login_name_for_IdP} is your login name for your IdP. {login_name_for_IdP} 是您的 IdP 的登录名。

Based on my experience with Snowflake.Data , it supports .Net framework starting from version 4.6.1.根据我对Snowflake.Data经验,它从 4.6.1 版本开始支持 .Net 框架。

The connection string is like:连接字符串如下:

 connStr="scheme=https;account=youraccount;host=xxx.snowflakecomputing.com;port=443;proxyhost=xx.myproxy.com;proxyport=80;role=MY_ROLE;warehouse=WAREHOUSE_NAME;user=userid;password=xxx;authenticator=xxx.okta.com"
You may also try to set authenticator=externalbrowser . 您也可以尝试设置authenticator=externalbrowser

I personally prefer to connect to Snowflake using ODBC Driver.我个人更喜欢使用 ODBC 驱动程序连接到雪花。 Please refer to https://docs.snowflake.com/en/user-guide/odbc.html on how to install ODBC driver in your local machine.请参阅https://docs.snowflake.com/en/user-guide/odbc.html了解如何在本地机器上安装 ODBC 驱动程序。 Once you install and configure Snowflake in your machine, you may connect to Snowflake using System.Data.Odbc library.在您的机器上安装和配置 Snowflake 后,您可以使用System.Data.Odbc库连接到 Snowflake。

The connection string might looks like:连接字符串可能如下所示:

 connStr="Dsn=DataSourceName;uid=userID;pwd=xxx"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM