Muokkaa

Jaa


AzureCLI@1 - Azure CLI v1 task

Run Azure CLI commands against an Azure subscription in a shell script when running on Linux agent or batch script when running on Windows agent.

Run a shell or batch script with Azure CLI commands against an Azure subscription.

Syntax

# Azure CLI v1
# Run Azure CLI commands against an Azure subscription in a Shell script when running on Linux agent or Batch script when running on Windows agent.
- task: AzureCLI@1
  inputs:
    azureSubscription: # string. Alias: connectedServiceNameARM. Required. Azure subscription. 
    scriptLocation: 'scriptPath' # 'inlineScript' | 'scriptPath'. Required. Script Location. Default: scriptPath.
    scriptPath: # string. Required when scriptLocation = scriptPath. Script Path. 
    #inlineScript: # string. Required when scriptLocation = inlineScript. Inline Script. 
    #arguments: # string. Alias: args. Arguments. 
  # Advanced
    #addSpnToEnvironment: false # boolean. Access service principal details in script. Default: false.
    #useGlobalConfig: false # boolean. Use global Azure CLI configuration. Default: false.
    #workingDirectory: # string. Alias: cwd. Working Directory. 
    #failOnStandardError: false # boolean. Fail on Standard Error. Default: false.
# Azure CLI v1
# Run a Shell or Batch script with Azure CLI commands against an azure subscription.
- task: AzureCLI@1
  inputs:
    azureSubscription: # string. Alias: connectedServiceNameARM. Required. Azure subscription. 
    scriptLocation: 'scriptPath' # 'inlineScript' | 'scriptPath'. Required. Script Location. Default: scriptPath.
    scriptPath: # string. Required when scriptLocation = scriptPath. Script Path. 
    #inlineScript: # string. Required when scriptLocation = inlineScript. Inline Script. 
    #arguments: # string. Alias: args. Arguments. 
  # Advanced
    #workingDirectory: # string. Alias: cwd. Working Directory. 
    #failOnStandardError: false # boolean. Fail on Standard Error. Default: false.

Inputs

azureSubscription - Azure subscription
Input alias: connectedServiceNameARM. string. Required.

Selects an Azure Resource Manager subscription for the deployment.


scriptLocation - Script Location
string. Required. Allowed values: inlineScript (Inline script), scriptPath (Script path). Default value: scriptPath.

Selects the script location.


scriptPath - Script Path
string. Required when scriptLocation = scriptPath.

Fully qualified path of the script or a path relative to the the default working directory.


inlineScript - Inline Script
string. Required when scriptLocation = inlineScript.

You can write your scripts inline here. When using Windows agent, use batch scripting. Use shell scripting when using Linux-based agents. For batch files, use the prefix call before every Azure command. You can also pass predefined and custom variables to this script using arguments

See the following examples. The first is a shell example and the second is a batch example:

azure --version || azure account show 
call  azure --version || call azure account show

arguments - Arguments
Input alias: args. string.

Arguments passed to the script.


addSpnToEnvironment - Access service principal details in script
boolean. Default value: false.

Adds the service principal ID and key of the Azure endpoint that you chose to the script's execution environment. You can use the $servicePrincipalId and $servicePrincipalKey variables in your script.

This is honored only when the Azure endpoint has Service Principal authentication scheme.


useGlobalConfig - Use global Azure CLI configuration
boolean. Default value: false.

If this is false, this task will use its own separate Azure CLI configuration directory. This can be used to run Azure CLI tasks in parallel releases.


workingDirectory - Working Directory
Input alias: cwd. string.

Current working directory where the script is run. If left blank, this input is the root of the repo (build) or artifacts (release), which is $(System.DefaultWorkingDirectory).


failOnStandardError - Fail on Standard Error
boolean. Default value: false.

If this input is true, this task will fail when any errors are written to the StandardError stream. Clear the checkbox to ignore standard errors and instead rely on exit codes to determine the status.


Task control options

All tasks have control options in addition to their task inputs. For more information, see Control options and common task properties.

Output variables

None.

Remarks

What's new in Version 1.0:

  • Supports the new Azure CLI 2.0 which is Python based
  • Works with cross-platform agents (Linux, macOS, or Windows)
  • For working with Azure CLI 1.0 (node.js-based), switch to task version 0.0
  • Limitations: - No support for Azure Classic subscriptions. Azure CLI 2.0 supports only Azure Resource Manager (ARM) subscriptions.

Requirements

Requirement Description
Pipeline types YAML, Classic build, Classic release
Runs on Agent, DeploymentGroup
Demands None
Capabilities This task does not satisfy any demands for subsequent tasks in the job.
Command restrictions Any
Settable variables Any
Agent version 2.0.0 or greater
Task category Deploy