Task name
AzureCLI
Task version
2
Environment type (Please select at least one environment where you face this issue)
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:
- the task runs on the hosted agent
- 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.
Task name
AzureCLI
Task version
2
Environment type (Please select at least one environment where you face this issue)
Azure DevOps Server type
dev.azure.com (formerly visualstudio.com)
Operation system
Windows-latest
Task log
n/a
Relevant log output
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_DIRto 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: trueprevents the overriding of the azure configuration directory.I'm proposing that when:
AZURE_CONFIG_DIRenvironment variable is already setThen:
AZURE_CONFIG_DIRvariableOR:
useGlobalConfigisn't explicitly set tofalseto indicate the perf improvement that's possible by introducing this setting.The method that would be changed:
azure-pipelines-tasks/Tasks/AzureCLIV2/azureclitask.ts
Lines 181 to 193 in 16dcae9
useGlobalConfigwith bothtrueandfalseon the hosted agent, in the same job. hence my alternative of logging the suggestion.