AzurePowerShell@4 - Azure PowerShell v4 工作

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

Syntax

# 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.
# 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.

輸入

azureSubscription - Azure 訂用帳戶
輸入別名: ConnectedServiceNameARMstring. 必要。

執行 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

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


RestrictContextToCurrentTask - 將內容約制限制為目前工作
boolean. 預設值:false

當此為 true 時,此工作只會將內容約制限制為目前的工作,而且使用私人代理程式時,管線中的其他工作將無法使用內容。


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

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

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


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

慣用Azure PowerShell版本必須是適當的語意版本,例如 1.2.3. 不支援類似 Regex 2.\*,2.3.\* 。 託管 VS2017 集區目前支援 Az 模組版本 1.0.0.


pwsh - 使用 PowerShell Core
boolean. 預設值:false

如果這是 true,則 Windows 上的工作會從您的路徑使用 pwsh.exe ,而不是 powershell.exe


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

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


workingDirectory - 工作目錄
string.

執行腳本的工作目錄。


工作控制選項

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

輸出變數

無。

備註

已新增 Az Module 和跨平臺代理程式的支援。

規格需求

需求 描述
管線類型 YAML、傳統組建、傳統版本
在 上執行 Agent、DeploymentGroup
要求
Capabilities 此工作不符合作業中後續工作的任何需求。
命令限制 任意
可設定變數 任意
代理程式版本 2.115.0 或更新版本
工作類別 部署