shary.sharath
shary.sharath

Reputation: 709

How to resolve Invalid URI issue in C# while connecting to Snowflake?

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.

Upvotes: 0

Views: 1264

Answers (2)

FKayani
FKayani

Reputation: 1021

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

In your example:

: account.east-us-2.azure

Hope this helps.

Upvotes: 0

Greg Pavlik
Greg Pavlik

Reputation: 11066

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";

Upvotes: 1

Related Questions