public async Task StartAsync(CancellationToken cancellationToken)
        {
            _logger.LogInformation("Registering with Spring Boot Admin Server at {0}", _options.Url);
            var basePath = _options.BasePath.TrimEnd('/');
            var app      = new Application()
            {
                Name          = _options.ApplicationName ?? "Steeltoe",
                HealthUrl     = new Uri($"{basePath}{_mgmtOptions.Path}/{_healthOptions.Path}"),
                ManagementUrl = new Uri($"{basePath}{_mgmtOptions.Path}"),
                ServiceUrl    = new Uri($"{basePath}/"),
                Metadata      = new Dictionary <string, object> {
                    { "startup", DateTime.Now }
                },
            };

            app.Metadata.Merge(_options.Metadata);

            _httpClient.Timeout = TimeSpan.FromMilliseconds(_options.ConnectionTimeoutMS);
            var result = await _httpClient.PostAsJsonAsync($"{_options.Url}/instances", app);

            if (result.IsSuccessStatusCode)
            {
                RegistrationResult = await result.Content.ReadFromJsonAsync <RegistrationResult>();
            }
            else
            {
                _logger.LogError($"Error registering with SpringBootAdmin {result}");
            }
        }
        /// <summary>
        /// Register the application with a Spring-Boot-Admin server
        /// </summary>
        /// <param name="builder"><see cref="IApplicationBuilder"/></param>
        /// <param name="configuration">App configuration. Will be retrieved from builder.ApplicationServices if not provided</param>
        /// <param name="httpClient">A customized HttpClient. [Bring your own auth]</param>
        public static void RegisterWithSpringBootAdmin(this IApplicationBuilder builder, IConfiguration configuration = null, HttpClient httpClient = null)
        {
            if (builder is null)
            {
                throw new ArgumentNullException(nameof(builder));
            }

            if (configuration is null)
            {
                configuration = builder.ApplicationServices.GetRequiredService <IConfiguration>();
            }

            var logger        = builder.ApplicationServices.GetService <ILogger <SpringBootAdminClientOptions> >();
            var appInfo       = builder.ApplicationServices.GetApplicationInstanceInfo();
            var options       = new SpringBootAdminClientOptions(configuration, appInfo);
            var mgmtOptions   = new ManagementEndpointOptions(configuration);
            var healthOptions = new HealthEndpointOptions(configuration);
            var basePath      = options.BasePath.TrimEnd('/');

            httpClient ??= HttpClientHelper.GetHttpClient(options.ValidateCertificates, ConnectionTimeoutMs);

            var app = new Application()
            {
                Name          = options.ApplicationName ?? "Steeltoe",
                HealthUrl     = new Uri($"{basePath}{mgmtOptions.Path}/{healthOptions.Path}"),
                ManagementUrl = new Uri($"{basePath}{mgmtOptions.Path}"),
                ServiceUrl    = new Uri($"{basePath}/"),
                Metadata      = new Dictionary <string, object> {
                    { "startup", DateTime.Now }
                },
            };

            app.Metadata.Merge(options.Metadata);

            var lifetime = builder.ApplicationServices.GetService <IHostApplicationLifetime>();

            lifetime.ApplicationStarted.Register(() =>
            {
                logger?.LogInformation("Registering with Spring Boot Admin Server at {0}", options.Url);

                var result = httpClient.PostAsJsonAsync($"{options.Url}/instances", app).GetAwaiter().GetResult();
                if (result.IsSuccessStatusCode)
                {
                    RegistrationResult = result.Content.ReadFromJsonAsync <RegistrationResult>().GetAwaiter().GetResult();
                }
                else
                {
                    logger.LogError($"Error registering with SpringBootAdmin {result}");
                }
            });

            lifetime.ApplicationStopped.Register(() =>
            {
                if (RegistrationResult == null || string.IsNullOrEmpty(RegistrationResult.Id))
                {
                    return;
                }

                _ = httpClient.DeleteAsync($"{options.Url}/instances/{RegistrationResult.Id}").GetAwaiter().GetResult();
            });
        }