question

GoudKanthiAniketh-4694 avatar image
0 Votes"
GoudKanthiAniketh-4694 asked GoudKanthiAniketh-4694 commented

Data retrival through C# application

Hi,

I'm new to Azure, could anyone help me while I'm trying to build C# application to retrieve the VM Metrics data
Metrics are:
1. CPU utlization
2. RAM Usage
3. Logical disk space used.

Can anyone help me with this.


azure-virtual-machines
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

@GoudKanthiAniketh-4694 Any update on the issue?

If the suggested response helped you resolve your issue, do click on "Mark as Answer" for the answer that helped you for benefit of the community.

Thanks.

0 Votes 0 ·

1 Answer

shivapatpi-MSFT avatar image
0 Votes"
shivapatpi-MSFT answered GoudKanthiAniketh-4694 commented

Hello @GoudKanthiAniketh-4694 ,
Thanks for your query !
To retrieve those metrics first you might want to enable the diagnostics for that VM.

Go to VM -> Monitoring -> Diagnostics Settings: (Follow the remaining steps)

You can select the required metrics like below:
Performance counters
Collecting data for these counters:
CPU
Memory
Disk
Network

Once you enable those , it will deploy an extension
Microsoft.Azure.Performance.Diagnostics.AzurePerformanceDiagnostics

As a part of enabling that extension , you will have to choose the storage account where all the required metrics will be stored.
In that particular storage account , it will create corresponding tables with name WADMetricsPT* .

Table data and columns looks like below:

128503-image.png

You will have to write a C#.net program using Azure API's to query that storage account tables data.

Sample high level piece of code to connect to azure storage table and retrieve the data:

<add key="StorageConnectionString" value="DefaultEndpointsProtocol=https;
AccountName=[Name of storage account];AccountKey=[Access Key for storage account]">

CloudStorageAccount cloudStorageAccount =
CloudStorageAccount.Parse
(ConfigurationManager.AppSettings["StorageConnectionString"]);
CloudTableClient tableClient = cloudStorageAccount.CreateCloudTableClient();
string tableName = "tablename"
CloudTable cloudTable = tableClient.GetTableReference(tableName);
TableOperation tableOperation = TableOperation.Retrieve(partitionKey, rowKey);
TableResult tableResult = table.Execute(tableOperation);


Please Note: You will have to query the corresponding Metrics which is available in CounterName Column

Kindly let us know if you need additional help on this.

Regards,
Shiva.




image.png (111.4 KiB)
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Thank you shivapatpi for providing the information. I will work on the process by using your walkthrough steps.

0 Votes 0 ·