使用此任务可在 Azure 环境中运行 PowerShell 脚本。 使用提供的 Azure 资源管理器服务连接对 Azure 上下文进行身份验证。
语法
# Azure PowerShell v4
# Run a PowerShell script within an Azure environment.
- task: AzurePowerShell@4
inputs:
azureSubscription: # string. Alias: ConnectedServiceNameARM. Required. 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.
#RestrictContextToCurrentTask: false # boolean. Restrict scope of context to current task. 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
#pwsh: false # boolean. Use PowerShell Core. Default: false.
#validateScriptSignature: false # boolean. Optional. Use when ScriptType = FilePath. Validate script signature. Default: false.
#workingDirectory: # string. Working Directory.
# Azure PowerShell v4
# Run a PowerShell script within an Azure environment.
- task: AzurePowerShell@4
inputs:
azureSubscription: # string. Alias: ConnectedServiceNameARM. Required. 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.
#RestrictContextToCurrentTask: false # boolean. Restrict scope of context to current task. 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
#pwsh: false # boolean. Use PowerShell Core. Default: false.
#workingDirectory: # string. Working Directory.
# Azure PowerShell v4
# Run a PowerShell script within an Azure environment.
- task: AzurePowerShell@4
inputs:
azureSubscription: # string. Alias: ConnectedServiceNameARM. Required. 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
#pwsh: false # boolean. Use PowerShell Core. Default: false.
#workingDirectory: # string. Working Directory.
输入
azureSubscription
-
Azure 订阅
输入别名: ConnectedServiceNameARM
.
string
。 必填。
运行 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
。 允许的值:stop
、continue
、silentlyContinue
。 默认值:stop
。
选择用于执行脚本的 ErrorActionPreference
变量的值。
标准错误FailOnStandardError
- 失败
boolean
。 默认值:false
。
如果为 true,则如果向错误管道写入任何错误,或者将任何数据写入标准错误流,则此任务将失败。
RestrictContextToCurrentTask
-
将上下文范围限制为当前任务
boolean
。 默认值:false
。
如果为 true,则此任务将上下文范围限制为仅当前任务,在使用专用代理时,该上下文将不适用于管道中的其他任务。
azurePowerShellVersion
-
Azure PowerShell 版本
输入别名: TargetAzurePs
.
string
。 允许的值:LatestVersion
(最新版本),OtherVersion
(指定其他版本)。 默认值:OtherVersion
。
对于托管代理,支持的 Azure PowerShell 版本为:1.0.0
(托管 VS2017 队列)。
若要选择代理上可用的最新版本,请选择 LatestVersion
(最新安装的版本)。
对于专用代理,可以使用 OtherVersion
(指定其他版本)指定首选版本的 Azure PowerShell。
preferredAzurePowerShellVersion
-
首选 Azure PowerShell 版本
输入别名: CustomTargetAzurePs
.
string
。
TargetAzurePs = OtherVersion
时是必需的。
首选的 Azure PowerShell 版本需要是适当的语义版本,例如。 不支持 1.2.3.
正则表达式(如 2.\*,2.3.\*
)。 托管 VS2017 池当前支持 Az 模块版本 1.0.0.
pwsh
-
使用 PowerShell Core
boolean
。 默认值:false
。
如果这是真的,则在 Windows 上,任务将使用路径中的 pwsh.exe
,而不是 powershell.exe
。
validateScriptSignature
-
验证脚本签名
boolean
。 可选。 当 ScriptType = FilePath
时使用。 默认值:false
。
如果为 true,则任务将首先检查以确保指定的脚本已签名并有效,然后再执行它。
workingDirectory
-
工作目录
string
。
运行脚本的工作目录。
任务控制选项
除任务输入之外,所有任务都具有控制选项。 有关详细信息,请参阅 控件选项和常见任务属性。
输出变量
没有。
注解
添加了对 Az Module 和跨平台代理的支持。