Skip to content

Commit

Permalink
Abzu-75062-Updated app insight configuration. (#195)
Browse files Browse the repository at this point in the history
* Abzu-75062-Updated app insight configuration.
Updated token parameter while adding pipeline lease

* Abzu-75062-Removed application Insights telemetry
  • Loading branch information
JiviteshT authored Mar 22, 2023
1 parent 6681dd2 commit 827d256
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 25 deletions.
3 changes: 2 additions & 1 deletion Deployment/add-lease.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Param(

try{
$contentType = "application/json";
$headers = @{ Authorization = 'Bearer $accessToken' };
$headers = @{ Authorization = $accessToken };
$rawRequest = @{ daysValid = $daysValid; definitionId = $definitionId; ownerId = $ownerId; protectPipeline = $false; runId = $buildId };
$request = ConvertTo-Json @($rawRequest);
$uri = "$collectionUri$teamProject/_apis/build/retention/leases?api-version=7.0";
Expand All @@ -23,6 +23,7 @@ try{
Write-Host "Pipeline will be retained for $daysValid days"
}
catch{
Write-Host "##vso[task.LogIssue type=warning;]Pipeline retaintion failed."
Write-Host $_
Write-Host "##vso[task.complete result=SucceededWithIssues;]"
}
2 changes: 1 addition & 1 deletion Deployment/templates/retain-pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ steps:
targetType: filePath
filePath: "$(Build.SourcesDirectory)/Deployment/add-lease.ps1"
arguments: "-daysValid 365
-accessToken '$(System.AccessToken)'
-accessToken 'Bearer $(System.AccessToken)'
-definitionId $(System.DefinitionId)
-ownerId 'User:$(Build.RequestedForId)'
-buildId $(Build.BuildId)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,25 +1,24 @@
using Azure.Extensions.AspNetCore.Configuration.Secrets;
using Azure.Identity;
using Azure.Security.KeyVault.Secrets;
using Microsoft.ApplicationInsights.Channel;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using System;
using System.Diagnostics.CodeAnalysis;
using Microsoft.Extensions.Logging;
using Serilog;
using Serilog.Events;
using Microsoft.Extensions.Logging;
using System;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Reflection;
using System.Threading.Tasks;
using UKHO.ExchangeSetService.CleanUpJob.Configuration;
using UKHO.ExchangeSetService.CleanUpJob.Helpers;
using UKHO.ExchangeSetService.CleanUpJob.Services;
using UKHO.ExchangeSetService.Common.Configuration;
using UKHO.ExchangeSetService.Common.Helpers;
using UKHO.ExchangeSetService.CleanUpJob.Services;
using UKHO.ExchangeSetService.Common.Storage;
using UKHO.Logging.EventHubLogProvider;
using System.Reflection;
using System.Linq;
using UKHO.ExchangeSetService.CleanUpJob.Configuration;
using UKHO.ExchangeSetService.CleanUpJob.Helpers;
using System.Threading.Tasks;
using Microsoft.ApplicationInsights.Channel;
using Microsoft.ApplicationInsights.Extensibility;

namespace UKHO.ExchangeSetService.CleanUpJob
{
Expand Down Expand Up @@ -106,10 +105,7 @@ private static void ConfigureServices(IServiceCollection serviceCollection, ICon
string instrumentationKey = configuration["APPINSIGHTS_INSTRUMENTATIONKEY"];
if (!string.IsNullOrEmpty(instrumentationKey))
{
loggingBuilder.AddApplicationInsights(
configureTelemetryConfiguration: (config) => config.ConnectionString = instrumentationKey,
configureApplicationInsightsLoggerOptions: (options) => { }
);
loggingBuilder.AddApplicationInsightsWebJobs(o => o.InstrumentationKey = instrumentationKey);
}
#if DEBUG
Expand Down Expand Up @@ -147,14 +143,6 @@ private static void ConfigureServices(IServiceCollection serviceCollection, ICon
}
});

serviceCollection.Configure<TelemetryConfiguration>(
(config) =>
{
config.TelemetryChannel = aiChannel;
config.ConnectionString = configuration["APPINSIGHTS_INSTRUMENTATIONKEY"];
}
);

serviceCollection.Configure<EssFulfilmentStorageConfiguration>(configuration.GetSection("EssFulfilmentStorageConfiguration"));
serviceCollection.Configure<CleanUpConfiguration>(configuration.GetSection("CleanUpConfiguration"));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
<PackageReference Include="Serilog" Version="2.12.0" />
<PackageReference Include="Serilog.Extensions.Logging" Version="3.1.0" />
<PackageReference Include="Serilog.Sinks.File" Version="5.0.0" />
<PackageReference Include="Microsoft.Azure.WebJobs.Logging.ApplicationInsights" Version="3.0.33" />
</ItemGroup>

<ItemGroup>
Expand Down

0 comments on commit 827d256

Please sign in to comment.