revert
This commit is contained in:
64
Program.cs
64
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
|
||||
HostApplicationBuilder builder = Host.CreateApplicationBuilder(args);
|
||||
|
||||
builder.Services.AddHttpClient();
|
||||
builder.Services.AddTransient<IActivityLogReader, ActivityLogReader>();
|
||||
builder.Services.AddAzureClients(clientBuilder =>
|
||||
{
|
||||
public static async Task Main(string[] args)
|
||||
// var creds = new ClientSecretCredential(
|
||||
// "",
|
||||
// "",
|
||||
// "");
|
||||
clientBuilder.UseCredential(new DefaultAzureCredential());
|
||||
clientBuilder.AddArmClient(builder.Configuration.GetSection("Am95DevSubscriptionId"));
|
||||
clientBuilder.ConfigureDefaults(client =>
|
||||
{
|
||||
var host = CreateHostBuilder(args).Build();
|
||||
await host.RunAsync();
|
||||
}
|
||||
client.Retry.MaxRetries = 3;
|
||||
});
|
||||
});
|
||||
|
||||
public static IHostBuilder CreateHostBuilder(string[] args) =>
|
||||
Host.CreateDefaultBuilder(args)
|
||||
.ConfigureAppConfiguration((hostingContext, config) =>
|
||||
{
|
||||
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>();
|
||||
builder.Services.Configure<RoleAssesorBackgroundServiceOptions>(builder.Configuration.GetSection("RoleAssessorBackgroundService"));
|
||||
builder.Services.AddHostedService<RoleAssesorBackgroundService>();
|
||||
|
||||
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);
|
||||
var host = builder.Build();
|
||||
|
||||
clientBuilder.UseCredential(credential);
|
||||
clientBuilder.AddArmClient(subscriptionId);
|
||||
clientBuilder.ConfigureDefaults(client =>
|
||||
{
|
||||
client.Retry.MaxRetries = 3;
|
||||
});
|
||||
clientBuilder.AddLogsQueryClient();
|
||||
});
|
||||
|
||||
services.Configure<RoleAssesorBackgroundServiceOptions>(
|
||||
hostContext.Configuration.GetSection("RoleAssessorBackgroundService"));
|
||||
services.AddHostedService<RoleAssesorBackgroundService>();
|
||||
});
|
||||
}
|
||||
await host.RunAsync();
|
||||
Reference in New Issue
Block a user