public bool IsValidServiceBusMessage(Message message) { if (message == null) { Logger.LogError($"Message {nameof(message)} is null."); return(false); } var messageBody = Encoding.UTF8.GetString(message.Body); try { var serviceBusMessage = JsonConvert.DeserializeObject <ServiceBusMessage>(messageBody); if (serviceBusMessage.EventType.Contains("BlobCreate", StringComparison.OrdinalIgnoreCase) && StorageUtilities.GetContainerNameFromUri(serviceBusMessage.Data.Url).Equals(StartTranscriptionEnvironmentVariables.AudioInputContainer, StringComparison.Ordinal)) { return(true); } } catch (JsonSerializationException e) { Logger.LogError($"Exception {e.Message} while parsing message {messageBody} - message will be ignored."); return(false); } return(false); }
public void GetContainerFromSasTest() { var containerName = StorageUtilities.GetContainerNameFromUri(new Uri(TestSasUri)); var fileName = StorageUtilities.GetFileNameFromUri(new Uri(TestSasUri)); var fileNameWithoutExtension = StorageUtilities.GetFileNameWithoutExtension(fileName); Assert.AreEqual("testContainer", containerName); Assert.AreEqual("testfolder/test.wav", fileName); Assert.AreEqual("testfolder/test", fileNameWithoutExtension); }