Reputation: 615
Using the preview package for Microsoft.Azure.Management.Monitor, I am trying to get metrics from Azure into a .NET Core application, but I am uncertain about what to input as "resourceUri".
var serviceCreds = await ApplicationTokenProvider.LoginSilentAsync(tenantId, clientId, secret);
var monitorClient = new MonitorManagementClient(serviceCreds);
monitorClient.SubscriptionId = subscriptionId;
var resourceUri = "";
var metrics = await monitorClient.Metrics.ListAsync(resourceUri: resourceUri, cancellationToken: CancellationToken.None);
What should I insert in the resourceUri variable, and where do I get this uri from in Azure? A lot of things are great about Azure, but not documentation 🤨
Upvotes: 2
Views: 326
Reputation: 29940
Good question.
The resourceUri is in this format(this example is for web app, and you should replace with your real subscriptionsId
, resourceGroupsName
etc.):
/subscriptions/4d7e91d4-e930-4bb5-a93d-163aa358e0dc/resourceGroups/Default-Web-westus/providers/microsoft.web/serverFarms/DefaultServerFarm
You can find this information in the source code, here.
And for different resources, the format has a little difference, I add another resourceUri for blob storage:
/subscriptions/xxx/resourceGroups/xxx/providers/Microsoft.Storage/storageAccounts/xxx/blobServices/default/providers/Microsoft.Insights/metrics/ContainerCount
If you still have issues, please feel free to let me know.
Upvotes: 2