Database Reference
In-Depth Information
Listing 4-1. The Constants.cs File
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace HadoopClient
{
public class Constants
{
public static Uri azureClusterUri = new Uri(" https://democluster.azurehdinsight.net:443 " );
public static string thumbprint = "your_subscription thumbprint";
public static Guid subscriptionId = new Guid("your_subscription_id");
public static string clusterUser = "admin";
public static string hadoopUser = "hdp";
public static string clusterPassword = "your_password";
public static string storageAccount = " democluster.blob.core.windows.net " ;
public static string storageAccountKey = "your_storage_key;
public static string container = "democlustercontainer";
public static string wasbPath =
"wasb://democlustercontainer@democluster.blob.core.windows.net";
}
}
When you choose your password, make sure to meet the following password requirements to avoid getting an
error when you execute your program:
The field must contain at least 10 characters.
The field cannot contain the user name.
The field must contain one each of the following: an uppercase letter, a lowercase letter, a
number, a special character.
Next, navigate to the Program.cs file in the solution that has the Main() function, the entry point of a console
application. You need to add the required references to access the certificate store for the Azure certificate as well as
different HDInsight management operations. Go ahead and add the following using statements at the top of your
Program.cs file:
using System.Security.Cryptography.X509Certificates;
using Microsoft.WindowsAzure.Management.HDInsight;
Create a new public function called ListClusters() . This function will have the code to query the certificate
store and list the existing HDInsight clusters under that subscription. Listing 4-2 outlines the code for the
ListClusters() function.
Listing 4-2. Enumerating Clusters in Your Subscription
public static void ListClusters()
{
var store = new X509Store();
store.Open(OpenFlags.ReadOnly);
var cert = store.Certificates.Cast<X509Certificate2>()
 
Search WWH ::




Custom Search