Skip to content

Commit 1c4a2e8

Browse files
authored
Add support to Azure PowerShell login credential (#329)
1 parent d16ac5a commit 1c4a2e8

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

shell/agents/Microsoft.Azure.Agent/AzureAgent.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ public async Task RefreshChatAsync(IShell shell, bool force)
194194
if (inner is CredentialUnavailableException)
195195
{
196196
host.WriteErrorLine($"Failed to start a chat session: Access token not available.");
197-
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.");
197+
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.");
198198
return;
199199
}
200200

shell/agents/Microsoft.Azure.Agent/ChatSession.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,8 @@ private async Task<string> SetupNewChat(IStatusContext context, CancellationToke
115115
{
116116
try
117117
{
118-
context.Status("Get Azure CLI login token ...");
119-
// Get an access token from the AzCLI login, using the specific audience guid.
118+
context.Status("Get Azure login token ...");
119+
// Get an access token from the Azure CLI/PowerShell login, using the specific audience guid.
120120
await _accessToken.CreateOrRenewTokenAsync(cancellationToken);
121121

122122
context.Status("Check Copilot authorization ...");

shell/agents/Microsoft.Azure.Agent/Schema.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -386,8 +386,10 @@ internal async Task CreateOrRenewTokenAsync(CancellationToken cancellationToken)
386386

387387
if (needRefresh)
388388
{
389-
_accessToken = await new AzureCliCredential()
390-
.GetTokenAsync(_tokenContext, cancellationToken);
389+
_accessToken = await new ChainedTokenCredential(
390+
new AzureCliCredential(),
391+
new AzurePowerShellCredential()
392+
).GetTokenAsync(_tokenContext, cancellationToken);
391393
}
392394
}
393395
catch (Exception e) when (e is not OperationCanceledException)

0 commit comments

Comments
 (0)