AzurePowerShell@3 - Azure PowerShell v3 工作

使用此工作在 Azure 環境中執行 PowerShell 腳本。 Azure 內容會使用提供的 Azure Resource Manager服務連線進行驗證。

Syntax

# 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 連線類型
輸入別名: ConnectedServiceNameSelectorstring. 允許的值: ConnectedServiceName (Azure 傳統) , ConnectedServiceNameARM (Azure Resource Manager) 。 預設值:ConnectedServiceNameARM


azureClassicSubscription - Azure 傳統訂用帳戶
輸入別名: ConnectedServiceNamestring. 當 ConnectedServiceNameSelector = ConnectedServiceName 時為必要。

執行 PowerShell 之前要設定的 Azure 傳統訂用帳戶。


azureSubscription - Azure 訂用帳戶
輸入別名: ConnectedServiceNameARMstring. 當 ConnectedServiceNameSelector = ConnectedServiceNameARM 時為必要。

執行 PowerShell 之前要設定的 Azure Resource Manager訂用帳戶。


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

如果有任何錯誤寫入錯誤管線,或將任何資料寫入標準錯誤資料流程,則此工作將會失敗。


azurePowerShellVersion - Azure PowerShell版本
輸入別名: TargetAzurePsstring. 允許的值: LatestVersion (最新安裝的版本) , OtherVersion (指定其他版本) 。 預設值:OtherVersion

如果裝載的代理程式,支援的Azure PowerShell版本為 2.1.03.8.04.2.15.1.16.7.0 。 若要挑選代理程式上可用的最新版本,請選取 LatestVersion [ (最新安裝的版本) 。

針對私人代理程式,您可以使用 (指定其他版本) 指定慣用 OtherVersion 版本的Azure PowerShell。


preferredAzurePowerShellVersion - 慣用Azure PowerShell版本
輸入別名: CustomTargetAzurePsstring. 當 TargetAzurePs = OtherVersion 時為必要。

慣用Azure PowerShell版本必須是適當的語意版本,例如 1.2.3.. 不支援 Regex,例如 2.\*,2.3.\* 。 裝載的代理程式目前支援 Azure 模組版本 2.1.03.8.04.2.15.1.1 和 AzureRM 模組版本 2.1.0 、、 3.8.04.2.1 、、 5.1.16.7.0


validateScriptSignature - 驗證腳本簽章
boolean. 選擇性。 使用 時機 ScriptType = FilePath 。 預設值:false

如果這是 true,則工作會先檢查以確定指定的腳本已簽署且在執行之前有效。


工作控制選項

除了工作輸入之外,所有工作都有控制選項。 如需詳細資訊,請參閱 控制項選項和一般工作屬性

輸出變數

無。

備註

已新增對標準錯誤和 ErrorActionPreference 失敗的支援。

規格需求

需求 描述
管線類型 YAML、傳統組建、傳統版本
執行于 Agent、DeploymentGroup
要求 自我裝載代理程式必須具備符合下列需求的功能,才能執行使用此工作的作業:azureps
Capabilities 此工作不符合作業中後續工作的任何需求。
命令限制 任意
Settable 變數 任意
代理程式版本 2.0.0 或更新版本
工作類別 部署