private async Task SendNotificationAsync()

in src/WebJobs.Extensions.DurableTask/EventGridLifeCycleNotificationHelper.cs [147:208]


        private async Task SendNotificationAsync(
            EventGridEvent[] eventGridEventArray,
            string hubName,
            string functionName,
            string instanceId,
            string reason,
            FunctionState functionState)
        {
            string json = JsonConvert.SerializeObject(eventGridEventArray);
            StringContent content = new StringContent(json, Encoding.UTF8, "application/json");
            Stopwatch stopWatch = Stopwatch.StartNew();

            // Details about the Event Grid REST API
            // https://docs.microsoft.com/en-us/rest/api/eventgrid/
            HttpResponseMessage result = null;
            try
            {
                result = await httpClient.PostAsync(this.eventGridTopicEndpoint, content);
            }
            catch (Exception e)
            {
                this.traceHelper.EventGridException(
                    hubName,
                    functionName,
                    functionState,
                    instanceId,
                    e.StackTrace,
                    e,
                    reason,
                    stopWatch.ElapsedMilliseconds);
                return;
            }

            using (result)
            {
                var body = await result.Content.ReadAsStringAsync();
                if (result.IsSuccessStatusCode)
                {
                    this.traceHelper.EventGridSuccess(
                        hubName,
                        functionName,
                        functionState,
                        instanceId,
                        body,
                        result.StatusCode,
                        reason,
                        stopWatch.ElapsedMilliseconds);
                }
                else
                {
                    this.traceHelper.EventGridFailed(
                        hubName,
                        functionName,
                        functionState,
                        instanceId,
                        body,
                        result.StatusCode,
                        reason,
                        stopWatch.ElapsedMilliseconds);
                }
            }
        }