diff --git a/src/Microsoft.Health.Dicom.Blob/Features/Storage/BlobFileStore.cs b/src/Microsoft.Health.Dicom.Blob/Features/Storage/BlobFileStore.cs index 0825a625e2..3d3fc27f1d 100644 --- a/src/Microsoft.Health.Dicom.Blob/Features/Storage/BlobFileStore.cs +++ b/src/Microsoft.Health.Dicom.Blob/Features/Storage/BlobFileStore.cs @@ -558,6 +558,14 @@ private async Task ExecuteAsync( _logger.LogError(ex, message: "Access to storage account failed with ErrorCode: {ErrorCode}", ex.ErrorCode); throw new DataStoreRequestFailedException(ex, _blobClient.IsExternal); } + catch (AggregateException ex) when (_blobClient.IsExternal && ex.InnerException is RequestFailedException) + { + var innerEx = ex.InnerException as RequestFailedException; + _logger.LogError(innerEx, + message: "Access to external storage account failed with ErrorCode: {ErrorCode}", + innerEx.ErrorCode); + throw new DataStoreRequestFailedException(innerEx, _blobClient.IsExternal); + } catch (Exception ex) { _logger.LogError(ex, "Access to storage account failed"); diff --git a/src/Microsoft.Health.Dicom.Core/DicomCoreResource.Designer.cs b/src/Microsoft.Health.Dicom.Core/DicomCoreResource.Designer.cs index 5d921c0f02..1320aa6ffd 100644 --- a/src/Microsoft.Health.Dicom.Core/DicomCoreResource.Designer.cs +++ b/src/Microsoft.Health.Dicom.Core/DicomCoreResource.Designer.cs @@ -519,6 +519,15 @@ internal static string ExternalDataStoreBlobModified { } } + /// + /// Looks up a localized string similar to Error occurred during an operation on the configured storage account. Use the https://go.microsoft.com/fwlink/?linkid=2251550 to troubleshoot the issue. No such host is known. + /// + internal static string ExternalDataStoreHostIsUnknown { + get { + return ResourceManager.GetString("ExternalDataStoreHostIsUnknown", resourceCulture); + } + } + /// /// Looks up a localized string similar to Error occurred during an operation on the configured storage account. Use the https://go.microsoft.com/fwlink/?linkid=2251550 to troubleshoot the issue. Received the following error code: {0}. /// @@ -528,6 +537,15 @@ internal static string ExternalDataStoreOperationFailed { } } + /// + /// Looks up a localized string similar to Error occurred during an operation on the configured storage account. Use the https://go.microsoft.com/fwlink/?linkid=2251550 to troubleshoot the issue. + /// + internal static string ExternalDataStoreOperationFailedUnknownIssue { + get { + return ResourceManager.GetString("ExternalDataStoreOperationFailedUnknownIssue", resourceCulture); + } + } + /// /// Looks up a localized string similar to Authorization failed.. /// diff --git a/src/Microsoft.Health.Dicom.Core/DicomCoreResource.resx b/src/Microsoft.Health.Dicom.Core/DicomCoreResource.resx index c5f910d41e..90da17bef5 100644 --- a/src/Microsoft.Health.Dicom.Core/DicomCoreResource.resx +++ b/src/Microsoft.Health.Dicom.Core/DicomCoreResource.resx @@ -667,6 +667,12 @@ For details on valid range queries, please refer to Search Matching section in C Error occurred during an operation on the configured storage account. Use the https://go.microsoft.com/fwlink/?linkid=2251550 to troubleshoot the issue. Received the following error code: {0} + + Error occurred during an operation on the configured storage account. Use the https://go.microsoft.com/fwlink/?linkid=2251550 to troubleshoot the issue. No such host is known. + + + Error occurred during an operation on the configured storage account. Use the https://go.microsoft.com/fwlink/?linkid=2251550 to troubleshoot the issue. + Received the following error code from blob storage account: {0}. Can not perform operation '{1}' because the blob '{2}' with eTag '{3}' has been modified or deleted by another process. Use the https://go.microsoft.com/fwlink/?linkid=2251550 to troubleshoot the issue. diff --git a/src/Microsoft.Health.Dicom.Core/Exceptions/DataStoreRequestFailedException.cs b/src/Microsoft.Health.Dicom.Core/Exceptions/DataStoreRequestFailedException.cs index 28312b4cf5..c5aec11762 100644 --- a/src/Microsoft.Health.Dicom.Core/Exceptions/DataStoreRequestFailedException.cs +++ b/src/Microsoft.Health.Dicom.Core/Exceptions/DataStoreRequestFailedException.cs @@ -3,6 +3,7 @@ // Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. // ------------------------------------------------------------------------------------------------- +using System; using System.Globalization; using Azure; @@ -17,10 +18,33 @@ public class DataStoreRequestFailedException : ConditionalExternalException public DataStoreRequestFailedException(RequestFailedException ex, bool isExternal = false) : base( (isExternal ? - string.Format(CultureInfo.InvariantCulture, DicomCoreResource.ExternalDataStoreOperationFailed, ex?.ErrorCode) + getFormattedExternalStoreMessage(ex) : DicomCoreResource.DataStoreOperationFailed), ex, isExternal) { } + + private static string getFormattedExternalStoreMessage(RequestFailedException ex) + { + return !string.IsNullOrEmpty(ex?.ErrorCode) + ? string.Format( + CultureInfo.InvariantCulture, + DicomCoreResource.ExternalDataStoreOperationFailed, + ex?.ErrorCode) + : GetFormattedExternalStoreMessageWithoutErrorCode(ex) + ; + } + + private static string GetFormattedExternalStoreMessageWithoutErrorCode(RequestFailedException ex) + { + if (ex.Message.Contains("No such host is known", StringComparison.OrdinalIgnoreCase)) + { + return DicomCoreResource.ExternalDataStoreHostIsUnknown; + } + + // if we do not have an error code and internal message is not "host not known", we are not familiar with the issue + // we can't just give back the exception message as it may contain sensitive information + return DicomCoreResource.ExternalDataStoreOperationFailedUnknownIssue; + } } \ No newline at end of file