0

I am trying to connect to Snowflake via azure function app. Following is the code snippet (ref: https://github.com/snowflakedb/snowflake-connector-net#create-a-connection ) I am using:

using (IDbConnection conn = new SnowflakeDbConnection())
{
    // Connect to Snowflake
    conn.ConnectionString = @"host = <Account_Name>;account = <Account_Name>;user = <User_name>;password = <password>;db = <my_DB>; schema = <My_SCHEMA>;";
    conn.Open();
}

As long as I understand: account here is nothing but first part of the URL i.e., bold part of the URL account.east-us-2.azure.snowflakecomputing.com

Is there anything wrong I'm doing here? When execution comes to conn.Open(); I am getting an error like :
Invalid URI: The hostname could not be parsed.
Correct me if I have any code error here.

shary.sharath
  • 649
  • 2
  • 14
  • 29

2 Answers2

1

For the account name, you need to omit the cloud provider and region. So instead of "account.east-us-2.azure" it should be only "account".

Since this account is not in the US West deployment, you also must supply a "host" parameter, which does not appear in your connection string. The host should be "account.east-us-2.azure.snowflakecomputing.com"

Here's a sample connection string:

conn.ConnectionString = "account=accountname;host=accountname.east-us-2.azure.snowflakecomputing.com;user=myuser;password=*****;db=test;schema=public;warehouse=test";
Greg Pavlik
  • 10,089
  • 2
  • 12
  • 29
  • 1
    Thank you @Greg Pavlik, it worked great. But now I am getting "IP [405316281041245] is not allowed to access Snowflake." error. may be something related to login. – shary.sharath Feb 13 '20 at 07:43
  • That message means there's a network policy (IP white list) that is preventing your machine's IP from accessing your Snowflake account. Check with someone who has the Snowflake ACCOUNTADMIN or SECURITYADMIN roles and have them change it. You could also VPN into a network range that's in the white list, but that only works if your VPN client sends all HTTPS traffic through your VPN server. If it sends your company domain's traffic through that server but all other traffic through the public internet, they'll need to change the white list. You could also remote into a jump server. – Greg Pavlik Feb 13 '20 at 15:14
0

Account name is string including cloud region ending at snowflakecomputing.com

In your example:

: account.east-us-2.azure

Hope this helps.

alyssaeliyah
  • 2,214
  • 6
  • 33
  • 80
FKayani
  • 981
  • 1
  • 5
  • 10