From 512bd4c4980cabb770f54fcf9e2e05c26d1a166d Mon Sep 17 00:00:00 2001 From: Dongbo Wang Date: Thu, 31 Oct 2024 10:23:40 -0700 Subject: [PATCH] Change to the 'canary' Copilot Access URL because the production URL doesn't work in some regions --- shell/agents/Microsoft.Azure.Agent/ChatSession.cs | 5 ++++- shell/agents/Microsoft.Azure.Agent/Utils.cs | 7 ++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/shell/agents/Microsoft.Azure.Agent/ChatSession.cs b/shell/agents/Microsoft.Azure.Agent/ChatSession.cs index 93a550f8..d27e3015 100644 --- a/shell/agents/Microsoft.Azure.Agent/ChatSession.cs +++ b/shell/agents/Microsoft.Azure.Agent/ChatSession.cs @@ -11,7 +11,10 @@ namespace Microsoft.Azure.Agent; internal class ChatSession : IDisposable { - private const string ACCESS_URL = "https://copilotweb.production.portalrp.azure.com/api/access?api-version=2024-09-01"; + // TODO: production URL not yet working for some regions. + // private const string ACCESS_URL = "https://copilotweb.production.portalrp.azure.com/api/access?api-version=2024-09-01"; + private const string ACCESS_URL = "https://copilotweb.canary.production.portalrp.azure.com/api/access?api-version=2024-09-01"; + private const string DL_TOKEN_URL = "https://copilotweb.production.portalrp.azure.com/api/conversations/start?api-version=2024-11-15"; private const string CONVERSATION_URL = "https://directline.botframework.com/v3/directline/conversations"; diff --git a/shell/agents/Microsoft.Azure.Agent/Utils.cs b/shell/agents/Microsoft.Azure.Agent/Utils.cs index d14ceb7a..40bf2701 100644 --- a/shell/agents/Microsoft.Azure.Agent/Utils.cs +++ b/shell/agents/Microsoft.Azure.Agent/Utils.cs @@ -40,7 +40,12 @@ internal async static Task EnsureSuccessStatusCodeForTokenRequest(this HttpRespo if (!response.IsSuccessStatusCode) { string responseText = await response.Content.ReadAsStringAsync(CancellationToken.None); - string message = $"{errorMessage} HTTP status: {response.StatusCode}, Response: {responseText}"; + if (string.IsNullOrEmpty(responseText)) + { + responseText = ""; + } + + string message = $"{errorMessage} HTTP status: {response.StatusCode}, Response: {responseText}."; Telemetry.Trace(AzTrace.Exception(message)); throw new TokenRequestException(message); }