Database Reference
In-Depth Information
After executing the DeleteCluster() method, you can go back to the Azure portal and confirm that the
AutomatedHDICluster , which we just provisioned through code, no longer exists. You see only the two clusters that
were previously created, as shown in Figure 4-8 .
Figure 4-8. AutomatedHDICluster is deleted
Using the HDInsight management package, you can easily list, create, and delete your HDInsight clusters on
Azure. Add a call to the functions we added earlier inside the Main() method, and call them sequentially to view the
output in the console window. The complete code listing for the Program.cs file along with the Main() method is
provided in Listing 4-5.
Listing 4-5. The Complete Code
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Security.Cryptography.X509Certificates;
using Microsoft.WindowsAzure.Management.HDInsight
namespace HadoopClient
{
class Program
{
static void Main(string[] args)
{
ListClusters();
CreateCluster();
DeleteCluster();
Console.ReadKey();
}
public static void ListClusters()
{
var store = new X509Store();
store.Open(OpenFlags.ReadOnly);
var cert = store.Certificates.Cast<X509Certificate2>().
First(item => item.Thumbprint == Constants.thumbprint);
var creds = new HDInsightCertificateCredential(Constants.subscriptionId, cert);
var client = HDInsightClient.Connect(creds);
var clusters = client.ListClusters();
foreach (var item in clusters)
 
Search WWH ::




Custom Search