[ExcludeFromCodeCoverage] //This function just calls other services which are tested so there is no logic here that can be tested. public async Task RunAsync([EventGridTrigger] EventGridEvent eventGridEvent, ILogger log) { try { // Get data from event grid event dynamic eventGridEventData = JsonConvert.DeserializeObject(eventGridEvent.Data.ToString()); Uri uri = new Uri(eventGridEventData.url.ToString()); // Generate correlation id and set Telemetry Guid correlation = _blobInfoFactoryService.CreateCorrelationId(); ScopedData scopedData = new ScopedData(); scopedData.AddCustomData(GeneralConstants.CorrelationIdKey, correlation.ToString()).Apply(); log.LogInformation("Started: {functionName} {uri}, {name}", _functionName, uri, uri.Segments.Last()); // Exclude empty files and folders if (!string.IsNullOrEmpty(uri.AbsoluteUri)) { // Generate BlobInfo BlobInfo blobInfo = _blobInfoFactoryService.CreateBlobInfo(uri, uri.Segments.Last(), correlation); log.LogInformation("{functionName}: created BlobInfo", _functionName); // Send service bus message await _serviceBusService.SubmitBlobInfoToServiceBus(blobInfo); log.LogInformation("{functionName}: submitted BlobInfo to Service Bus", _functionName); } } catch (Exception ex) { log.LogError(ex, "{functionName}: Failed to submit BlobInfo to Service Bus for {eventData}", _functionName, eventGridEvent.Data.ToString()); throw; } finally { log.LogInformation("{functionName}: Completed {eventData}", _functionName, eventGridEvent.Data.ToString()); } }