diff --git a/shell/agents/Microsoft.Azure.Agent/AzureAgent.cs b/shell/agents/Microsoft.Azure.Agent/AzureAgent.cs index 948bea49..f1bb3eb0 100644 --- a/shell/agents/Microsoft.Azure.Agent/AzureAgent.cs +++ b/shell/agents/Microsoft.Azure.Agent/AzureAgent.cs @@ -194,7 +194,7 @@ public async Task RefreshChatAsync(IShell shell, bool force) if (inner is CredentialUnavailableException) { host.WriteErrorLine($"Failed to start a chat session: Access token not available."); - host.WriteErrorLine($"The '{Name}' agent depends on the Azure CLI credential to acquire access token. Please run 'az login' from a command-line shell to setup account. Once you've successfully logged in, run '/refresh' to start a new conversation."); + host.WriteErrorLine($"The '{Name}' agent depends on the Azure CLI credential or Azure PowerShell credential to acquire access token. Please run 'az login' or 'Connect-AzAccount' from a command-line shell to setup account. Once you've successfully logged in, run '/refresh' to start a new conversation."); return; } diff --git a/shell/agents/Microsoft.Azure.Agent/ChatSession.cs b/shell/agents/Microsoft.Azure.Agent/ChatSession.cs index 448b18a2..064d73be 100644 --- a/shell/agents/Microsoft.Azure.Agent/ChatSession.cs +++ b/shell/agents/Microsoft.Azure.Agent/ChatSession.cs @@ -115,8 +115,8 @@ private async Task SetupNewChat(IStatusContext context, CancellationToke { try { - context.Status("Get Azure CLI login token ..."); - // Get an access token from the AzCLI login, using the specific audience guid. + context.Status("Get Azure login token ..."); + // Get an access token from the Azure CLI/PowerShell login, using the specific audience guid. await _accessToken.CreateOrRenewTokenAsync(cancellationToken); context.Status("Check Copilot authorization ..."); diff --git a/shell/agents/Microsoft.Azure.Agent/Schema.cs b/shell/agents/Microsoft.Azure.Agent/Schema.cs index 0aca7981..15a2da3d 100644 --- a/shell/agents/Microsoft.Azure.Agent/Schema.cs +++ b/shell/agents/Microsoft.Azure.Agent/Schema.cs @@ -386,8 +386,10 @@ internal async Task CreateOrRenewTokenAsync(CancellationToken cancellationToken) if (needRefresh) { - _accessToken = await new AzureCliCredential() - .GetTokenAsync(_tokenContext, cancellationToken); + _accessToken = await new ChainedTokenCredential( + new AzureCliCredential(), + new AzurePowerShellCredential() + ).GetTokenAsync(_tokenContext, cancellationToken); } } catch (Exception e) when (e is not OperationCanceledException)