Community Articles
Find and share helpful community-sourced technical articles
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.
Labels (1)

Sharing source code I wrote to a prospect that wants to try Phoenix + .NET.

It's a simple code that POST the query to Phoenix Server and parse result JSON and prints results on console:

using System;
using System.Net;
using System.Collections.Generic;
using Newtonsoft.Json;
using System.Text;
namespace ConsoleApplication1
    class PhoenixSample
        public class FirstFrame
            public String offset;
            public List<List<String>> rows;
        public class Result
            public FirstFrame firstFrame;
            public int updateCount;
        public class PhoenixResult
            public string response { get; set; }
            public List<Result> results { get; set; }
        static void Main(string[] args)
                string url = "";
                string query = "select * from test";
                var syncClient = new WebClient();
                syncClient.Headers["request"] = "{\"request\":\"prepareAndExecute\",\"connectionId\":\"b27cbc83-a514-49f0-9bbe-f15d8bfb3532\",\"sql\":\"" + query + "\",\"maxRowCount\":-1}";
                syncClient.Headers["Content-Type"] = "application/json";
                byte[] responseArray = syncClient.UploadData(url, "POST", Encoding.ASCII.GetBytes(""));
                string json = Encoding.ASCII.GetString(responseArray);
                System.Diagnostics.Debug.WriteLine("json=" + json);
                PhoenixResult test = JsonConvert.DeserializeObject<PhoenixResult>(json);
                for (int i = 0; i < test.results[0].firstFrame.rows.Count; i++)
                    for (int j = 0; j < test.results[0].firstFrame.rows[i].Count; j++)
                        System.Diagnostics.Debug.Write("row # " + i + " col # " + j + " = ");
            catch (Exception e)

Nice! I had made something similar a few months back so this might be my opportunity to share that as well

New Contributor

Microsoft released a preview of their .NET ProtoBuf client for Phoenix (hdinsight-phoenix-sharp) on in June 2016. I've found it worked well against my HDP 2.4 (HBASE 1.1.2 / Phoenix 4.4) cluster, but the API was unfamiliar to me. As I learned it, I implemented a System.Data IDbConnection, IDbCommand et al wrapper API around it, named Garuda.Data. It makes access to Phoenix from .NET code feel almost like SqlConnection, SqlCommand, etc - Check it out on Nuget:

Blog post on the topic:

Garuda.Data Github Repo:

Don't have an account?
Coming from Hortonworks? Activate your account here
Version history
Revision #:
1 of 1
Last update:
‎10-26-2015 11:09 PM
Updated by:
Top Kudoed Authors