From 7c763bb18800d601c948d016918b9b8dc88df6aa Mon Sep 17 00:00:00 2001 From: David Revoledo Date: Tue, 9 Oct 2018 22:21:28 -0300 Subject: [PATCH] Use Azure Storage Account NameValidator to check LeaseContainerName --- .../AzureStorageCheckpointLeaseManager.cs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/Microsoft.Azure.EventHubs.Processor/AzureStorageCheckpointLeaseManager.cs b/src/Microsoft.Azure.EventHubs.Processor/AzureStorageCheckpointLeaseManager.cs index 1a31648..bb7fc1d 100644 --- a/src/Microsoft.Azure.EventHubs.Processor/AzureStorageCheckpointLeaseManager.cs +++ b/src/Microsoft.Azure.EventHubs.Processor/AzureStorageCheckpointLeaseManager.cs @@ -38,12 +38,15 @@ internal AzureStorageCheckpointLeaseManager(CloudStorageAccount cloudStorageAcco throw new ArgumentNullException(nameof(cloudStorageAccount)); } - // Validate lease container name. - if (!Regex.IsMatch(leaseContainerName, @"^[a-z0-9](([a-z0-9\-[^\-])){1,61}[a-z0-9]$")) + try + { + NameValidator.ValidateContainerName(leaseContainerName); + } + catch (ArgumentException) { throw new ArgumentException( "Azure Storage lease container name is invalid. Please check naming conventions at https://msdn.microsoft.com/en-us/library/azure/dd135715.aspx", - nameof(leaseContainerName)); + nameof(leaseContainerName)); } this.cloudStorageAccount = cloudStorageAccount;