Using "Loggedin" view i am trying to list HDInsight clusters in my subscription but when i am trying to run the code, "Loggedin" page keeps loading without any output.I am not able to figure out where i am going wrong.
While debugging, the code hangs up at the line var cluster = client.ListClusters();
in controller.
At this instance, output window displays following message :
Microsoft.WindowsAzure.ServiceRuntime Verbose: 500 : Role instance status check starting Microsoft.WindowsAzure.ServiceRuntime Verbose: 502 : Role instance status check succeeded: Ready The thread 0x59fc has exited with code 259 (0x103).
Any help would be greatly appreciated.
Controller
public ActionResult Loggedin()
{
Guid subscriptionId = new Guid("Subscription_id"); //your-subscription-id
string certName = "Friendly_name"; //your friendly name
// Create an HDInsight Client
X509Store store = new X509Store(StoreName.My);
store.Open(OpenFlags.ReadOnly);
X509Certificate2 cert = store.Certificates.Cast<X509Certificate2>().First(item => item.FriendlyName == certName);
HDInsightCertificateCredential creds = new HDInsightCertificateCredential(subscriptionId, cert);
IHDInsightClient client = HDInsightClient.Connect(creds);
var cluster = client.ListClusters();
var c = new List<ClusterList>();
foreach (var item in cluster)
{
c.Add(new ClusterList() { Name = item.Name });
c.Add(new ClusterList() { Node = item.ClusterSizeInNodes });
}
return View(c);
}
Model
public class ClusterList
{
public string Name { get; set; }
public int Node { get; set; }
}
View
@model List<listCluster.Models.ClusterList>
@{
ViewBag.Title = "Loggedin";
Layout = "~/Views/Shared/_Layout.cshtml";
}
<h2>Loggedin</h2>
<div>
<table>
<tr>
<th>@Html.Label("Name")</th>
<th>@Html.Label("Node")</th>
</tr>
<tr>
<td>@Model.Name</td>
<td>@Model.Node</td>
</tr>
</table>
</div>