diff --git a/sdk/core/Azure.Core.TestFramework/src/ProxyTransport.cs b/sdk/core/Azure.Core.TestFramework/src/ProxyTransport.cs index 5b7099fb27238..61c8abdf0f227 100644 --- a/sdk/core/Azure.Core.TestFramework/src/ProxyTransport.cs +++ b/sdk/core/Azure.Core.TestFramework/src/ProxyTransport.cs @@ -135,8 +135,16 @@ public override Request CreateRequest() _recording.HasRequests = true; lock (_recording.Random) { - // Make sure ClientRequestId are the same across request and response - request.ClientRequestId = _recording.Random.NewGuid().ToString("N"); + if (_recording.UseDefaultGuidFormatForClientRequestId) + { + // User want the client format to use the default format + request.ClientRequestId = _recording.Random.NewGuid().ToString(); + } + else + { + // Make sure ClientRequestId are the same across request and response + request.ClientRequestId = _recording.Random.NewGuid().ToString("N"); + } } return request; } diff --git a/sdk/core/Azure.Core.TestFramework/src/RecordedTestBase.cs b/sdk/core/Azure.Core.TestFramework/src/RecordedTestBase.cs index bf9d6306c5647..7161f0b06aca3 100644 --- a/sdk/core/Azure.Core.TestFramework/src/RecordedTestBase.cs +++ b/sdk/core/Azure.Core.TestFramework/src/RecordedTestBase.cs @@ -149,6 +149,13 @@ public string ReplacementHost /// public bool CompareBodies { get; set; } = true; + /// + /// Determines if the ClientRequestId that is sent as part of a request while in Record mode + /// should use the default Guid format. The default Guid format contains hyphens. + /// The default value is false. + /// + public bool UseDefaultGuidFormatForClientRequestId { get; set; } = false; + /// /// Request headers whose values can change between recording and playback without causing request matching /// to fail. The presence or absence of the header itself is still respected in matching. diff --git a/sdk/core/Azure.Core.TestFramework/src/TestRecording.cs b/sdk/core/Azure.Core.TestFramework/src/TestRecording.cs index 25aec74da98aa..bc36ff3936de3 100644 --- a/sdk/core/Azure.Core.TestFramework/src/TestRecording.cs +++ b/sdk/core/Azure.Core.TestFramework/src/TestRecording.cs @@ -199,6 +199,18 @@ public TestRandom Random public string RecordingId { get; private set; } + /// + /// Determines if the ClientRequestId that is sent as part of a request while in Record mode + /// should use the default Guid format. The default Guid format contains hyphens. + /// + public bool UseDefaultGuidFormatForClientRequestId + { + get + { + return _recordedTestBase.UseDefaultGuidFormatForClientRequestId; + } + } + /// /// Gets the moment in time that this test is being run. This is useful /// for any test recordings that capture the current time.