revert
This commit is contained in:
@@ -81,6 +81,7 @@ public class RoleAssesorBackgroundService : IHostedService, IDisposable
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
GC.SuppressFinalize(this);
|
||||
_timer?.Dispose();
|
||||
}
|
||||
}
|
||||
58
Program.cs
58
Program.cs
@@ -2,55 +2,29 @@
|
||||
using Microsoft.Extensions.Azure;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using ProperDI.Azure.Endpoints.ResourceGroup;
|
||||
|
||||
public class Program
|
||||
{
|
||||
public static async Task Main(string[] args)
|
||||
{
|
||||
var host = CreateHostBuilder(args).Build();
|
||||
await host.RunAsync();
|
||||
}
|
||||
HostApplicationBuilder builder = Host.CreateApplicationBuilder(args);
|
||||
|
||||
public static IHostBuilder CreateHostBuilder(string[] args) =>
|
||||
Host.CreateDefaultBuilder(args)
|
||||
.ConfigureAppConfiguration((hostingContext, config) =>
|
||||
builder.Services.AddHttpClient();
|
||||
builder.Services.AddTransient<IActivityLogReader, ActivityLogReader>();
|
||||
builder.Services.AddAzureClients(clientBuilder =>
|
||||
{
|
||||
config.AddEnvironmentVariables();
|
||||
|
||||
// Optionally, you can add JSON configuration if needed
|
||||
config.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true);
|
||||
// config.AddJsonFile($"appsettings.{hostingContext.HostingEnvironment.EnvironmentName}.json", optional: true, reloadOnChange: true);
|
||||
})
|
||||
.ConfigureServices((hostContext, services) =>
|
||||
{
|
||||
services.AddHttpClient();
|
||||
services.AddTransient<IActivityLogReader, ActivityLogReader>();
|
||||
|
||||
services.AddAzureClients(clientBuilder =>
|
||||
{
|
||||
var configuration = hostContext.Configuration;
|
||||
|
||||
// Read Azure credentials from environment variables
|
||||
var tenantId = configuration["AzureTenantId"];
|
||||
var clientId = configuration["AzureClientId"];
|
||||
var clientSecret = configuration["AzureClientSecret"];
|
||||
var subscriptionId = configuration["AzureSubscriptionId"];
|
||||
System.Console.WriteLine($"Tenant id: {tenantId}\nClientID: {clientId}\nClientSecret: {clientSecret}");
|
||||
var credential = new ClientSecretCredential(tenantId, clientId, clientSecret);
|
||||
|
||||
clientBuilder.UseCredential(credential);
|
||||
clientBuilder.AddArmClient(subscriptionId);
|
||||
// var creds = new ClientSecretCredential(
|
||||
// "",
|
||||
// "",
|
||||
// "");
|
||||
clientBuilder.UseCredential(new DefaultAzureCredential());
|
||||
clientBuilder.AddArmClient(builder.Configuration.GetSection("Am95DevSubscriptionId"));
|
||||
clientBuilder.ConfigureDefaults(client =>
|
||||
{
|
||||
client.Retry.MaxRetries = 3;
|
||||
});
|
||||
clientBuilder.AddLogsQueryClient();
|
||||
});
|
||||
|
||||
services.Configure<RoleAssesorBackgroundServiceOptions>(
|
||||
hostContext.Configuration.GetSection("RoleAssessorBackgroundService"));
|
||||
services.AddHostedService<RoleAssesorBackgroundService>();
|
||||
});
|
||||
}
|
||||
builder.Services.Configure<RoleAssesorBackgroundServiceOptions>(builder.Configuration.GetSection("RoleAssessorBackgroundService"));
|
||||
builder.Services.AddHostedService<RoleAssesorBackgroundService>();
|
||||
|
||||
var host = builder.Build();
|
||||
|
||||
await host.RunAsync();
|
||||
25
Sentinel.sln
Normal file
25
Sentinel.sln
Normal file
@@ -0,0 +1,25 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.11.35327.3
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Sentinel", "Sentinel.csproj", "{FA937A3C-5191-4DAC-AC62-EBF7EE90BD1F}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{FA937A3C-5191-4DAC-AC62-EBF7EE90BD1F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{FA937A3C-5191-4DAC-AC62-EBF7EE90BD1F}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{FA937A3C-5191-4DAC-AC62-EBF7EE90BD1F}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{FA937A3C-5191-4DAC-AC62-EBF7EE90BD1F}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {79EE9B52-D46E-4FBB-8310-32FD5835CF1D}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
@@ -12,6 +12,7 @@
|
||||
"RoleAssessorBackgroundService": {
|
||||
"RunFrequencyInMinutes": 12
|
||||
},
|
||||
"Am95DevSubscriptionId": "040698c2-a013-45be-b1fa-e975f46b9d63",
|
||||
"DefaultSubscriptionId": "2690a5f1-155b-4fa8-896f-92c6bcb62bee",
|
||||
"ASPNETCORE_ENVIRONMENT": "Development",
|
||||
"AzureSubscriptionId": "2690a5f1-155b-4fa8-896f-92c6bcb62bee",
|
||||
|
||||
Reference in New Issue
Block a user