AzurePowerShell@3 - Azure PowerShell v3 任务

使用此任务可在 Azure 环境中运行 PowerShell 脚本。 使用提供的 Azure 资源管理器服务连接对 Azure 上下文进行身份验证。

此版本的任务已弃用;使用 AzurePowerShell@5

使用此任务可在 Azure 环境中运行 PowerShell 脚本。 使用提供的 Azure 资源管理器服务连接对 Azure 上下文进行身份验证。

语法

# Azure PowerShell v3
# Run a PowerShell script within an Azure environment.
- task: AzurePowerShell@3
  inputs:
    #azureConnectionType: 'ConnectedServiceNameARM' # 'ConnectedServiceName' | 'ConnectedServiceNameARM'. Alias: ConnectedServiceNameSelector. Azure Connection Type. Default: ConnectedServiceNameARM.
    #azureClassicSubscription: # string. Alias: ConnectedServiceName. Required when ConnectedServiceNameSelector = ConnectedServiceName. Azure Classic Subscription. 
    azureSubscription: # string. Alias: ConnectedServiceNameARM. Required when ConnectedServiceNameSelector = ConnectedServiceNameARM. Azure Subscription. 
    #ScriptType: 'FilePath' # 'FilePath' | 'InlineScript'. Script Type. Default: FilePath.
    #ScriptPath: # string. Optional. Use when ScriptType = FilePath. Script Path. 
    #Inline: # string. Optional. Use when ScriptType = InlineScript. Inline Script. 
    #ScriptArguments: # string. Optional. Use when ScriptType = FilePath. Script Arguments. 
    #errorActionPreference: 'stop' # 'stop' | 'continue' | 'silentlyContinue'. ErrorActionPreference. Default: stop.
    #FailOnStandardError: false # boolean. Fail on Standard Error. Default: false.
  # Azure PowerShell version options
    #azurePowerShellVersion: 'OtherVersion' # 'LatestVersion' | 'OtherVersion'. Alias: TargetAzurePs. Azure PowerShell Version. Default: OtherVersion.
    preferredAzurePowerShellVersion: # string. Alias: CustomTargetAzurePs. Required when TargetAzurePs = OtherVersion. Preferred Azure PowerShell Version. 
  # Advanced
    #validateScriptSignature: false # boolean. Optional. Use when ScriptType = FilePath. Validate script signature. Default: false.
# Azure PowerShell v3
# Run a PowerShell script within an Azure environment.
- task: AzurePowerShell@3
  inputs:
    #azureConnectionType: 'ConnectedServiceNameARM' # 'ConnectedServiceName' | 'ConnectedServiceNameARM'. Alias: ConnectedServiceNameSelector. Azure Connection Type. Default: ConnectedServiceNameARM.
    #azureClassicSubscription: # string. Alias: ConnectedServiceName. Required when ConnectedServiceNameSelector = ConnectedServiceName. Azure Classic Subscription. 
    azureSubscription: # string. Alias: ConnectedServiceNameARM. Required when ConnectedServiceNameSelector = ConnectedServiceNameARM. Azure Subscription. 
    #ScriptType: 'FilePath' # 'FilePath' | 'InlineScript'. Script Type. Default: FilePath.
    #ScriptPath: # string. Optional. Use when ScriptType = FilePath. Script Path. 
    #Inline: # string. Optional. Use when ScriptType = InlineScript. Inline Script. 
    #ScriptArguments: # string. Optional. Use when ScriptType = FilePath. Script Arguments. 
    #errorActionPreference: 'stop' # 'stop' | 'continue' | 'silentlyContinue'. ErrorActionPreference. Default: stop.
    #FailOnStandardError: false # boolean. Fail on Standard Error. Default: false.
  # Azure PowerShell version options
    #azurePowerShellVersion: 'OtherVersion' # 'LatestVersion' | 'OtherVersion'. Alias: TargetAzurePs. Azure PowerShell Version. Default: OtherVersion.
    preferredAzurePowerShellVersion: # string. Alias: CustomTargetAzurePs. Required when TargetAzurePs = OtherVersion. Preferred Azure PowerShell Version.

输入

azureConnectionType - Azure 连接类型
输入别名ConnectedServiceNameSelector. string。 允许的值:ConnectedServiceName(Azure 经典版)、ConnectedServiceNameARM(Azure 资源管理器)。 默认值:ConnectedServiceNameARM


azureClassicSubscription - Azure 经典订阅
输入别名ConnectedServiceName. stringConnectedServiceNameSelector = ConnectedServiceName时是必需的。

运行 PowerShell 之前要配置的 Azure 经典订阅。


azureSubscription - Azure 订阅
输入别名ConnectedServiceNameARM. stringConnectedServiceNameSelector = ConnectedServiceNameARM时是必需的。

运行 PowerShell 之前要配置的 Azure 资源管理器订阅。


ScriptType - 脚本类型
string。 允许的值:FilePath(脚本文件路径)、InlineScript(内联脚本)。 默认值:FilePath

脚本的类型:文件路径或内联。


ScriptPath - 脚本路径
string。 可选。 当 ScriptType = FilePath时使用。

脚本的路径。 这应该是完全限定的路径或相对于默认工作目录的路径。


Inline - 内联脚本
string。 可选。 当 ScriptType = InlineScript时使用。 默认值:# You can write your azure powershell scripts inline here. \n# You can also pass predefined and custom variables to this script using arguments

指定要执行的脚本。 支持的最大内联脚本长度为 5000 个字符。 如果要使用较长的脚本,请使用文件中的脚本。


ScriptArguments - 脚本参数
string。 可选。 当 ScriptType = FilePath时使用。

要传递给 PowerShell 的其他参数。 这些参数可以是序号参数,也可以是命名参数。


errorActionPreference - ErrorActionPreference
string。 允许的值:stopcontinuesilentlyContinue。 默认值:stop

选择用于执行脚本的 ErrorActionPreference 变量的值。


标准错误FailOnStandardError - 失败
boolean。 默认值:false

如果为 true,则如果向错误管道写入任何错误,或者将任何数据写入标准错误流,则此任务将失败。


azurePowerShellVersion - Azure PowerShell 版本
输入别名TargetAzurePs. string。 允许的值:LatestVersion(最新版本),OtherVersion(指定其他版本)。 默认值:OtherVersion

对于托管代理,支持的 Azure PowerShell 版本 2.1.03.8.04.2.15.1.16.7.0。 若要选择代理上可用的最新版本,请选择 LatestVersion(最新安装的版本)。

对于专用代理,可以使用 OtherVersion(指定其他版本)指定首选版本的 Azure PowerShell。


preferredAzurePowerShellVersion - 首选 Azure PowerShell 版本
输入别名CustomTargetAzurePs. stringTargetAzurePs = OtherVersion时是必需的。

首选的 Azure PowerShell 版本需要是适当的语义版本,例如。 1.2.3.。 不支持正则表达式(如 2.\*,2.3.\*)。 托管代理目前支持 Azure 模块版本 2.1.03.8.04.2.15.1.1 和 AzureRM 模块版本 2.1.03.8.04.2.15.1.16.7.0


validateScriptSignature - 验证脚本签名
boolean。 可选。 当 ScriptType = FilePath时使用。 默认值:false

如果为 true,则任务将首先检查以确保指定的脚本已签名并有效,然后再执行它。


任务控制选项

除任务输入之外,所有任务都具有控制选项。 有关详细信息,请参阅 控件选项和常见任务属性

输出变量

没有。

注解

添加了对标准错误和 ErrorActionPreference 失败的支持。

要求

要求 说明
管道类型 YAML,经典版本,经典版本
运行时间 代理,DeploymentGroup
需求 自承载代理必须具有 功能, 满足以下 要求, 运行使用此任务的作业:
功能 此任务不满足作业中后续任务的任何要求。
命令限制 任何
Settable 变量 任何
代理版本 2.0.0 或更高版本
任务类别 部署