public AzureDnsUpdaterService(ILogger <AzureDnsUpdaterService> logger, IServiceOptionsProvider serviceOptionsProvider) { Logger = logger; Options = serviceOptionsProvider.GetServiceOptions <AzureDnsOptions>(ServiceKey); EnsureOptionsSet(Options); }
private static void EnsureOptionsSet(AzureDnsOptions options) { if (options == null) { throw new InvalidOperationException("No options provided."); } if (string.IsNullOrWhiteSpace(options.ApplicationTenantDomain)) { throw new InvalidOperationException($"{nameof(AzureDnsOptions.ApplicationTenantDomain)} must be set."); } if (string.IsNullOrWhiteSpace(options.ApplicationClientId)) { throw new InvalidOperationException($"{nameof(AzureDnsOptions.ApplicationClientId)} must be set."); } if (string.IsNullOrWhiteSpace(options.ApplicationClientSecret)) { throw new InvalidOperationException($"{nameof(AzureDnsOptions.ApplicationClientSecret)} must be set."); } if (string.IsNullOrWhiteSpace(options.DnsSubscriptionId)) { throw new InvalidOperationException($"{nameof(AzureDnsOptions.DnsSubscriptionId)} must be set."); } if (string.IsNullOrWhiteSpace(options.DnsResourceGroup)) { throw new InvalidOperationException($"{nameof(AzureDnsOptions.DnsResourceGroup)} must be set."); } if (string.IsNullOrWhiteSpace(options.DnsZoneName)) { throw new InvalidOperationException($"{nameof(AzureDnsOptions.DnsZoneName)} must be set."); } if (string.IsNullOrWhiteSpace(options.DnsRelativeRecordSetName)) { throw new InvalidOperationException($"{nameof(AzureDnsOptions.DnsRelativeRecordSetName)} must be set."); } }