Skip to content

[enhancement]: Enable Credential Caching Across AzurePowerShell@5 Tasks in Azure Pipelines #21286

@emiacepacIG

Description

@emiacepacIG

Task name

AzurePowerShell@5

Describe your feature request here

In many pipelines, the AzurePowerShell@5 task is used repeatedly—our team often invokes it more than 20 times within a single pipeline. However, each invocation includes the following default cleanup commands::

Clear-AzContext -Scope CurrentUser -Force -ErrorAction SilentlyContinue
Clear-AzContext -Scope Process

And upon completion, it runs:
Disconnect-AzAccount -Scope CurrentUser -ErrorAction Stop
These operations remove the authentication context and credentials, resulting in a repeated login process for each task. This adds approximately 30 to 45 seconds per task, which can accumulate to 15 minutes or more in pipelines with many AzurePowerShell@5 steps.

Request:

Please consider adding an option to cache credentials across multiple AzurePowerShell@5 tasks within the same pipeline session. This would significantly reduce execution time and improve pipeline efficiency.

Note: While Enable-AzContextAutosave is available, it does not persist the context when the above cleanup commands are executed by default.

Suggested Solution:

Introduce a task-level parameter such as preserveContext: true or reuseCredentials: true that disables the automatic context clearing and disconnection behavior, allowing credential reuse across tasks.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions