C# 如何从Azure门户获取活动日志

C# 如何从Azure门户获取活动日志,c#,azure,azure-sdk-.net,C#,Azure,Azure Sdk .net,我想从Azure门户检索所有活动日志。我开始试着联系。我实际上得到了我的连接,但我不知道如何获得相关的活动日志。我是否使用了正确的API var operation = networkClient.VirtualNetworkGatewayConnections.ListWithHttpMessagesAsync(resourceGroup); if (operation != null) { var result = operation.Result; if (result

我想从Azure门户检索所有活动日志。我开始试着联系。我实际上得到了我的连接,但我不知道如何获得相关的活动日志。我是否使用了正确的API

var operation = networkClient.VirtualNetworkGatewayConnections.ListWithHttpMessagesAsync(resourceGroup);
if (operation != null)
{
    var result = operation.Result;

    if (result != null)
    {
         var body = result.Body;

         foreach (Microsoft.Azure.Management.Network.Models.VirtualNetworkGatewayConnection connection in body)
         {
              Console.WriteLine(connection.Name);
         }
    }
}

Azure活动日志/审核日志可以通过多种方式读取。您可以将它们导出到存储帐户并从那里查看。您可以使用webhooks和restapi使用自定义工具或第三方工具来读取它。您可以将它们用作powerbi的数据源,并将其视为图表、表格等。您可以将日志分析解决方案添加到您的工作区,并将其配置为读取活动日志


Azure活动日志/审核日志可以通过多种方式读取。您可以将它们导出到存储帐户并从那里查看。您可以使用webhooks和restapi使用自定义工具或第三方工具来读取它。您可以将它们用作powerbi的数据源,并将其视为图表、表格等。您可以将日志分析解决方案添加到您的工作区,并将其配置为读取活动日志

如何获取相关的活动日志

如果希望以编程方式检索和查看活动日志,可以尝试

如何获取相关的活动日志

如果希望以编程方式检索和查看活动日志,可以尝试


我使用了这个示例代码,只做了少许修改:

InsightsClient客户端=新InsightsClient(凭据);
DateTime endDateTime=DateTime.Now;
DateTime startDateTime=endDateTime.AddDays(天);

string filterString=filterString.Generate(eventData=>(eventData.EventTimestamp>=startDateTime)和&(eventData.EventTimestamp我使用了这个示例代码,只做了少许修改:

InsightsClient客户端=新InsightsClient(凭据);
DateTime endDateTime=DateTime.Now;
DateTime startDateTime=endDateTime.AddDays(天);

string filterString=filterString.Generate(eventData=>(eventData.EventTimestamp>=startDateTime)&&(eventData.EventTimestamp所以,我不能使用Microsoft.Azure.Management或Microsoft.Azure.Insights NuGet软件包?我必须管理多个门户,因为我的每个客户都有自己的门户,所以我尝试使其非常简单。我对REST不熟悉,但如果这是唯一的方法,我将使用它,谢谢。因此,我不能使用Microsoft.Azure.Management或Microsoft.Azure.Insights NuGet软件包?我必须管理多个门户,因为我的每个客户都有自己的门户,所以我尽量让它非常简单。我不熟悉REST,但如果这是唯一的方法,我会使用它,谢谢。
InsightsClient client = new InsightsClient(credentials);
DateTime endDateTime = DateTime.Now;
DateTime startDateTime = endDateTime.AddDays(days);
string filterString = FilterString.Generate<ListEventsForResourceProviderParameters>(eventData => (eventData.EventTimestamp >= startDateTime) && (eventData.EventTimestamp <= endDateTime) && (eventData.ResourceType == "Microsoft.Network/connections"));

EventDataListResponse response = client.EventOperations.ListEvents(filterString, selectedProperties: null);
List<EventData> logList = new List<EventData>(response.EventDataCollection.Value);

while (!string.IsNullOrEmpty(response.EventDataCollection.NextLink))
{
    response = client.EventOperations.ListEventsNext(response.EventDataCollection.NextLink);
    logList.AddRange(response.EventDataCollection.Value);
}