Skip to content

Add azure powershell credential #329

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jan 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion shell/agents/Microsoft.Azure.Agent/AzureAgent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
4 changes: 2 additions & 2 deletions shell/agents/Microsoft.Azure.Agent/ChatSession.cs
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@ private async Task<string> 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 ...");
Expand Down
6 changes: 4 additions & 2 deletions shell/agents/Microsoft.Azure.Agent/Schema.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Loading