protected override async Task OnActivateAsync()
        {
            try
            {
                await this.StateManager.TryAddStateAsync <Dictionary <int, ProductStockTrend> >("ProductStockTrends", new Dictionary <int, ProductStockTrend>());

                TimeSpan startDelay = TimeSpan.Parse(ConfigurationHelper.ReadValue("AppSettings", "PredictionTimerStartDelay"));
                TimeSpan interval   = TimeSpan.Parse(ConfigurationHelper.ReadValue("AppSettings", "PredictionTimerInterval"));

                if (!int.TryParse(ConfigurationHelper.ReadValue("AppSettings", "PredictionNotificationAttempts"), out this.notificationAttempts))
                {
                    this.notificationAttempts = 10;
                }

                // register timer to regularly check for updates
                this.notificationTimer = this.RegisterTimer(
                    this.RunNotificationAsync,
                    null,
                    startDelay,
                    interval
                    );

                this.mlClient = AzureMlClientFactory.CreateClient();

                await base.OnActivateAsync();
            }
            catch (Exception ex)
            {
                Logger.Error(ex, nameof(this.OnActivateAsync));
                throw;
            }
        }
        protected override async Task OnActivateAsync()
        {
            try
            {
                await this.StateManager.TryAddStateAsync<Dictionary<int, ProductStockTrend>>("ProductStockTrends", new Dictionary<int, ProductStockTrend>());

                TimeSpan startDelay = TimeSpan.Parse(ConfigurationHelper.ReadValue("AppSettings", "PredictionTimerStartDelay"));
                TimeSpan interval = TimeSpan.Parse(ConfigurationHelper.ReadValue("AppSettings", "PredictionTimerInterval"));

                if (!int.TryParse(ConfigurationHelper.ReadValue("AppSettings", "PredictionNotificationAttempts"), out this.notificationAttempts))
                {
                    this.notificationAttempts = 10;
                }

                // register timer to regularly check for updates
                this.notificationTimer = this.RegisterTimer(
                    this.RunNotificationAsync,
                    null,
                    startDelay,
                    interval
                    );

                this.mlClient = AzureMlClientFactory.CreateClient();

                await base.OnActivateAsync();
            }
            catch (Exception ex)
            {
                Logger.Error(ex, nameof(this.OnActivateAsync));
                throw;
            }
        }