Skip to content
master
Switch branches/tags
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
img
 
 
 
 
 
 
 
 

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

Releases

No releases published

Packages

No packages published

Languages