private static async Task SaveResponseAsync(StackExchangeResponse stackExchangeResponse)
        {
            //var config = new ConfigurationBuilder().SetBasePath(context.FunctionAppDirectory).AddJsonFile("local.settings.json", optional: true, reloadOnChange: true).AddEnvironmentVariables().Build();

            CloudStorageAccount storageAccount = new CloudStorageAccount(
                new Microsoft.WindowsAzure.Storage.Auth.StorageCredentials(
                    config["SEStorageName"], config["SEStorageKey"]), true);

            CloudTableClient tableClient = storageAccount.CreateCloudTableClient();
            CloudTable       stackExchangeQuestionsTable = tableClient.GetTableReference("StackExchangeQuestions");

            foreach (var item in stackExchangeResponse.items)
            {
                var            itemEntity      = _mapper.Map <StackExchangeResponseItemEntity>(item);
                TableOperation insertOperation = TableOperation.InsertOrReplace(itemEntity);
                await stackExchangeQuestionsTable.ExecuteAsync(insertOperation);
            }
        }
        private static List <EventGridEvent> PackageEvents(StackExchangeResponse stackExchangeResponse)
        {
            var events  = new List <EventGridEvent>();
            var tagsCSV = string.Join(",", tags);

            foreach (var item in stackExchangeResponse.items)
            {
                var tempEvent = new EventGridEvent()
                {
                    Id          = Guid.NewGuid().ToString(),
                    Data        = item,
                    EventTime   = DateTime.Now,
                    EventType   = $"StackExchange.NewQuestion.{site}.{tagsCSV}",
                    Subject     = "NewQuestion",
                    DataVersion = "1.0"
                };
                events.Add(tempEvent);
            }
            return(events);
        }
        private static async Task SendToEventGridTopic(StackExchangeResponse stackExchangeResponse)
        {
            var topicHostName = "sequestionstopic.westus2-1.eventgrid.azure.net";
            var topicKey      = "nPZy0jWBGjBBwGGtNCbmopNiIYfj/sR8awdtk2idaFs=";
            // Create service credential with the topic credential
            // class and custom topic access key
            var credentials = new TopicCredentials(topicKey);

            // Create an instance of the event grid client class
            var client = new EventGridClient(credentials);

            // Retrieve a collection of events
            var events = PackageEvents(stackExchangeResponse);

            if (events.Count > 0)
            {
                // Publish the events
                await client.PublishEventsAsync(
                    topicHostName,
                    events);
            }
        }