Search code examples
azurenugetazure-monitoringazure-monitor

unable to find nuget for MonitorClient


i am trying to access monitoring data using Monitor API.

I am trying to create Monitoring Client using this code in azure functions .net core 3.1 but no nuget seems to resolve it. Can someone suggest the correct nuget

    private async Task<MonitorClient> GetMonitorClientAsync()
    {
        var serviceCreds = await ApplicationTokenProvider.LoginSilentAsync(tenantId, clientId, secret);
        var monitorClient = new MonitorClient(serviceCreds);
        monitorClient.SubscriptionId = subscriptionId;
        return monitorClient;
    }

Solution

  • unable to find nuget for MonitorClient

    • Use MonitorManagementClient in place of MonitorClient
    • MonitorManagementClient is available in the Microsoft.Azure.Management.Monitor namespace
    • Install the latest 0.28.0-preview version of Microsoft.Azure.Management.Monitor. If it is not available in the Nuget Packages, run the below command in the Package Manager Console
    Install-Package Microsoft.Azure.Management.Monitor -Version 0.28.0-preview
    

    Nuget Packages :

    enter image description here

    Code :

    using Microsoft.Rest.Azure.Authentication;
    using Microsoft.Azure.Management.Monitor;
    
    var monitorClient = new MonitorManagementClient(serviceCreds);   
    

    References taken from :

    MonitorClient's replacement MonitorManagementClient