デプロイ戦略を使用すると、更新プログラムの配信方法を構成できます。
この定義を参照する定義: jobs.deployment
実装
| 実装 | 説明 | 
|---|---|
| 戦略: runOnce | デプロイ戦略を 1 回実行します。 | 
| 戦略: ローリング | ローリング デプロイ戦略。 | 
| 戦略: カナリア | カナリアデプロイ戦略。 | 
注釈
アプリケーションの更新プログラムを展開する場合、更新プログラムの配信に使用する手法は次のことが重要です。
- 初期化を有効にする。
 - 更新プログラムをデプロイする。
 - 更新されたバージョンにトラフィックをルーティングする。
 - トラフィックのルーティング後に更新されたバージョンをテストする。
 - エラーが発生した場合は、最新の正常なバージョンに復元する手順を実行します。
 
これを実現するには、デプロイ中にステップを実行できるライフサイクル フックを使用します。 各ライフサイクル フックは、プール属性に応じて、エージェント ジョブまたはサーバー ジョブ (または将来的にはコンテナーまたは検証ジョブ) に解決されます。 既定では、ライフサイクル フックはデプロイ ジョブで指定されたプールを継承します。
デプロイ ジョブで $(Pipeline.Workspace) system variable. を使用する
セルフホステッド エージェントを使用している場合は、ワークスペースのクリーン オプションを使用してデプロイ ワークスペースをクリーンアップできます。
  jobs:
  - deployment: deploy
    pool:
      vmImage: ubuntu-latest
      workspace:
        clean: all
    environment: staging
strategy: runOnce
runOnce 配置戦略では、各手順を 1 回実行して変更をロールアウトします。
strategy:
  runOnce: # RunOnce Deployment strategy.
    preDeploy: # Pre deploy hook for runOnce deployment strategy.
      steps: [ task | script | powershell | pwsh | bash | checkout | download | downloadBuild | getPackage | publish | template | reviewApp ] # A list of steps to run.
      pool: string | pool # Pool where pre deploy steps will run.
    deploy: # Deploy hook for runOnce deployment strategy.
      steps: [ task | script | powershell | pwsh | bash | checkout | download | downloadBuild | getPackage | publish | template | reviewApp ] # A list of steps to run.
      pool: string | pool # Pool where deploy steps will run.
    routeTraffic: # Route traffic hook for runOnce deployment strategy.
      steps: [ task | script | powershell | pwsh | bash | checkout | download | downloadBuild | getPackage | publish | template | reviewApp ] # A list of steps to run.
      pool: string | pool # Pool where route traffic steps will run.
    postRouteTraffic: # Post route traffic hook for runOnce deployment strategy.
      steps: [ task | script | powershell | pwsh | bash | checkout | download | downloadBuild | getPackage | publish | template | reviewApp ] # A list of steps to run.
      pool: string | pool # Pool where post route traffic steps will run.
    on: # On success or failure hook for runOnce deployment strategy.
      failure: # Runs on failure of any step.
        steps: [ task | script | powershell | pwsh | bash | checkout | download | downloadBuild | getPackage | publish | template | reviewApp ] # A list of steps to run.
        pool: string | pool # Pool where post on failure steps will run.
      success: # Runs on success of all of the steps.
        steps: [ task | script | powershell | pwsh | bash | checkout | download | downloadBuild | getPackage | publish | template | reviewApp ] # A list of steps to run.
        pool: string | pool # Pool where on success steps will run.
特性
jobs.deployment.strategy.runOnceを runOnceします。
RunOnce 配置戦略  します。
注釈
              runOnce は、すべてのライフサイクル フック (preDeploydeploy、routeTraffic、postRouteTraffic) が 1 回実行される最も簡単なデプロイ戦略です。 次に、on: success または on: failure が実行されます。
戦略: ローリング
ローリング デプロイは、アプリケーションの以前のバージョンのインスタンスを、各イテレーションの固定された仮想マシン (ローリング セット) 上の新しいバージョンのアプリケーションのインスタンスに置き換えます。
strategy:
  rolling: # Rolling Deployment strategy.
    maxParallel: string # Maximum number of jobs running in parallel.
    preDeploy: # Pre deploy hook for rolling deployment strategy.
      steps: [ task | script | powershell | pwsh | bash | checkout | download | downloadBuild | getPackage | publish | template | reviewApp ] # A list of steps to run.
      pool: string | pool # Pool where pre deploy steps will run.
    deploy: # Deploy hook for rolling deployment strategy.
      steps: [ task | script | powershell | pwsh | bash | checkout | download | downloadBuild | getPackage | publish | template | reviewApp ] # A list of steps to run.
      pool: string | pool # Pool where deploy steps will run.
    routeTraffic: # Route traffic hook for rolling deployment strategy.
      steps: [ task | script | powershell | pwsh | bash | checkout | download | downloadBuild | getPackage | publish | template | reviewApp ] # A list of steps to run.
      pool: string | pool # Pool where route traffic steps will run.
    postRouteTraffic: # Post route traffic hook for rolling deployment strategy.
      steps: [ task | script | powershell | pwsh | bash | checkout | download | downloadBuild | getPackage | publish | template | reviewApp ] # A list of steps to run.
      pool: string | pool # Pool where post route traffic steps will run.
    on: # On success or failure hook for rolling deployment strategy.
      failure: # Runs on failure of any step.
        steps: [ task | script | powershell | pwsh | bash | checkout | download | downloadBuild | getPackage | publish | template | reviewApp ] # A list of steps to run.
        pool: string | pool # Pool where post on failure steps will run.
      success: # Runs on success of all of the steps.
        steps: [ task | script | powershell | pwsh | bash | checkout | download | downloadBuild | getPackage | publish | template | reviewApp ] # A list of steps to run.
        pool: string | pool # Pool where on success steps will run.
特性
jobs.deployment.strategy.rollingを rollingします。
ローリング デプロイ戦略を  します。
戦略: カナリア
カナリア展開戦略では、変更をサーバーの小さなサブセットにロールアウトします。
strategy:
  canary: # Canary Deployment strategy.
    increments: [ string ] # Maximum batch size for deployment.
    preDeploy: # Pre deploy hook for canary deployment strategy.
      steps: [ task | script | powershell | pwsh | bash | checkout | download | downloadBuild | getPackage | publish | template | reviewApp ] # A list of steps to run.
      pool: string | pool # Pool where pre deploy steps will run.
    deploy: # Deploy hook for canary deployment strategy.
      steps: [ task | script | powershell | pwsh | bash | checkout | download | downloadBuild | getPackage | publish | template | reviewApp ] # A list of steps to run.
      pool: string | pool # Pool where deploy steps will run.
    routeTraffic: # Route traffic hook for canary deployment strategy.
      steps: [ task | script | powershell | pwsh | bash | checkout | download | downloadBuild | getPackage | publish | template | reviewApp ] # A list of steps to run.
      pool: string | pool # Pool where route traffic steps will run.
    postRouteTraffic: # Post route traffic hook for canary deployment strategy.
      steps: [ task | script | powershell | pwsh | bash | checkout | download | downloadBuild | getPackage | publish | template | reviewApp ] # A list of steps to run.
      pool: string | pool # Pool where post route traffic steps will run.
    on: # On success or failure hook for canary deployment strategy.
      failure: # Runs on failure of any step.
        steps: [ task | script | powershell | pwsh | bash | checkout | download | downloadBuild | getPackage | publish | template | reviewApp ] # A list of steps to run.
        pool: string | pool # Pool where post on failure steps will run.
      success: # Runs on success of all of the steps.
        steps: [ task | script | powershell | pwsh | bash | checkout | download | downloadBuild | getPackage | publish | template | reviewApp ] # A list of steps to run.
        pool: string | pool # Pool where on success steps will run.
特性
jobs.deployment.strategy.canaryを canaryします。
カナリアデプロイ戦略  します。
注釈
カナリアデプロイ戦略は、新しいバージョンのアプリケーションのロールアウトに伴うリスクを軽減するのに役立つ高度なデプロイ戦略です。 この戦略を使用すると、最初にサーバーの小さなサブセットに変更をロールアウトできます。 新バージョンへの信頼度が上がってきたら、インフラストラクチャ内のより多くのサーバーにリリースし、より多くのトラフィックをルーティングすることができます。