using Azure.ResourceManager; using Microsoft.Extensions.Logging; namespace ProperDI.Azure.Endpoints.ResourceGroup.LogLooker; public interface IActivityLogReader { Task Scan(CancellationToken cancellationToken); } public class ActivityLogReader( ILogger logger, ArmClient armClient) : IActivityLogReader { private readonly ILogger _logger = logger ?? throw new ArgumentNullException(nameof(logger)); private readonly ArmClient _armClient = armClient ?? throw new ArgumentNullException(nameof(armClient)); public async Task Scan(CancellationToken cancellationToken) { try { _logger.LogInformation("Scanning for resources"); var resp = await _armClient.GetDefaultSubscriptionAsync(cancellationToken); _logger.LogInformation("Found default subscription {sub}", resp.Data.DisplayName); } catch (TaskCanceledException) { _logger.LogWarning("Task canceled"); } catch (System.Exception ex) { _logger.LogError(ex, "Http request failed"); throw; } } }