snowflakedb / snowflake-connector-net

Snowflake Connector for .NET
Apache License 2.0
180 stars 138 forks source link

SNOW-1808401: Issue while reading private key from azure functions configs #1060

Open hemantkadam03 opened 6 days ago

hemantkadam03 commented 6 days ago

I always get below exception when my azure serverless application reads private key and tries to connect to snowflake.

Error: Could not read private key with value passed in connection string. \n Error : incorrect private key value or private key format: use "\n" for newlines and double the equals sign. SqlState: , VendorCode: 270052, QueryId: : System.NullReferenceException: Object reference not set to an instance of an object.

I have tried adding "\n" and double equal signs in my privatekey but still not working. Strange thing is same connection string with private key works fine, if i run serverless application locally in visual studio on my windows laptop. below is sample snowflake connection string which i am coufiguring in cloud service.

account=accountName;ROLE=roleName;user=userName;AUTHENTICATOR=snowflake_jwt;PRIVATE_KEY=\"-----BEGIN PRIVATE KEY-----\nASDASDASDjkhkjhASDASDkjhkjj\najhgsdjhasgdhjasdASDASDASDajshdjhsaasdas\njkashdkhjsk\n83798324jksdfhkjsdfv7jXxSXsY4xW\n-----END PRIVATE KEY-----\n\";schema=schemaName;db=dbName;

Can you please suggest any solution to this. i did connect with snowflake team but they mention as request is not reaching to snowflake so it means the issue is with .net driver which is Snowflake.Data V2.2.0

Please answer these questions before submitting your issue.

In order to accurately debug the issue this information is required. Thanks!

  1. What version of .NET driver are you using? Snoeflake.Data V 2.2.0

  2. What operating system and processor architecture are you using? linux

  3. What version of .NET framework are you using? .net 8.0

  4. What did you do?

  5. What did you expect to see?

    it should accept the snowflake connection string with private key and then connect to snowflake

  6. Can you set logging to DEBUG and collect the logs?

Error: Could not read private key with value passed in connection string. \n Error : incorrect private key value or private key format: use "\n" for newlines and double the equals sign. SqlState: , VendorCode: 270052, QueryId: : System.NullReferenceException: Object reference not set to an instance of an object. https://community.snowflake.com/s/article/How-to-generate-log-file-on-Snowflake-connectors

There is an example in READMD.md file showing you how to enable logging.

Before sharing any information, please be sure to review the log and remove any sensitive information.

sfc-gh-dszmolka commented 4 days ago

hi, thanks for raising this issue. So Snowflake.Data 2.2.0 is very old and several bugfixes were introduced since it was released. Do you think it would be possible to try with the latest version?

Also can you please give me the case number you had with Snowflake Support where the advice was to raise the issue here ?