Skip to content

[BUG]: AzureCLI@2 task ignores existing optimizations on hosted agent #19209

Description

Task name

AzureCLI

Task version

2

Environment type (Please select at least one environment where you face this issue)

  • Self-Hosted
  • Microsoft Hosted
  • VMSS Pool
  • Container

Azure DevOps Server type

dev.azure.com (formerly visualstudio.com)

Operation system

Windows-latest

Task log

n/a

Relevant log output

Setting AZURE_CONFIG_DIR env variable to: D:\a\_temp\.azclitask

Aditional info

The Azure Pipelines Hosted Agent images take extra care making sure that azure-cli is configured, pre-compiled, all required additional packages have been installed and the command index has been built.

By redirecting the AZURE_CONFIG_DIR to the agent's temp directory, all of that goes to waste and the performance difference is quite high. On the Windows Hosted Agents the time to run a simple command is about 1 extra minute than is needed.

Setting the useGlobalConfig: true prevents the overriding of the azure configuration directory.

I'm proposing that when:

  1. the task runs on the hosted agent
  2. the AZURE_CONFIG_DIR environment variable is already set

Then:

  • AzureCLI@2 will not reset the AZURE_CONFIG_DIR variable

OR:

  • AzureCLI@2 will log a warning if useGlobalConfig isn't explicitly set to false to indicate the perf improvement that's possible by introducing this setting.

The method that would be changed:

private static setConfigDirectory(): void {
if (tl.getBoolInput("useGlobalConfig")) {
return;
}
if (!!tl.getVariable('Agent.TempDirectory')) {
var azCliConfigPath = path.join(tl.getVariable('Agent.TempDirectory'), ".azclitask");
console.log(tl.loc('SettingAzureConfigDir', azCliConfigPath));
process.env['AZURE_CONFIG_DIR'] = azCliConfigPath;
} else {
console.warn(tl.loc('GlobalCliConfigAgentVersionWarning'));
}
}

⚠️ Warning: this might be a breaking change if people are mixing useGlobalConfig with both true and false on the hosted agent, in the same job. hence my alternative of logging the suggestion.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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