Skip to content

liarjo/AzureMetricSample

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AzureMetricSample

This sample shows how can you read VM metrics using Azure Insights REST API.
To use this API metric you always needs to do two calls: first to retrieve metric definition and the second to read the metrics values.

Pre-requisites

  1. Have a VM created in Azure with diagnostic activated
  2. Have a user created in Azure AD
  3. Grant this user as a reader of the VM
  4. Create an application in Azure AD and gives permission to other application Windows Azure Service Manager API

Configure the sample code

You need to configure APP.config with this data
  1. tenantId: you can see your tenant id in Active directory, application endpoints
  2. clientId:You can read client id in e Active directory, application property
  3. userName: username from Azure Active Directory
  4. password: user password
  5. SubscriptionId: subscription ID from the resource, in this case the VM

On the code you need to change the resource with your data

  string ResourceGroupName = "metricsampleRG";
  string ProviderName="Microsoft.Compute";
  string VirtualMachineName="metricsample";
This data can ead from Resource ID in the new portal

and looks like this sample
/subscriptions/d134b748-cba2-43e2-a445-edc634076368/resourceGroups/metricsampleRG/providers/Microsoft.Compute/virtualMachines/metricsample

Run

When run the sample program you will see:

  1. The Token
  2. The metric list for this recource
  3. The metric values for this recource(filtered)

About

VM metrics using Azure Insights REST API.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages