How to get the Workspace ID of an Azure Log Analytics workspace via C#

前端 未结 2 1376
醉话见心
醉话见心 2021-01-07 01:55

How can I get the Workspace ID of a Log Analytics workspace in Azure via C#?

2条回答
  •  栀梦
    栀梦 (楼主)
    2021-01-07 02:21

    I've since found that the OperationalInsightsManagementClient class can be used as well.

    var client = new OperationalInsightsManagementClient(GetCredentials()) {SubscriptionId = subscriptionId};
    return (await client.Workspaces.ListByResourceGroupWithHttpMessagesAsync(resourceGroupName))
        .Body
        .Select(w => w.CustomerId)
        .FirstOrDefault();
    

提交回复
热议问题