背景
リリース作業の一連のパイプラインの中で、AppServiceのスロットスワップが手動で行う必要があった
⇒
AppServiceのスロットスワップもパイプラインから実施する
対応
スワップ用のパイプラインを作成
下記yamlを定義する。
parameters:
- name: TargetSlot
displayName: TargetSlot
type: string
default: stage
values:
- stage
- sorry
- production
- name: SourceSlot
displayName: SourceSlot
type: string
default: stage
values:
- stage
- sorry
- production
# Azureリソースのスワップ
steps:
- task: AzureAppServiceManage@0
displayName: スロットのスワップ
inputs:
azureSubscription: xxxxx
Action: Swap Slots
SwapWithProduction: false
WebAppName: xxxxx
ResourceGroupName: xxxxx
TargetSlot: ${{ parameters.TargetSlot }}
SourceSlot: ${{ parameters.SourceSlot }}
parameters
をパイプライン実行時に指定することで、スワップ対象のスロットを選択できるようにしている。
(パイプライン実行時に↓こんな感じで選べる)
※AzurePortal側の環境変数の設定で「デプロイスロットの設定」にチェックがついていない環境変数はスワップ時に置いてかれます。。
参考