Removing LogConverter due to lack of support

This commit is contained in:
Jon Ormond 2022-06-22 16:26:57 -07:00
Родитель 56c6df899f
Коммит e04e9db0c1
36 изменённых файлов: 0 добавлений и 2464 удалений

Просмотреть файл

@ -1,60 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{4D220267-2881-4E52-8551-BCEFF0DD380C}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>PowerBIConnector</RootNamespace>
<AssemblyName>ConverterLib</AssemblyName>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Compile Include="Entity.cs" />
<Compile Include="StorageURL.cs" />
<Compile Include="PowerBIConnectorException.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<Reference Include="Newtonsoft.Json, Version=8.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.8.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

Просмотреть файл

@ -1,153 +0,0 @@
//----------------------------------------------------------------------------------
// Microsoft Azure Networking
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// This code is licensed under the MIT License (MIT). THIS CODE IS PROVIDED *AS IS*
// WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY IMPLIED
// WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABILITY,
// OR NON-INFRINGEMENT.
//----------------------------------------------------------------------------------
namespace PowerBIConnector
{
using System.Collections.Generic;
using Newtonsoft.Json;
/// <summary>
/// Type definitions for parsing JSON log entries.
/// NetworkSecurityGroupRuleCounter.Log class encapsulates counters log.
/// NetworkSecurityGroupRuleEvent.Log class encapsulates events log.
/// </summary>
public class LogPropertyBase
{
public string macAddress { get; set; }
public string ruleName { get; set; }
public string direction { get; set; }
public string type { get; set; }
public string vnetResourceGuid { get; set; }
public string subnetPrefix { get; set; }
}
public class LogBase
{
public string time { get; set; }
public string systemId { get; set; }
public string category { get; set; }
public string resourceId { get; set; }
public string operationName { get; set; }
}
namespace NetworkSecurityGroupRuleCounter
{
public class LogProperty : LogPropertyBase
{
public string matchedConnections { get; set; }
}
public class Log : LogBase
{
public LogProperty properties { get; set; }
}
public class LogRecords
{
public List<Log> records { get; set; }
}
}
namespace NetworkSecurityGroupRuleEvent
{
public class LogPropertyCondition
{
public string destinationPortRange { get; set; }
public string sourcePortRange { get; set; }
public string sourceIP { get; set; }
public string destinationIP { get; set; }
public string protocols { get; set; }
}
public class LogProperty : LogPropertyBase
{
public string priority { get; set; }
public LogPropertyCondition conditions { get; set; }
}
public class Log : LogBase
{
public LogProperty properties { get; set; }
}
public class LogRecords
{
public List<Log> records { get; set; }
}
}
namespace LoadBalancLoadBalancerProbeHealthStatuserEvent
{
public class LogProperty
{
public string publicIpAddress { get; set; }
public string port { get; set; }
public string totalDipCount { get; set; }
public string dipDownCount { get; set; }
public string healthPercentage { get; set; }
}
public class Log : LogBase
{
public LogProperty properties { get; set; }
}
public class LogRecords
{
public List<Log> records { get; set; }
}
}
namespace LoadBalancerAlertEvent
{
public class EventProperty
{
[JsonProperty(propertyName: "public ip address")]
public string publicIpAddress { get; set; }
}
public class LogProperty
{
public string eventName { get; set; }
public string eventDescription { get; set; }
public EventProperty eventProperties { get; set; }
}
public class Log : LogBase
{
public LogProperty properties { get; set; }
}
public class LogRecords
{
public List<Log> records { get; set; }
}
}
}

Просмотреть файл

@ -1,21 +0,0 @@
//----------------------------------------------------------------------------------
// Microsoft Azure Networking
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// This code is licensed under the MIT License (MIT). THIS CODE IS PROVIDED *AS IS*
// WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY IMPLIED
// WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABILITY,
// OR NON-INFRINGEMENT.
//----------------------------------------------------------------------------------
namespace PowerBIConnector
{
using System;
class PowerBIConnectorException : Exception
{
public PowerBIConnectorException(string message) : base(message)
{ }
}
}

Просмотреть файл

@ -1,36 +0,0 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("ConverterUtility")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ConverterUtility")]
[assembly: AssemblyCopyright("Copyright © 2015")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("4d220267-2881-4e52-8551-bceff0dd380c")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

Просмотреть файл

@ -1,82 +0,0 @@
//----------------------------------------------------------------------------------
// Microsoft Azure Networking
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// This code is licensed under the MIT License (MIT). THIS CODE IS PROVIDED *AS IS*
// WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY IMPLIED
// WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABILITY,
// OR NON-INFRINGEMENT.
//----------------------------------------------------------------------------------
namespace PowerBIConnector
{
using System;
public enum ResourceType { NETWORKSECURITYGROUPS, LOADBALANCERS };
/// <summary>
/// Utility class used to generate log storage Uri.
/// </summary>
public class StorageURL
{
private const string RESOURCEID = "resourceId";
private const string SUBSCRIPTIONS = "SUBSCRIPTIONS";
private const string RESOURCEGROUPS = "RESOURCEGROUPS";
private const string PROVIDERS = "PROVIDERS";
private const string NETWORKSECURITYGROUPS = "NETWORKSECURITYGROUPS";
private const string DEFAULTLOGBLOB = "PT1H.json";
private readonly Uri containerUri;
private readonly string subscriptionId;
private readonly string resourceGroupsName;
private readonly string providersName;
private ResourceType resourceType;
private readonly string resourceTypeName;
private readonly string blobName;
public StorageURL(Uri containerUri, string subscriptionId, string resourceGroupsName, string providersName, string resourceTypeName, ResourceType resourceType, string blobName = DEFAULTLOGBLOB)
{
if ((containerUri == null)
|| String.IsNullOrWhiteSpace(subscriptionId)
|| String.IsNullOrWhiteSpace(resourceGroupsName)
|| String.IsNullOrWhiteSpace(providersName)
|| String.IsNullOrWhiteSpace(resourceTypeName)
|| String.IsNullOrWhiteSpace(blobName))
{
throw new PowerBIConnectorException("Invalid null argument found.");
}
this.containerUri = containerUri;
this.subscriptionId = subscriptionId;
this.resourceGroupsName = resourceGroupsName;
this.providersName = providersName;
this.resourceType = resourceType;
this.resourceTypeName = resourceTypeName;
this.blobName = blobName;
}
public Uri GetURL(DateTime logDateTimeStamp)
{
return GenerateURL(logDateTimeStamp);
}
private Uri GenerateURL(DateTime logDateTime)
{
string urlSegments = $"{containerUri.ToString()}{GenerateURLConfigSegments()}{GenerateURLDateTimeSegments(logDateTime)}/{blobName}";
return new Uri(urlSegments);
}
private string GenerateURLConfigSegments()
{
return $"/{RESOURCEID}=/{SUBSCRIPTIONS}/{subscriptionId}/{RESOURCEGROUPS}/{resourceGroupsName}/{PROVIDERS}/{providersName}/{resourceType}/{resourceTypeName}";
}
private string GenerateURLDateTimeSegments(DateTime logDateTime)
{
return $"/y={logDateTime.ToString("yyyy")}/m={logDateTime.ToString("MM")}/d={logDateTime.ToString("dd")}/h={logDateTime.ToString("HH")}/m={logDateTime.ToString("mm")}";
}
}
}

Просмотреть файл

@ -1,27 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-8.0.0.0" newVersion="8.0.0.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Data.Edm" publicKeyToken="31bf3856ad364e35" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-5.7.0.0" newVersion="5.7.0.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Data.Services.Client" publicKeyToken="31bf3856ad364e35" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-5.7.0.0" newVersion="5.7.0.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Data.OData" publicKeyToken="31bf3856ad364e35" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-5.7.0.0" newVersion="5.7.0.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.WindowsAzure.Storage" publicKeyToken="31bf3856ad364e35" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-6.2.2.0" newVersion="6.2.2.0"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2"/></startup></configuration>

Просмотреть файл

@ -1,4 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Newtonsoft.Json" version="8.0.1" targetFramework="net461" />
</packages>

Просмотреть файл

@ -1,30 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2"/>
</startup>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-8.0.0.0" newVersion="8.0.0.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.WindowsAzure.Storage" publicKeyToken="31bf3856ad364e35" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-6.2.2.0" newVersion="6.2.2.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Data.Edm" publicKeyToken="31bf3856ad364e35" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-5.7.0.0" newVersion="5.7.0.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Data.Services.Client" publicKeyToken="31bf3856ad364e35" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-5.7.0.0" newVersion="5.7.0.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Data.OData" publicKeyToken="31bf3856ad364e35" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-5.7.0.0" newVersion="5.7.0.0"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>

Просмотреть файл

@ -1,104 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{3AB3C315-9911-4013-955F-CF0162880532}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>CountersLogConverter</RootNamespace>
<AssemblyName>CountersLogConverter</AssemblyName>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
<RestorePackages>true</RestorePackages>
<TargetFrameworkProfile />
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.Azure.KeyVault.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Azure.KeyVault.Core.1.0.0\lib\net40\Microsoft.Azure.KeyVault.Core.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Data.Edm, Version=5.7.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Data.Edm.5.7.0\lib\net40\Microsoft.Data.Edm.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Data.OData, Version=5.7.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Data.OData.5.7.0\lib\net40\Microsoft.Data.OData.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Data.Services.Client, Version=5.7.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Data.Services.Client.5.7.0\lib\net40\Microsoft.Data.Services.Client.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.WindowsAzure.Storage, Version=6.2.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\WindowsAzure.Storage.6.2.2-preview\lib\net40\Microsoft.WindowsAzure.Storage.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Newtonsoft.Json, Version=8.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.8.0.2\lib\net45\Newtonsoft.Json.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Data.Services.Client" />
<Reference Include="System.Net" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Net.Http.WebRequest" />
<Reference Include="System.Runtime.Serialization" />
<Reference Include="System.Spatial, Version=5.7.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\System.Spatial.5.7.0\lib\net40\System.Spatial.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\ConverterLib\ConverterLib.csproj">
<Project>{4d220267-2881-4e52-8551-bceff0dd380c}</Project>
<Name>ConverterLib</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

Просмотреть файл

@ -1,154 +0,0 @@
//----------------------------------------------------------------------------------
// Microsoft Azure Networking
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// This code is licensed under the MIT License (MIT). THIS CODE IS PROVIDED *AS IS*
// WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY IMPLIED
// WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABILITY,
// OR NON-INFRINGEMENT.
//----------------------------------------------------------------------------------
namespace CountersLogConverterSample
{
using Microsoft.WindowsAzure.Storage;
using Microsoft.WindowsAzure.Storage.Blob;
using System;
using System.Collections.Generic;
using System.IO;
using PowerBIConnector;
using PowerBIConnector.NetworkSecurityGroupRuleCounter;
using Newtonsoft.Json;
/// <summary>
/// Sample code to download counters log and export it to a .CSV file.
/// </summary>
public class Program
{
/*************************************************************************************
** Below constants needs to be populated by user.
** Arguments can be retrieved from URL to the JSON log stored in the blob storage,
** it should look similar to below URL.
** https://shoebox.blob.core.windows.net/insights-logs-networksecuritygrouprulecounter/resourceId=
** /SUBSCRIPTIONS/D763EE4A-XXX-XXXX-XXXX-876035455EC4/RESOURCEGROUPS/INSIGHTOBONRPFOO
** /PROVIDERS/MICROSOFT.NETWORK/NETWORKSECURITYGROUPS/NSGINSIGHTOBONRPFOO
** /y=2015/m=08/d=26/h=00/m=00/PT1H.json
*************************************************************************************/
// Connection string to the blob storage.
private const string BlobStorageConnectionString = "<Blob storage connectiong string>";
// Container name in the above URL is : insights-logs-networksecuritygrouprulecounter
private const string CounterContainerName = "<Counter log Container Name>";
// This is path and name of the exported .CSV file.
private const string CounterCSVExportNamePath = "CountsLog.csv";
// Subscription in the above url is : D763EE4A-XXX-XXXX-XXXX-876035455EC4
private const string SubscriptionID = "<Azure Subscription ID>";
// Resource groups : INSIGHTOBONRPFOO
private const string ResrouceGroupsName = "<Resource group name>";
// Resource type name : NSGINSIGHTOBONRPFOO
private const string ResrouceTypeName = "<Resource type name>";
// Provider name : MICROSOFT.NETWORK
private const string ProviderName = "MICROSOFT.NETWORK";
// Beginning date and time of the exporting log segments.
private const string FilterDatetimeStart = "9/1/2015 1:00 AM";
// End date and time of the exporting log segments.
private const string FilterDateTimeEnd = "9/2/2015 10:00 PM";
static void Main()
{
Console.WriteLine("Starting counters log export.");
DateTime startDateTime = DateTime.Parse(FilterDatetimeStart);
DateTime endDateTime = DateTime.Parse(FilterDateTimeEnd);
GetNetworkSecurityGroupRuleCounters(startDateTime, endDateTime);
Console.WriteLine("Export completed.");
Console.WriteLine("Press any key to exit");
Console.ReadKey();
}
/// <summary>
/// Down loads JSON log files between 2 dates from the blob storage
/// and exports them into one .CSV file.
/// </summary>
/// <param name="logStart">Begin date and time of the log.</param>
/// <param name="logEnd">End date and time of the log.</param>
private static void GetNetworkSecurityGroupRuleCounters(DateTime logStart, DateTime logEnd)
{
// Creates client.
CloudStorageAccount storageAccount = CloudStorageAccount.Parse(BlobStorageConnectionString);
CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();
Console.WriteLine($"Getting reference to container {CounterContainerName}");
CloudBlobContainer container = blobClient.GetContainerReference(CounterContainerName);
// Instantiate the URL generator.
StorageURL storageUrl = new StorageURL(container.Uri, SubscriptionID, ResrouceGroupsName, ProviderName, ResrouceTypeName, ResourceType.NETWORKSECURITYGROUPS);
List<Log> logs = new List<Log>();
int itemPosition = 0;
// Using the date and time as arguments download all logs from the storage blob.
for (DateTime logTimeStamp = logStart; logTimeStamp <= logEnd; logTimeStamp = logTimeStamp.AddHours(1))
{
Console.WriteLine(logTimeStamp);
Uri storageblobUrl = storageUrl.GetURL(logTimeStamp);
CloudBlockBlob blockBlob = new CloudBlockBlob(storageblobUrl, storageAccount.Credentials);
MemoryStream memstream = new MemoryStream();
try
{
blockBlob.DownloadToStream(memstream);
memstream.Position = 0;
JsonSerializer serializer = new JsonSerializer();
using (StreamReader sr = new StreamReader(memstream))
using (JsonTextReader jsonTextReader = new JsonTextReader(sr))
{
// Deserialize JSON.
LogRecords logRecords = serializer.Deserialize<LogRecords>(jsonTextReader);
itemPosition = 0;
foreach (Log logItem in logRecords.records)
{
// Add deserialized logs.
logs.Add(logItem);
itemPosition++;
}
}
}
catch (Exception ex)
{
Console.WriteLine($"{ex.Message} - {storageblobUrl}");
}
}
// Dump everything in the logs list into a file.
using (StreamWriter file = new StreamWriter(CounterCSVExportNamePath))
{
file.WriteLine("time,systemId,resourceId,operationName,properties.vnetResourceGuid,properties.subnetPrefix"
+ ",properties.macAddress,properties.ruleName,properties.direction,properties.type,properties.matchedConnections");
foreach (Log log in logs)
{
file.WriteLine($"{DateTime.Parse(log.time).ToUniversalTime()}, {log.systemId}, {log.resourceId}, {log.operationName}"
+ $", {log.properties.vnetResourceGuid}, {log.properties.subnetPrefix}, {log.properties.macAddress}"
+ $", {log.properties.ruleName}, {log.properties.direction}, {log.properties.type}, {log.properties.matchedConnections}");
}
}
}
}
}

Просмотреть файл

@ -1,36 +0,0 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("CountersLogConverter")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("CountersLogConverter")]
[assembly: AssemblyCopyright("Copyright © 2013")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("02db5912-44fc-4b98-a1f9-854d6e6441fe")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

Просмотреть файл

@ -1,10 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.Azure.KeyVault.Core" version="1.0.0" targetFramework="net461" />
<package id="Microsoft.Data.Edm" version="5.7.0" targetFramework="net461" />
<package id="Microsoft.Data.OData" version="5.8.4" targetFramework="net461" />
<package id="Microsoft.Data.Services.Client" version="5.7.0" targetFramework="net461" />
<package id="Newtonsoft.Json" version="8.0.2" targetFramework="net461" />
<package id="System.Spatial" version="5.7.0" targetFramework="net461" />
<package id="WindowsAzure.Storage" version="6.2.2-preview" targetFramework="net461" />
</packages>

Просмотреть файл

@ -1,30 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2"/>
</startup>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-8.0.0.0" newVersion="8.0.0.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.WindowsAzure.Storage" publicKeyToken="31bf3856ad364e35" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-6.2.2.0" newVersion="6.2.2.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Data.Edm" publicKeyToken="31bf3856ad364e35" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-5.7.0.0" newVersion="5.7.0.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Data.Services.Client" publicKeyToken="31bf3856ad364e35" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-5.7.0.0" newVersion="5.7.0.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Data.OData" publicKeyToken="31bf3856ad364e35" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-5.7.0.0" newVersion="5.7.0.0"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>

Просмотреть файл

@ -1,104 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{85C81265-CA86-4C3D-93B9-7AC54FCD20AF}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>EventsLogConverter</RootNamespace>
<AssemblyName>EventsLogConverter</AssemblyName>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
<RestorePackages>true</RestorePackages>
<TargetFrameworkProfile />
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.Azure.KeyVault.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Azure.KeyVault.Core.1.0.0\lib\net40\Microsoft.Azure.KeyVault.Core.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Data.Edm, Version=5.7.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Data.Edm.5.7.0\lib\net40\Microsoft.Data.Edm.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Data.OData, Version=5.7.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Data.OData.5.7.0\lib\net40\Microsoft.Data.OData.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Data.Services.Client, Version=5.7.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Data.Services.Client.5.7.0\lib\net40\Microsoft.Data.Services.Client.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.WindowsAzure.Storage, Version=6.2.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\WindowsAzure.Storage.6.2.2-preview\lib\net40\Microsoft.WindowsAzure.Storage.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Newtonsoft.Json, Version=8.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.8.0.2\lib\net45\Newtonsoft.Json.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Data.Services.Client" />
<Reference Include="System.Net" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Net.Http.WebRequest" />
<Reference Include="System.Runtime.Serialization" />
<Reference Include="System.Spatial, Version=5.7.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\System.Spatial.5.7.0\lib\net40\System.Spatial.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\ConverterLib\ConverterLib.csproj">
<Project>{4d220267-2881-4e52-8551-bceff0dd380c}</Project>
<Name>ConverterLib</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

Просмотреть файл

@ -1,146 +0,0 @@
//----------------------------------------------------------------------------------
// Microsoft Azure Networking
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// This code is licensed under the MIT License (MIT). THIS CODE IS PROVIDED *AS IS*
// WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY IMPLIED
// WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABILITY,
// OR NON-INFRINGEMENT.
//----------------------------------------------------------------------------------
namespace EventsLogConverterSample
{
using Microsoft.WindowsAzure.Storage;
using Microsoft.WindowsAzure.Storage.Blob;
using System;
using System.Collections.Generic;
using System.IO;
using PowerBIConnector;
using PowerBIConnector.NetworkSecurityGroupRuleEvent;
using Newtonsoft.Json;
/// <summary>
/// Sample code to download events log and export it to a .CSV file.
/// </summary>
public class Program
{
/*************************************************************************************
** Below constants needs to be populated by user.
** Arguments can be retrieved from URL to the JSON log stored in the blob storage,
** it should look similar to below URL.
** https://shoebox.blob.core.windows.net/insights-logs-networksecuritygroupevent
** /resourceId=/SUBSCRIPTIONS/D763EE4A-XXX-XXXX-XXXX-876035455EC4/RESOURCEGROUPS/INSIGHTOBONRPFOO
** /PROVIDERS/MICROSOFT.NETWORK/NETWORKSECURITYGROUPS/NSGINSIGHTOBONRPFOO/y=2015/m=08/d=26/h=00/m=00/PT1H.json
*************************************************************************************/
// Connection string to the blob storage.
private const string BlobStorageConnectionString = "<Blob storage connectiong string>";
// Container name in the above URL is : insights-logs-networksecuritygroupevent
private const string EventContainerName = "<Events log Container Name>";
// This is path and name of the exported .CSV file.
private const string EventCSVExportNamePath = "EventsLog.csv";
// Subscription in the above url is : D763EE4A-XXX-XXXX-XXXX-876035455EC4
private const string SubscriptionID = "<Azure Subscription ID>";
// Resource groups : INSIGHTOBONRPFOO
private const string ResrouceGroupsName = "<Resource group name>";
// Resource type name : NSGINSIGHTOBONRPFOO
private const string ResrouceTypeName = "<Resource type name>";
// Provider name : MICROSOFT.NETWORK
private const string ProviderName = "MICROSOFT.NETWORK";
// Beginning date and time of the exporting log segments.
private const string FilterDatetimeStart = "9/1/2015 1:00 AM";
// End date and time of the exporting log segments.
private const string FilterDateTimeEnd = "9/2/2015 10:00 PM";
static void Main(string[] args)
{
Console.WriteLine("Starting events log export.");
DateTime startDateTime = DateTime.Parse(FilterDatetimeStart);
DateTime endDateTime = DateTime.Parse(FilterDateTimeEnd);
GetNetworkSecurityGroupEvents(startDateTime, endDateTime);
Console.WriteLine("Export completed.");
Console.WriteLine("Press any key to exit");
Console.ReadKey();
}
private static void GetNetworkSecurityGroupEvents(DateTime logStart, DateTime logEnd)
{
CloudStorageAccount storageAccount = CloudStorageAccount.Parse(BlobStorageConnectionString);
CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();
Console.WriteLine($"Getting reference to container {EventContainerName}");
CloudBlobContainer container = blobClient.GetContainerReference(EventContainerName);
StorageURL storageUrl = new StorageURL(container.Uri, SubscriptionID, ResrouceGroupsName, ProviderName, ResrouceTypeName, ResourceType.NETWORKSECURITYGROUPS);
List<Log> logs = new List<Log>();
int itemPosition = 0;
for (DateTime logTimeStamp = logStart; logTimeStamp <= logEnd; logTimeStamp = logTimeStamp.AddHours(1))
{
Console.WriteLine(logTimeStamp);
Uri storageblobUrl = storageUrl.GetURL(logTimeStamp);
CloudBlockBlob blockBlob = new CloudBlockBlob(storageblobUrl, storageAccount.Credentials);
MemoryStream memstream = new MemoryStream();
try
{
blockBlob.DownloadToStream(memstream);
memstream.Position = 0;
JsonSerializer serializer = new JsonSerializer();
using (StreamReader sr = new StreamReader(memstream))
using (JsonTextReader jsonTextReader = new JsonTextReader(sr))
{
LogRecords logRecords = serializer.Deserialize<LogRecords>(jsonTextReader);
itemPosition = 0;
foreach (Log logItem in logRecords.records)
{
logs.Add(logItem);
itemPosition++;
}
}
}
catch (Exception ex)
{
Console.WriteLine($"{ex.Message} - {storageblobUrl}");
}
}
using (System.IO.StreamWriter file = new System.IO.StreamWriter(EventCSVExportNamePath))
{
file.WriteLine("time,systemId,resourceId,operationName,properties.vnetResourceGuid,properties.subnetPrefix"
+ ",properties.macAddress,properties.ruleName,properties.direction,properties.priority"
+ ",properties.type,properties.conditions.destinationPortRange,properties.conditions.sourcePortRange"
+ ",properties.conditions.sourceIP,properties.conditions.destinationIP,properties.conditions.protocols");
foreach (Log log in logs)
{
file.WriteLine($"{DateTime.Parse(log.time).ToUniversalTime()}, {log.systemId}, {log.resourceId}, {log.operationName}"
+ $", {log.properties.vnetResourceGuid}, {log.properties.subnetPrefix}, {log.properties.macAddress}"
+ $", {log.properties.ruleName}, {log.properties.direction}, {log.properties.priority}, {log.properties.type}"
+ $", {log.properties.conditions.destinationPortRange}, {log.properties.conditions.sourcePortRange}"
+ $", {log.properties.conditions.sourceIP?.Replace(',', ';')}, {log.properties.conditions.destinationIP?.Replace(',', ';')}"
+ $", {(string.IsNullOrWhiteSpace(log.properties.conditions.protocols) ? "*" : log.properties.conditions.protocols?.Replace(',', ';'))}");
}
}
}
}
}

Просмотреть файл

@ -1,36 +0,0 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("EventsLogConverter")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("EventsLogConverter")]
[assembly: AssemblyCopyright("Copyright © 2013")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("02db5912-44fc-4b98-a1f9-854d6e6441fe")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

Просмотреть файл

@ -1,10 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.Azure.KeyVault.Core" version="1.0.0" targetFramework="net461" />
<package id="Microsoft.Data.Edm" version="5.7.0" targetFramework="net461" />
<package id="Microsoft.Data.OData" version="5.8.4" targetFramework="net461" />
<package id="Microsoft.Data.Services.Client" version="5.7.0" targetFramework="net461" />
<package id="Newtonsoft.Json" version="8.0.2" targetFramework="net461" />
<package id="System.Spatial" version="5.7.0" targetFramework="net461" />
<package id="WindowsAzure.Storage" version="6.2.2-preview" targetFramework="net461" />
</packages>

Просмотреть файл

@ -1,21 +0,0 @@
The MIT License (MIT)
Copyright (c) 2015 Microsoft Corporation
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

Просмотреть файл

@ -1,26 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2"/>
</startup>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Microsoft.Data.Services.Client" publicKeyToken="31bf3856ad364e35" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-5.7.0.0" newVersion="5.7.0.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Data.OData" publicKeyToken="31bf3856ad364e35" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-5.7.0.0" newVersion="5.7.0.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Data.Edm" publicKeyToken="31bf3856ad364e35" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-5.7.0.0" newVersion="5.7.0.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-8.0.0.0" newVersion="8.0.0.0"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>

Просмотреть файл

@ -1,96 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{CE58F3DE-36EA-422A-A524-35B3FFC42C15}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>LoadBalancerAlertLogConverter</RootNamespace>
<AssemblyName>LoadBalancerAlertLogConverter</AssemblyName>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.Azure.KeyVault.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Azure.KeyVault.Core.1.0.0\lib\net40\Microsoft.Azure.KeyVault.Core.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Data.Edm, Version=5.7.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Data.Edm.5.7.0\lib\net40\Microsoft.Data.Edm.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Data.OData, Version=5.7.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Data.OData.5.7.0\lib\net40\Microsoft.Data.OData.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Data.Services.Client, Version=5.7.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Data.Services.Client.5.7.0\lib\net40\Microsoft.Data.Services.Client.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.WindowsAzure.Storage, Version=6.2.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\WindowsAzure.Storage.6.2.2-preview\lib\net40\Microsoft.WindowsAzure.Storage.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Newtonsoft.Json, Version=8.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.8.0.2\lib\net45\Newtonsoft.Json.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Spatial, Version=5.7.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\System.Spatial.5.7.0\lib\net40\System.Spatial.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\ConverterLib\ConverterLib.csproj">
<Project>{4d220267-2881-4e52-8551-bceff0dd380c}</Project>
<Name>ConverterLib</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

Просмотреть файл

@ -1,142 +0,0 @@
//----------------------------------------------------------------------------------
// Microsoft Azure Networking
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// This code is licensed under the MIT License (MIT). THIS CODE IS PROVIDED *AS IS*
// WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY IMPLIED
// WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABILITY,
// OR NON-INFRINGEMENT.
//----------------------------------------------------------------------------------
namespace LoadBalancerAlertLogConverterSample
{
using Microsoft.WindowsAzure.Storage;
using Microsoft.WindowsAzure.Storage.Blob;
using Newtonsoft.Json;
using PowerBIConnector;
using PowerBIConnector.LoadBalancerAlertEvent;
using System;
using System.Collections.Generic;
using System.IO;
/// <summary>
/// Sample code to download health status logs and export it to a .CSV file.
/// </summary>
class Program
{
/*************************************************************************************
** Below constants needs to be populated by user.
** Arguments can be retrieved from URL to the JSON log stored in the blob storage,
** it should look similar to below URL.
** https://shoebox.blob.core.windows.net/insights-logs-loadbalanceralertevent/resourceId=
** /SUBSCRIPTIONS/<subscription id>/RESOURCEGROUPS/SLBDEMO/PROVIDERS/MICROSOFT.NETWORK/LOADBALANCERS/MYLB/y=2016/m=01/d=27/h=04/m=00/PT1H.json
*************************************************************************************/
// Connection string to the blob storage.
private const string BlobStorageConnectionString = "<Blob storage connectiong string>";
// Container name in the above URL is : insights-logs-loadbalancerprobehealthstatus
private const string EventContainerName = "insights-logs-loadbalanceralertevent";
// This is path and name of the exported .CSV file.
private const string EventCSVExportNamePath = "LoadBalancerAlertEvent.csv";
// Subscription in the above url is : D763EE4A-XXX-XXXX-XXXX-876035455EC4
// All alphabets must be in uppercase.
private const string SubscriptionID = "<Azure Subscription ID>";
// Resource groups : SLBDEMO
private const string ResrouceGroupsName = "<Resource group name>";
// Resource type name : MYLB
private const string ResrouceTypeName = "<Resource type name>";
// Provider name : MICROSOFT.NETWORK
private const string ProviderName = "MICROSOFT.NETWORK";
// Beginning date and time of the exporting log segments.
private const string FilterDatetimeStart = "1/1/2016 00:00 AM";
// End date and time of the exporting log segments.
private const string FilterDateTimeEnd = "1/1/2016 03:00 AM";
static void Main(string[] args)
{
Console.WriteLine("Starting load balancer alert log export.");
DateTime startDateTime = DateTime.Parse(FilterDatetimeStart);
DateTime endDateTime = DateTime.Parse(FilterDateTimeEnd);
GetLoadBalancerEvents(startDateTime, endDateTime);
Console.WriteLine("Export completed.");
Console.WriteLine("Press any key to exit");
Console.ReadKey();
}
private static void GetLoadBalancerEvents(DateTime logStart, DateTime logEnd)
{
CloudStorageAccount storageAccount = CloudStorageAccount.Parse(BlobStorageConnectionString);
CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();
Console.WriteLine($"Getting reference to container {EventContainerName}");
CloudBlobContainer container = blobClient.GetContainerReference(EventContainerName);
StorageURL storageUrl = new StorageURL(container.Uri, SubscriptionID, ResrouceGroupsName, ProviderName, ResrouceTypeName, ResourceType.LOADBALANCERS);
List<Log> logs = new List<Log>();
int itemPosition = 0;
// Using the date and time as arguments download all logs from the storage blob.
for (DateTime logTimeStamp = logStart; logTimeStamp <= logEnd; logTimeStamp = logTimeStamp.AddHours(1))
{
Console.WriteLine(logTimeStamp);
Uri storageBlobUrl = storageUrl.GetURL(logTimeStamp);
CloudBlockBlob blockBlob = new CloudBlockBlob(storageBlobUrl, storageAccount.Credentials);
MemoryStream memstream = new MemoryStream();
try
{
blockBlob.DownloadToStream(memstream);
memstream.Position = 0;
JsonSerializer serializer = new JsonSerializer();
using (StreamReader sr = new StreamReader(memstream))
{
using (JsonTextReader jsonTextReader = new JsonTextReader(sr))
{
LogRecords logRecords = serializer.Deserialize<LogRecords>(jsonTextReader);
itemPosition = 0;
foreach (Log logItem in logRecords.records)
{
logs.Add(logItem);
itemPosition++;
}
}
}
}
catch (Exception ex)
{
Console.WriteLine($"{ex.Message} - {storageBlobUrl}");
}
}
using (System.IO.StreamWriter file = new System.IO.StreamWriter(EventCSVExportNamePath))
{
file.WriteLine("time,systemId,category,resourceId,operationName,properties.eventName"
+ ",properties.eventDescription,properties.eventProperties.publicIpAddress");
foreach (Log log in logs)
{
file.WriteLine($"{DateTime.Parse(log.time).ToUniversalTime()}, {log.systemId}, {log.category}, {log.resourceId}, {log.operationName}"
+ $", {log.properties.eventName }, {log.properties.eventDescription}, {log.properties.eventProperties.publicIpAddress}");
}
}
}
}
}

Просмотреть файл

@ -1,36 +0,0 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("LoadBalancerAlertLogConverter")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("LoadBalancerAlertLogConverter")]
[assembly: AssemblyCopyright("Copyright © 2016")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("ce58f3de-36ea-422a-a524-35b3ffc42c15")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

Просмотреть файл

@ -1,10 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.Azure.KeyVault.Core" version="1.0.0" targetFramework="net461" />
<package id="Microsoft.Data.Edm" version="5.7.0" targetFramework="net461" />
<package id="Microsoft.Data.OData" version="5.8.4" targetFramework="net461" />
<package id="Microsoft.Data.Services.Client" version="5.7.0" targetFramework="net461" />
<package id="Newtonsoft.Json" version="8.0.2" targetFramework="net461" />
<package id="System.Spatial" version="5.7.0" targetFramework="net461" />
<package id="WindowsAzure.Storage" version="6.2.2-preview" targetFramework="net461" />
</packages>

Просмотреть файл

@ -1,26 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2"/>
</startup>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Microsoft.Data.Edm" publicKeyToken="31bf3856ad364e35" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-5.7.0.0" newVersion="5.7.0.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Data.Services.Client" publicKeyToken="31bf3856ad364e35" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-5.7.0.0" newVersion="5.7.0.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Data.OData" publicKeyToken="31bf3856ad364e35" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-5.7.0.0" newVersion="5.7.0.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-8.0.0.0" newVersion="8.0.0.0"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>

Просмотреть файл

@ -1,102 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{E233F759-D0FF-4A25-BEFD-207CF0BF8585}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>LoadBalancerHealthProbeLogConverter</RootNamespace>
<AssemblyName>LoadBalancerHealthProbeLogConverter</AssemblyName>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.Azure.KeyVault.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Azure.KeyVault.Core.1.0.0\lib\net40\Microsoft.Azure.KeyVault.Core.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Data.Edm, Version=5.7.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Data.Edm.5.7.0\lib\net40\Microsoft.Data.Edm.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Data.OData, Version=5.7.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Data.OData.5.7.0\lib\net40\Microsoft.Data.OData.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Data.Services.Client, Version=5.7.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Data.Services.Client.5.7.0\lib\net40\Microsoft.Data.Services.Client.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.WindowsAzure.Configuration, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.WindowsAzure.ConfigurationManager.3.2.0\lib\net40\Microsoft.WindowsAzure.Configuration.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.WindowsAzure.Storage, Version=6.2.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\WindowsAzure.Storage.6.2.2-preview\lib\net40\Microsoft.WindowsAzure.Storage.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Newtonsoft.Json, Version=8.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.8.0.2\lib\net45\Newtonsoft.Json.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Spatial, Version=5.7.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\System.Spatial.5.7.0\lib\net40\System.Spatial.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
<None Include="packages.config">
<SubType>Designer</SubType>
</None>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\ConverterLib\ConverterLib.csproj">
<Project>{4d220267-2881-4e52-8551-bceff0dd380c}</Project>
<Name>ConverterLib</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

Просмотреть файл

@ -1,143 +0,0 @@
//----------------------------------------------------------------------------------
// Microsoft Azure Networking
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// This code is licensed under the MIT License (MIT). THIS CODE IS PROVIDED *AS IS*
// WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY IMPLIED
// WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABILITY,
// OR NON-INFRINGEMENT.
//----------------------------------------------------------------------------------
namespace LoadBalancerHealthProbeLogConverterSample
{
using Microsoft.WindowsAzure.Storage;
using Microsoft.WindowsAzure.Storage.Blob;
using Newtonsoft.Json;
using PowerBIConnector;
using PowerBIConnector.LoadBalancLoadBalancerProbeHealthStatuserEvent;
using System;
using System.Collections.Generic;
using System.IO;
/// <summary>
/// Sample code to download health status logs and export it to a .CSV file.
/// </summary>
class Program
{
/*************************************************************************************
** Below constants needs to be populated by user.
** Arguments can be retrieved from URL to the JSON log stored in the blob storage,
** it should look similar to below URL.
** https://shoebox.blob.core.windows.net/insights-logs-loadbalancerprobehealthstatus/resourceId=
** /SUBSCRIPTIONS/<subscription id>/RESOURCEGROUPS/SLBDEMO/PROVIDERS/MICROSOFT.NETWORK/LOADBALANCERS/MYLB/y=2016/m=01/d=27/h=04/m=00/PT1H.json
*************************************************************************************/
// Connection string to the blob storage.
private const string BlobStorageConnectionString = "<Blob storage connectiong string>";
// Container name in the above URL is : insights-logs-loadbalancerprobehealthstatus
private const string EventContainerName = "insights-logs-loadbalancerprobehealthstatus";
// This is path and name of the exported .CSV file.
private const string EventCSVExportNamePath = "LoadBalancerHealthStatusLog.csv";
// Subscription in the above url is : D763EE4A-XXX-XXXX-XXXX-876035455EC4
// All alphabets must be in uppercase.
private const string SubscriptionID = "<Azure Subscription ID>";
// Resource groups : SLBDEMO
private const string ResrouceGroupsName = "<Resource group name>";
// Resource type name : MYLB
private const string ResrouceTypeName = "<Resource type name>";
// Provider name : MICROSOFT.NETWORK
private const string ProviderName = "MICROSOFT.NETWORK";
// Beginning date and time of the exporting log segments.
private const string FilterDatetimeStart = "1/1/2016 00:00 AM";
// End date and time of the exporting log segments.
private const string FilterDateTimeEnd = "1/1/2016 03:00 AM";
static void Main(string[] args)
{
Console.WriteLine("Starting load balancer health status log export.");
DateTime startDateTime = DateTime.Parse(FilterDatetimeStart);
DateTime endDateTime = DateTime.Parse(FilterDateTimeEnd);
GetLoadBalancerEvents(startDateTime, endDateTime);
Console.WriteLine("Export completed.");
Console.WriteLine("Press any key to exit");
Console.ReadKey();
}
private static void GetLoadBalancerEvents(DateTime logStart, DateTime logEnd)
{
CloudStorageAccount storageAccount = CloudStorageAccount.Parse(BlobStorageConnectionString);
CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();
Console.WriteLine($"Getting reference to container {EventContainerName}");
CloudBlobContainer container = blobClient.GetContainerReference(EventContainerName);
StorageURL storageUrl = new StorageURL(container.Uri, SubscriptionID, ResrouceGroupsName, ProviderName, ResrouceTypeName, ResourceType.LOADBALANCERS);
List<Log> logs = new List<Log>();
int itemPosition = 0;
// Using the date and time as arguments download all logs from the storage blob.
for (DateTime logTimeStamp = logStart; logTimeStamp <= logEnd; logTimeStamp = logTimeStamp.AddHours(1))
{
Console.WriteLine(logTimeStamp);
Uri storageBlobUrl = storageUrl.GetURL(logTimeStamp);
CloudBlockBlob blockBlob = new CloudBlockBlob(storageBlobUrl, storageAccount.Credentials);
MemoryStream memstream = new MemoryStream();
try
{
blockBlob.DownloadToStream(memstream);
memstream.Position = 0;
JsonSerializer serializer = new JsonSerializer();
using (StreamReader sr = new StreamReader(memstream))
{
using (JsonTextReader jsonTextReader = new JsonTextReader(sr))
{
LogRecords logRecords = serializer.Deserialize<LogRecords>(jsonTextReader);
itemPosition = 0;
foreach (Log logItem in logRecords.records)
{
logs.Add(logItem);
itemPosition++;
}
}
}
}
catch (Exception ex)
{
Console.WriteLine($"{ex.Message} - {storageBlobUrl}");
}
}
using (System.IO.StreamWriter file = new System.IO.StreamWriter(EventCSVExportNamePath))
{
file.WriteLine("time,systemId,category,resourceId,operationName,properties.publicIpAddress"
+ ",properties.port,properties.totalDipCount,properties.dipDownCount,properties.healthPercentage");
foreach (Log log in logs)
{
file.WriteLine($"{DateTime.Parse(log.time).ToUniversalTime()}, {log.systemId}, {log.category}, {log.resourceId}, {log.operationName}"
+ $", {log.properties.publicIpAddress }, {log.properties.port}, {log.properties.totalDipCount}"
+ $", {log.properties.dipDownCount}, {log.properties.healthPercentage}");
}
}
}
}
}

Просмотреть файл

@ -1,36 +0,0 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("LoadBalancerHealthProbeLogConverter")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("LoadBalancerHealthProbeLogConverter")]
[assembly: AssemblyCopyright("Copyright © 2016")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("e233f759-d0ff-4a25-befd-207cf0bf8585")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

Просмотреть файл

@ -1,11 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.Azure.KeyVault.Core" version="1.0.0" targetFramework="net452" />
<package id="Microsoft.Data.Edm" version="5.7.0" targetFramework="net461" />
<package id="Microsoft.Data.OData" version="5.8.4" targetFramework="net461" />
<package id="Microsoft.Data.Services.Client" version="5.7.0" targetFramework="net461" />
<package id="Microsoft.WindowsAzure.ConfigurationManager" version="3.2.0" targetFramework="net461" />
<package id="Newtonsoft.Json" version="8.0.2" targetFramework="net461" />
<package id="System.Spatial" version="5.7.0" targetFramework="net461" />
<package id="WindowsAzure.Storage" version="6.2.2-preview" targetFramework="net461" />
</packages>

Просмотреть файл

@ -1,52 +0,0 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.24720.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EventsLogConverter", "EventsLogConverter\EventsLogConverter.csproj", "{85C81265-CA86-4C3D-93B9-7AC54FCD20AF}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CountersLogConverter", "CountersLogConverter\CountersLogConverter.csproj", "{3AB3C315-9911-4013-955F-CF0162880532}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OperationsLogConverter", "OperationsLogConverter\OperationsLogConverter.csproj", "{47BC0A41-BE8B-45FD-9993-67ADDFDA4460}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConverterLib", "ConverterLib\ConverterLib.csproj", "{4D220267-2881-4E52-8551-BCEFF0DD380C}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LoadBalancerHealthProbeLogConverter", "LoadBalancerHealthProbeLogConverter\LoadBalancerHealthProbeLogConverter.csproj", "{E233F759-D0FF-4A25-BEFD-207CF0BF8585}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LoadBalancerAlertLogConverter", "LoadBalancerAlertLogConverter\LoadBalancerAlertLogConverter.csproj", "{CE58F3DE-36EA-422A-A524-35B3FFC42C15}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{85C81265-CA86-4C3D-93B9-7AC54FCD20AF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{85C81265-CA86-4C3D-93B9-7AC54FCD20AF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{85C81265-CA86-4C3D-93B9-7AC54FCD20AF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{85C81265-CA86-4C3D-93B9-7AC54FCD20AF}.Release|Any CPU.Build.0 = Release|Any CPU
{3AB3C315-9911-4013-955F-CF0162880532}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3AB3C315-9911-4013-955F-CF0162880532}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3AB3C315-9911-4013-955F-CF0162880532}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3AB3C315-9911-4013-955F-CF0162880532}.Release|Any CPU.Build.0 = Release|Any CPU
{47BC0A41-BE8B-45FD-9993-67ADDFDA4460}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{47BC0A41-BE8B-45FD-9993-67ADDFDA4460}.Debug|Any CPU.Build.0 = Debug|Any CPU
{47BC0A41-BE8B-45FD-9993-67ADDFDA4460}.Release|Any CPU.ActiveCfg = Release|Any CPU
{47BC0A41-BE8B-45FD-9993-67ADDFDA4460}.Release|Any CPU.Build.0 = Release|Any CPU
{4D220267-2881-4E52-8551-BCEFF0DD380C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4D220267-2881-4E52-8551-BCEFF0DD380C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4D220267-2881-4E52-8551-BCEFF0DD380C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4D220267-2881-4E52-8551-BCEFF0DD380C}.Release|Any CPU.Build.0 = Release|Any CPU
{E233F759-D0FF-4A25-BEFD-207CF0BF8585}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E233F759-D0FF-4A25-BEFD-207CF0BF8585}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E233F759-D0FF-4A25-BEFD-207CF0BF8585}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E233F759-D0FF-4A25-BEFD-207CF0BF8585}.Release|Any CPU.Build.0 = Release|Any CPU
{CE58F3DE-36EA-422A-A524-35B3FFC42C15}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{CE58F3DE-36EA-422A-A524-35B3FFC42C15}.Debug|Any CPU.Build.0 = Debug|Any CPU
{CE58F3DE-36EA-422A-A524-35B3FFC42C15}.Release|Any CPU.ActiveCfg = Release|Any CPU
{CE58F3DE-36EA-422A-A524-35B3FFC42C15}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

Просмотреть файл

@ -1,27 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-8.0.0.0" newVersion="8.0.0.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.WindowsAzure.Storage" publicKeyToken="31bf3856ad364e35" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-6.2.2.0" newVersion="6.2.2.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Data.Edm" publicKeyToken="31bf3856ad364e35" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-5.7.0.0" newVersion="5.7.0.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Data.Services.Client" publicKeyToken="31bf3856ad364e35" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-5.7.0.0" newVersion="5.7.0.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Data.OData" publicKeyToken="31bf3856ad364e35" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-5.7.0.0" newVersion="5.7.0.0"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2"/></startup></configuration>

Просмотреть файл

@ -1,175 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{47BC0A41-BE8B-45FD-9993-67ADDFDA4460}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>OperationsLogConverter</RootNamespace>
<AssemblyName>OperationsLogConverter</AssemblyName>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
<RestorePackages>true</RestorePackages>
<TargetFrameworkProfile />
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Hyak.Common, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Hyak.Common.1.1.0\lib\net45\Hyak.Common.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Azure.Common, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Azure.Common.2.1.0\lib\net45\Microsoft.Azure.Common.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Azure.Common.NetFramework, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Azure.Common.2.1.0\lib\net45\Microsoft.Azure.Common.NetFramework.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Azure.Insights, Version=0.9.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Azure.Insights.0.10.0-preview\lib\net45\Microsoft.Azure.Insights.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Azure.KeyVault.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Azure.KeyVault.Core.1.0.0\lib\net40\Microsoft.Azure.KeyVault.Core.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Azure.ResourceManager, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Azure.Management.Resources.2.18.7-preview\lib\net40\Microsoft.Azure.ResourceManager.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Data.Edm, Version=5.7.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Data.Edm.5.7.0\lib\net40\Microsoft.Data.Edm.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Data.OData, Version=5.7.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Data.OData.5.7.0\lib\net40\Microsoft.Data.OData.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Data.Services.Client, Version=5.7.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Data.Services.Client.5.7.0\lib\net40\Microsoft.Data.Services.Client.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.IdentityModel.Clients.ActiveDirectory, Version=2.19.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.IdentityModel.Clients.ActiveDirectory.2.19.208020213\lib\net45\Microsoft.IdentityModel.Clients.ActiveDirectory.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.IdentityModel.Clients.ActiveDirectory.WindowsForms, Version=2.19.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.IdentityModel.Clients.ActiveDirectory.2.19.208020213\lib\net45\Microsoft.IdentityModel.Clients.ActiveDirectory.WindowsForms.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Rest.ClientRuntime, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Rest.ClientRuntime.1.8.2\lib\net45\Microsoft.Rest.ClientRuntime.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Rest.ClientRuntime.Azure, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Rest.ClientRuntime.Azure.2.5.4\lib\net45\Microsoft.Rest.ClientRuntime.Azure.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Threading.Tasks, Version=1.0.12.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Threading.Tasks.Extensions, Version=1.0.12.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.Extensions.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Threading.Tasks.Extensions.Desktop, Version=1.0.168.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.Extensions.Desktop.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.WindowsAzure.Configuration, Version=1.8.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>$(SolutionDir)\packages\Microsoft.WindowsAzure.ConfigurationManager.1.8.0.0\lib\net35-full\Microsoft.WindowsAzure.Configuration.dll</HintPath>
</Reference>
<Reference Include="Microsoft.WindowsAzure.Storage, Version=6.2.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\WindowsAzure.Storage.6.2.2-preview\lib\net40\Microsoft.WindowsAzure.Storage.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Newtonsoft.Json, Version=8.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.8.0.2\lib\net45\Newtonsoft.Json.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Data.Services.Client" />
<Reference Include="System.Net" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Net.Http.Extensions, Version=2.2.29.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Net.Http.2.2.29\lib\net45\System.Net.Http.Extensions.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System.Net.Http.Primitives, Version=4.2.29.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Net.Http.2.2.29\lib\net45\System.Net.Http.Primitives.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System.Net.Http.WebRequest" />
<Reference Include="System.Runtime.Serialization" />
<Reference Include="System.Spatial, Version=5.7.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\System.Spatial.5.7.0\lib\net40\System.Spatial.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config">
<SubType>Designer</SubType>
</None>
<None Include="packages.config">
<SubType>Designer</SubType>
</None>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\ConverterLib\ConverterLib.csproj">
<Project>{4d220267-2881-4e52-8551-bceff0dd380c}</Project>
<Name>ConverterLib</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
<Import Project="..\packages\Microsoft.Bcl.Build.1.0.21\build\Microsoft.Bcl.Build.targets" Condition="Exists('..\packages\Microsoft.Bcl.Build.1.0.21\build\Microsoft.Bcl.Build.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\Microsoft.Bcl.Build.1.0.21\build\Microsoft.Bcl.Build.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Bcl.Build.1.0.21\build\Microsoft.Bcl.Build.targets'))" />
</Target>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

Просмотреть файл

@ -1,236 +0,0 @@
//----------------------------------------------------------------------------------
// Microsoft Azure Networking
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// This code is licensed under the MIT License (MIT). THIS CODE IS PROVIDED *AS IS*
// WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY IMPLIED
// WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABILITY,
// OR NON-INFRINGEMENT.
//----------------------------------------------------------------------------------
using System.Linq;
namespace OperationsLogConverterSample
{
using Microsoft.Azure.Common.OData;
using Microsoft.Azure;
using Microsoft.Azure.Insights;
using Microsoft.Azure.Insights.Models;
using System;
using System.Collections.Generic;
using System.IO;
using Microsoft.IdentityModel.Clients.ActiveDirectory;
using Microsoft.Azure.Management.Resources;
using Microsoft.Azure.Management.Resources.Models;
using System.Text;
public class Program
{
/*************************************************************************************
** Read this to configure your subscriptionid, tenantid, client id and uri
** 1. SubscriptionID:
** a. https://manage.windowsazure.com > Settings > SUBSCRIPTION ID
** OR
** b. https://portal.azure.com > Browse > Subscriptions > SUBSCRIPTION ID
** 2. For TenantID/ClientID/URI follow the "Set up authentication using the Management Portal" step in Authenticating Azure Resource Manager requests
** a. TenantID - found in Step 3.3
** b. ClientID(aka Application ID) - found in Step 3.3
** c. URI(aka Redirect URI) - found in Step 1.4
*************************************************************************************/
private const string SubscriptionID = "<Azure Subscription ID>";
private const string TenantID = "<Azure Active Directory Tenant ID>";
private const string ClientID = "<Client ID or Application ID>";
private const string CSVExportNamePath = "OpsLog.csv";
private static readonly Uri RedirectURI = new Uri("http://www.microsoft.com");
private const double days = -10; //max = -90 (90 days of logs is stored by audit logs)
static void Main(string[] args)
{
Console.WriteLine("Starting operations log export.");
string token = GetAuthorizationHeader();
TokenCloudCredentials credentials = new TokenCloudCredentials(SubscriptionID, token);
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));
EventDataListResponse response = client.EventOperations.ListEvents(filterString, selectedProperties: null);
List<EventData> logList = new List<EventData>(response.EventDataCollection.Value);
while (!string.IsNullOrEmpty(response.EventDataCollection.NextLink))
{
Console.WriteLine($"Retrieving page {response.EventDataCollection.NextLink}");
response = client.EventOperations.ListEventsNext(response.EventDataCollection.NextLink);
logList.AddRange(response.EventDataCollection.Value);
}
ResourceManagementClient resClient = new ResourceManagementClient(credentials);
Console.WriteLine($"Page retrieval completed, preparing to write to a file {CSVExportNamePath}.");
ExportOpsLogToCSV(logList, resClient);
Console.WriteLine("Export completed.");
Console.WriteLine("Press any key to exit");
Console.ReadKey();
}
private static string GetAuthorizationHeader()
{
AuthenticationContext context = new AuthenticationContext($"https://login.windows.net/{TenantID}");
AuthenticationResult result = context.AcquireToken("https://management.core.windows.net/", ClientID, RedirectURI);
if (result == null)
{
throw new InvalidOperationException("Failed to obtain the token.");
}
return result.AccessToken;
}
private static void ExportOpsLogToCSV(IList<EventData> eventDataList, ResourceManagementClient resclient)
{
using (StreamWriter file = File.AppendText(CSVExportNamePath))
{
file.WriteLine("SubscriptionId,EventTimeStamp,EventDate,EventDataId,CorrelationId,EventName,Level"
+ ",ResourceGroupName,ResourceProviderName,ResourceId,ResourceName,ResourceLocation"
+ ",Status,Caller,OperationId,OperationName,OperationRP,OperationResType,OperationType"
+ ",Description,Title,Service,Region,Transcript,IncidentId,IncidentType");
foreach(EventData eventEntry in eventDataList)
{
Tuple<string, string> resourceNameUriPair = GetAllResourceNameAndLocation(eventEntry, eventEntry.ResourceGroupName, eventEntry.ResourceId, resclient);
Tuple<string, string, string> operationNameTrio = ParseOperationName(eventEntry);
Tuple<string, string, string, string, string, string> resourceProviderSextet = GetResourceProviderName(eventEntry);
DateTime convertedTimeStamp = eventEntry.EventTimestamp.ToUniversalTime();
// SubscriptionId | EventTimeStamp | EventDate | EventDataId
file.WriteLine($"{eventEntry.SubscriptionId},{convertedTimeStamp},{convertedTimeStamp.Date},{eventEntry.EventDataId?.Replace(',', ';')}"
// | CorrelationId | EventName
+ $",{eventEntry.CorrelationId?.Replace(',', ';')},{eventEntry.EventName.Value?.Replace(',', ';')}"
// | Level | ResourceGroupName | ResourceProviderName
+ $",{eventEntry.Level},{eventEntry.ResourceGroupName?.Replace(',', ';')},{eventEntry.ResourceProviderName.Value?.Replace(',', ';')}"
// | ResourceId | ResourceName | ResourceLocation | Status
+ $",{eventEntry.ResourceId?.Replace(',', ';')},{resourceNameUriPair.Item1},{resourceNameUriPair.Item2},{eventEntry.Status.Value?.Replace(',', ';')}"
// | Caller | OperationId | OperationName
+ $",{eventEntry.Caller?.Replace(',', ';')},{eventEntry.OperationId},{eventEntry.OperationName.Value?.Replace(',', ';')}"
// | OperationRP | OperationResType | OperationType | Description
+ $",{operationNameTrio.Item1},{operationNameTrio.Item2},{operationNameTrio.Item3},{eventEntry.Description?.Replace(',', ';').Replace(System.Environment.NewLine, string.Empty)}"
// | Title | Service | Region | Transcript
+ $",{resourceProviderSextet.Item1},{resourceProviderSextet.Item2},{resourceProviderSextet.Item3},{resourceProviderSextet.Item4}"
// | IncidentId | IncidentType
+ $",{resourceProviderSextet.Item5},{resourceProviderSextet.Item6}");
}
}
}
private static Tuple<string, string, string, string, string, string> GetResourceProviderName(EventData eventEntry)
{
Tuple<string, string, string, string, string, string> resultSet =
new Tuple<string, string, string, string, string, string>(string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty);
if (eventEntry.ResourceProviderName == null)
{
return resultSet;
}
if (eventEntry.ResourceProviderName.Value == "Azure.Health")
{
string titleProp = eventEntry.Properties.ContainsKey("Title") ? eventEntry.Properties["Title"]?.Replace(',', ';').Replace(Environment.NewLine, string.Empty) : string.Empty;
string serviceProp = eventEntry.Properties.ContainsKey("Service") ? eventEntry.Properties["Service"]?.Replace(',', ';').Replace(Environment.NewLine, string.Empty) : string.Empty;
string regionProp = eventEntry.Properties.ContainsKey("Region") ? eventEntry.Properties["Region"]?.Replace(',', ';').Replace(Environment.NewLine, string.Empty) : string.Empty;
string tranCommProp = eventEntry.Properties.ContainsKey("Transcript Of Communication") ? eventEntry.Properties["Transcript Of Communication"]?.Replace(',', ';').Replace(Environment.NewLine, string.Empty) : string.Empty;
string incidentIDProp = eventEntry.Properties.ContainsKey("IncidentId") ? eventEntry.Properties["IncidentId"]?.Replace(',', ';').Replace(Environment.NewLine, string.Empty) : string.Empty;
string incidentTypeProp = eventEntry.Properties.ContainsKey("IncidentType") ? eventEntry.Properties["IncidentType"]?.Replace(',', ';').Replace(Environment.NewLine, string.Empty) : string.Empty;
resultSet = new Tuple<string, string, string, string, string, string>(titleProp, serviceProp, regionProp, tranCommProp, incidentIDProp, incidentTypeProp);
}
return resultSet;
}
private static Tuple<string, string> GetAllResourceNameAndLocation(EventData eventEntry, string resourceGroupName, string resourceUri, ResourceManagementClient resclient)
{
Tuple<string, string> resultSet = new Tuple<string, string>(string.Empty, string.Empty);
if (!string.IsNullOrWhiteSpace(resourceGroupName) && !string.IsNullOrWhiteSpace(resourceUri))
{
try
{
ResourceListParameters reslist = new ResourceListParameters();
reslist.ResourceGroupName = eventEntry.ResourceGroupName;
ResourceListResult resresult = resclient.Resources.List(reslist);
foreach (GenericResourceExtended resource in resresult.Resources)
{
if (resource.Id == eventEntry.ResourceId)
{
resultSet = new Tuple<string, string>(resource.Name, resource.Location);
break;
}
}
}
catch
{
return resultSet;
}
}
return resultSet;
}
private static Tuple<string, string, string> ParseOperationName(EventData eventEntry)
{
Tuple<string, string, string> resultSet = new Tuple<string, string, string>(string.Empty, string.Empty, string.Empty);
if (eventEntry.ResourceProviderName == null)
{
return resultSet;
}
if (string.IsNullOrWhiteSpace(eventEntry.ResourceProviderName.Value))
{
if (eventEntry.ResourceProviderName.Value != "Azure.Health")
{
if (eventEntry.OperationName.Value.Contains("/"))
{
string[] entry = eventEntry.OperationName.Value.ToLower().Replace("/action", "").Split('/');
string operationResProvider = entry[0].Replace("microsoft.", "");
string operationResType = entry[1];
StringBuilder operationTypeName = new StringBuilder();
if (entry.Length > 2)
{
for(int i = 2; i < entry.Length; i++)
{
operationTypeName.Append(entry[i]);
if (i < entry.Length)
{
operationTypeName.Append("/");
}
}
}
resultSet = new Tuple<string, string, string>(operationResProvider, operationResType, operationTypeName.ToString());
}
}
}
return resultSet;
}
}
}

Просмотреть файл

@ -1,36 +0,0 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("OperationsLogConverter")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("OperationsLogConverter")]
[assembly: AssemblyCopyright("Copyright © 2013")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("02db5912-44fc-4b98-a1f9-854d6e6441fe")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

Просмотреть файл

@ -1,23 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Hyak.Common" version="1.1.0" targetFramework="net46" />
<package id="Microsoft.Azure.Common" version="2.1.0" targetFramework="net45" />
<package id="Microsoft.Azure.Common.Dependencies" version="1.0.0" targetFramework="net45" />
<package id="Microsoft.Azure.Insights" version="0.10.0-preview" targetFramework="net46" />
<package id="Microsoft.Azure.KeyVault.Core" version="1.0.0" targetFramework="net46" />
<package id="Microsoft.Azure.Management.Resources" version="2.18.7-preview" targetFramework="net46" />
<package id="Microsoft.Bcl" version="1.1.10" targetFramework="net46" />
<package id="Microsoft.Bcl.Async" version="1.0.168" targetFramework="net45" />
<package id="Microsoft.Bcl.Build" version="1.0.21" targetFramework="net46" />
<package id="Microsoft.Data.Edm" version="5.7.0" targetFramework="net46" />
<package id="Microsoft.Data.OData" version="5.8.4" targetFramework="net46" />
<package id="Microsoft.Data.Services.Client" version="5.7.0" targetFramework="net46" />
<package id="Microsoft.IdentityModel.Clients.ActiveDirectory" version="2.19.208020213" targetFramework="net46" />
<package id="Microsoft.Net.Http" version="2.2.29" targetFramework="net46" />
<package id="Microsoft.Rest.ClientRuntime" version="1.8.2" targetFramework="net46" />
<package id="Microsoft.Rest.ClientRuntime.Azure" version="2.5.4" targetFramework="net46" />
<package id="Microsoft.WindowsAzure.ConfigurationManager" version="1.8.0.0" targetFramework="net45" />
<package id="Newtonsoft.Json" version="8.0.2" targetFramework="net46" />
<package id="System.Spatial" version="5.7.0" targetFramework="net46" />
<package id="WindowsAzure.Storage" version="6.2.2-preview" targetFramework="net46" />
</packages>

Просмотреть файл

@ -1,219 +0,0 @@
# Azure Networking Log Converter
Code for downloading operational network logs and converting them to .CSV files. Files can then be uploaded to Power BI for analysis.
## Running this sample
### Prerequisites:
* Visual Studio 2015
* .NET Framework 4.6
* Microsoft Azure SDK - [Latest](https://azure.microsoft.com/en-us/downloads/)
* Cloud Explorer for Visual Studio 2015 - [Visual Studio Extension](https://visualstudiogallery.msdn.microsoft.com/84e83a7c-9606-4f9f-83dd-0f6182f13add) (recommended)
## Solution Contents
The solution contains 5 executable console app projects CountersLogConverter, EventsLogConverter, OperationsLogConverter, LoadBalancerAlertLogConverter and LoadBalancerHealthProbeLogConverter.
#####1. CountersLogConverter
In order to use this code, logging must be turned on via SDK or Ibiza portal (soon to be released)
and familiarity with Azure Resource Manager is required.
The counters logs are stored in the Azure Storage Container as JSON blobs
```
{
"time": "2015-09-11T23:14:22.6940000Z",
"systemId": "e22a0996-e5a7-XXXX-XXXX-4357a6e8f0c5",
"category": "NetworkSecurityGroupRuleCounter",
"resourceId": "/SUBSCRIPTIONS/D763EE4A-9131-XXXX-XXXX-876035455EC4/RESOURCEGROUPS/INSIGHTOBONRPFOO/PROVIDERS/MICROSOFT.NETWORK/NETWORKSECURITYGROUPS/NSGINSIGHTOBONRPFOO",
"operationName": "NetworkSecurityGroupCounters",
"properties": {
"vnetResourceGuid":"{DD0074B1-4CB3-XXXX-XXXX-8719DFBA3568}",
"subnetPrefix":"10.0.0.0/24",
"macAddress":"001517D9C43C",
"ruleName":"DenyAllOutBound",
"direction":"Out",
"type":"block",
"matchedConnections":0
}
}
```
Converted .CSV file of counter log has following columns
1. *time*
2. *systemId*
3. *resourceId*
4. *operationName*
5. *properties.vnetResourceGuid*
6. *properties.subnetPrefix*
7. *properties.macAddress*
8. *properties.ruleName*
9. *properties.direction*
10. *properties.type*
11. *properties.matchedConnections*
---
#####2. EventsLogConverter
In order to use this code, logging must be turned on.
Familiarity with Azure Resource Manager is required.
The events logs are stored in the Azure Storage Container as JSON blobs
```
{
"time": "2015-09-11T23:05:22.6860000Z",
"systemId": "e22a0996-e5a7-XXXX-XXXX-4357a6e8f0c5",
"category": "NetworkSecurityGroupEvent",
"resourceId": "/SUBSCRIPTIONS/D763EE4A-9131-455F-8C5E-876035455EC4/RESOURCEGROUPS/INSIGHTOBONRPFOO/PROVIDERS/MICROSOFT.NETWORK/NETWORKSECURITYGROUPS/NSGINSIGHTOBONRPFOO",
"operationName": "NetworkSecurityGroupEvents",
"properties": {
"vnetResourceGuid":"{DD0074B1-4CB3-XXXX-XXXX-8719DFBA3568}",
"subnetPrefix":"10.0.0.0/24",
"macAddress":"001517D9C43C",
"ruleName":"AllowVnetOutBound",
"direction":"Out",
"priority":65000,
"type":"allow",
"conditions":{
"destinationPortRange":"0-65535",
"sourcePortRange":"0-65535",
"destinationIP":"10.0.0.0/8,172.16.0.0/12,169.254.0.0/16,192.168.0.0/16,168.63.129.16/32",
"sourceIP":"10.0.0.0/8,172.16.0.0/12,169.254.0.0/16,192.168.0.0/16,168.63.129.16/32"
}
}
}
```
Converted .CSV file of events log has following columns
1. *time*
2. *systemId*
3. *resourceId*
4. *operationName*
5. *properties.vnetResourceGuid*
6. *properties.subnetPrefix*
7. *properties.macAddress*
8. *properties.ruleName*
9. *properties.direction*
10. *properties.priority*
11. *properties.type*
12. *properties.conditions.destinationPortRange*
13. *properties.conditions.sourcePortRange*
14. *properties.conditions.sourceIP*
15. *properties.conditions.destinationIP*
16. *properties.conditions.protocols*
---
#####3. OperationsLogConverter
This app needs to be authorized to access Azure AD management API.
Fore more information on Azure AD authorization go to: https://msdn.microsoft.com/en-us/library/azure/dn790557.aspx
Operations logs are retrieved through the Azure Insight API. For available properties look at member of [Microsoft.Azure.Insight.Models.EventData class definition](https://msdn.microsoft.com/en-us/library/azure/microsoft.azure.insights.models.eventdata.aspx).
Converted .CSV file of operations log has following columns.
1. *SubscriptionId*
2. *EventTimeStamp*
3. *EventDate*
4. *EventDataId*
5. *CorrelationId*
6. *EventName*
7. *Level*
8. *ResourceGroupName*
9. *ResourceProviderName*
10. *ResourceId*
11. *ResourceName*
12. *ResourceLocation*
13. *Status*
14. *Caller*
15. *OperationId*
16. *OperationName*
17. *OperationRP*
18. *OperationResType*
19. *OperationType*
20. *Description*
21. *Title*
22. *Service*
23. *Region*
24. *Transcript*
25. *IncidentId*
26. *IncidentType*
---
#####4. LoadBalancerAlertLogConverter
In order to use this code, logging must be turned on, for how-to: https://github.com/Azure/azure-content/blob/master/articles/load-balancer/load-balancer-monitor-log.md
The alert event logs are stored in the Azure Storage Container as JSON blobs
```
{
"time": "2016-01-26T10:37:46.6024215Z",
"systemId": "32077926-b9c4-42fb-94c1-762e528b5b27",
"category": "LoadBalancerAlertEvent",
"resourceId": "/SUBSCRIPTIONS/XXXXXXXXXXXXXXXXX-XXXX-XXXX-XXXXXXXXX/RESOURCEGROUPS/RG7/PROVIDERS/MICROSOFT.NETWORK/LOADBALANCERS/WWEBLB",
"operationName": "LoadBalancerProbeHealthStatus",
"properties": {
"eventName": "Resource Limits Hit",
"eventDescription": "Ports exhausted",
"eventProperties": {
"public ip address": "40.117.227.32"
}
}
}
```
Converted .CSV file of alert event log has following columns
1. *time*
2. *systemId*
3. *category*
3. *resourceId*
4. *operationName*
5. *properties.eventName*
6. *properties.eventDescription*
7. *properties.eventProperties.publicIpAddress*
---
#####5. LoadBalancerHealthProbeLogConverter
In order to use this code, logging must be turned on, for how-to: https://github.com/Azure/azure-content/blob/master/articles/load-balancer/load-balancer-monitor-log.md
The healt status event logs are stored in the Azure Storage Container as JSON blobs
```
{
"time": "2016-01-26T10:37:46.6024215Z",
"systemId": "32077926-b9c4-42fb-94c1-762e528b5b27",
"category": "LoadBalancerProbeHealthStatus",
"resourceId": "/SUBSCRIPTIONS/XXXXXXXXXXXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXX/RESOURCEGROUPS/RG7/PROVIDERS/MICROSOFT.NETWORK/LOADBALANCERS/WWEBLB",
"operationName": "LoadBalancerProbeHealthStatus",
"properties": {
"publicIpAddress": "40.83.190.158",
"port": "81",
"totalDipCount": 2,
"dipDownCount": 0,
"healthPercentage": 100.000000
}
}
```
Converted .CSV file of healt status log has following columns
1. *time*
2. *systemId*
3. *category*
3. *resourceId*
4. *operationName*
5. *properties.publicIpAddress*
6. *properties.port*
7. *properties.totalDipCount*
8. *properties.dipDownCount*
9. *properties.healthPercentage*
---

Просмотреть файл

@ -10,12 +10,8 @@ The Azure Connectivity Toolkit ([AzureCT][AzureCT]) is a PowerShell module and c
- A network availability test (Get-AzureNetworkAvailability) that runs pings and traceroutes over an extended period of time to show end to end availability and hop latency.
- A bandwidth and latency tester (Get-LinkPerformance) that runs a series of iPerf3 load tests while concurently doing a TCP ping to show latency under various loads.
#### LogConverter
[LogConverter][LogConverter] contains code for downloading operational network logs and converting them to .CSV files. Files can then be uploaded to Power BI for analysis.
<!--Image References-->
[0]: ./AzureCT/media/AzureNMT.png "Azure Network Monitoring Tools"
<!--Link References-->
[LogConverter]: https://github.com/Azure/NetworkMonitoring/tree/master/LogConverter "LogConverter tree"
[AzureCT]: https://github.com/Azure/NetworkMonitoring/tree/master/AzureCT "AzureCT tree"