Global Variables

Global Variables let one automation step pass values to later steps during the same task run. They are useful for chaining outputs (for example script output, generated IDs, or runtime secrets) without hard-coding values.


Variable Sources

A task run can receive variables from three sources:

Linked custom parameter values entered at execution time are added when the run starts.

Certificate system variables are pre-populated for certificate task runs.

Script output variables can be appended by PowerShell Script steps while the run is executing.

Variables are scoped to one task run. They are available to later steps in that run and stored with run history.


Using Variable References

Use variable placeholders with double braces:

{{ VariableName }}

Runtime replacement is applied to supported string fields, including:

• Script step parameter values.

• Service action fields (name, display name, description, startup parameters).

• Certificate install fields (store path, PFX path/password, post-script content).

• Key Vault certificate fields (vault URI and certificate name).

• DevOps pipeline parameter values and branch field.


Creating Variables from PowerShell Output

PowerShell Script step output can create variables by writing lines in this format:

::azx-set-var:VariableName=VariableValue

Example:

$serverName = $env:COMPUTERNAME Write-Host "::azx-set-var:ServerName=$serverName" $deploymentId = "deploy-$(Get-Date -Format 'yyyyMMdd-HHmmss')" Write-Host "::azx-set-var:DeploymentId=$deploymentId"

The legacy ##vso[task.setvariable...] syntax is not the runtime parser format used by current agent step execution.


Certificate Task System Variables

Certificate task runs include built-in certificate variables when data is available:

• CertificateThumbprint

• CertificateSubject

• CertificateExpiration

• CertificateCommonName

• CertificatePrimaryDomain

• CertificateFriendlyName

• CertificatePassword

Global Variables Concept

Variable Lifecycle and History

1. A run starts and initial variables are created (custom input values + system values where applicable).

2. Steps execute and script steps can append additional variables.

3. Variables are stored encrypted and shown in run details to authorized users.

4. History views can reveal/copy variable values for troubleshooting.

View Variables in Execution History

Variable values are encrypted at rest and decrypted only for allowed views or step execution flows that require plaintext.


Parallel Execution Considerations

Steps running in parallel should not assume variables from sibling parallel steps are already available.

• Create shared variables in earlier sequential steps.

• Keep parallel branches independent when possible.

• If branches must share data, merge results in a later sequential step.


Troubleshooting

Variable not replaced

• Check spelling and casing in both declaration and placeholder.

• Confirm the producing step completed before the consuming step runs.

• Verify the field supports runtime replacement (not every field type is replaced).


Script variable did not appear

• Ensure the script writes exactly: ::azx-set-var:Name=Value.

• Check script output in step run logs to confirm the line was emitted.

• Avoid relying on script output from non-PSScript step types.



If you encounter any issues or need further assistance, please contact us at

info@azexecute.com

. Our support team is here to help you.

An unhandled error has occurred. Reload 🗙
An unhandled error has occurred. Reload 🗙