次の方法で共有


AzurePowerShell@4 - Azure PowerShell v4 タスク

このタスクを使用して、Azure 環境内で PowerShell スクリプトを実行します。 Azure コンテキストは、指定された Azure Resource Manager サービス接続で認証されます。

構文

# 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 サブスクリプションazureSubscription -
入力エイリアス: ConnectedServiceNameARMstring。 必須。

PowerShell を実行する前に構成する Azure Resource Manager サブスクリプション。


ScriptType - スクリプトの種類
string。 使用できる値: FilePath (スクリプト ファイル パス)、InlineScript (インライン スクリプト)。 既定値: FilePath.

スクリプトの種類: ファイル パスまたはインライン。


ScriptPath - スクリプト パスの
string。 任意 ScriptType = FilePathするときに使用します。

スクリプトのパス。 これは、完全修飾パス、または既定の作業ディレクトリに対する相対パスである必要があります。


インライン スクリプト の
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.

実行するスクリプトを指定します。 サポートされるインライン スクリプトの最大長は 5,000 文字です。 より長いスクリプトを使用する場合は、ファイルのスクリプトを使用します。


ScriptArguments - スクリプト引数の
string。 任意 ScriptType = FilePathするときに使用します。

PowerShell に渡す追加のパラメーター。 序数パラメーターまたは名前付きパラメーターを指定できます。


errorActionPreference - ErrorActionPreference (エラーアクションプリファレンス)
string。 使用できる値: stopcontinuesilentlyContinue。 既定値: stop.

スクリプトを実行するための ErrorActionPreference 変数の値を選択します。


標準エラーで失敗する FailOnStandardError -
boolean。 既定値: false.

これが true の場合、エラーがエラー パイプラインに書き込まれたり、データが標準エラー ストリームに書き込まれたりすると、このタスクは失敗します。


RestrictContextToCurrentTask - コンテキストのスコープを現在のタスク に制限する
boolean。 既定値: false.

これが当てはまる場合、このタスクはコンテキストのスコープを現在のタスクのみに制限し、プライベート エージェントを使用する場合、パイプライン内の他のタスクではコンテキストを使用できなくなります。


azurePowerShellVersion - Azure PowerShell バージョン
入力エイリアス: TargetAzurePsstring。 使用できる値: LatestVersion (インストールされている最新バージョン)、OtherVersion (他のバージョンを指定します)。 既定値: OtherVersion.

ホストされているエージェントの場合、サポートされている Azure PowerShell バージョンは 1.0.0 (ホステッド VS2017 キュー) です。 エージェントで使用可能な最新バージョンを選択するには、LatestVersion (インストールされている最新バージョン) を選択します。

プライベート エージェントの場合は、OtherVersion を使用して Azure PowerShell の優先バージョンを指定できます (他のバージョンを指定します)。


推奨される Azure PowerShell バージョンpreferredAzurePowerShellVersion - する
入力エイリアス: CustomTargetAzurePsstringTargetAzurePs = OtherVersionする場合に必要です。

推奨される Azure PowerShell バージョンは、たとえば適切なセマンティック バージョンである必要があります。 1.2.3. 正規表現 (2.\*,2.3.\* など) はサポートされていません。 Hosted VS2017 プールでは現在、Az モジュール バージョン 1.0.0. がサポートされています


PowerShell Coreを使用する pwsh -
boolean。 既定値: false.

これが当てはまる場合、Windows では、タスクはパスから pwsh.exe を使用し、powershell.exeの代わりに使用します。


validateScriptSignature - スクリプト署名の検証
boolean。 任意 ScriptType = FilePathするときに使用します。 既定値: false.

これが true の場合、タスクは最初に、指定されたスクリプトが署名され、有効であることを確認してから実行します。


workingDirectory - 作業ディレクトリの
string

スクリプトが実行される作業ディレクトリ。


タスク コントロールのオプション

すべてのタスクには、タスク入力に加えて制御オプションがあります。 詳細については、「コントロール オプションと一般的なタスク プロパティを参照してください。

出力変数

なし。

注釈

Az Module およびクロス プラットフォーム エージェントのサポートを追加しました。

必要条件

要件 説明
パイプラインの種類 YAML、クラシック ビルド、クラシック リリース
実行日 エージェント、DeploymentGroup
の需要 なし
機能の このタスクは、ジョブ内の後続のタスクに対する要求を満たしていません。
コマンドの制限 どれでも
設定可能な変数 どれでも
エージェントのバージョン 2.115.0 以上
タスク カテゴリ 展開