概要
前回は、Bicepを使ってのリソース構築を行った。
今回は、AzureDevOpsのパイプラインからのデプロイを行う。
ファイル構成
毎回動く必要はないので、infrastructure
フォルダ以下のファイルに変更があったときのみ動作するトリガー設定をした。
- azure-dev-ops
- app-deploy-pipelines.yaml
- iac-pipelines.yaml
- infrastructure
- bin
- create.bash
- biceps
- resourceGrop.bicep
- staticWebApp.bicep
パイプライン
azure-dev-ops/iac-pipelines.yaml
trigger:
branches:
include:
- main
paths:
include:
- infrastructure/*
- azure-dev-ops/iac-pipelines.yaml
pool:
vmImage: ubuntu-latest
steps:
- task: AzureCLI@2
inputs:
azureSubscription: 'azure-dev-hobby'
scriptType: 'bash'
scriptLocation: 'scriptPath'
scriptPath : 'infrastructure/bin/create.bash'
azureSubscription の設定
Create an Azure Resource Manager service connection that uses workload identity federation
- Azure DevOps のプロジェクトに移動
- 左側のメニューから "Project settings" を選択
- "Service connections" を選択
- "New service connection" をクリック
Azure Resource Managerの設定を行う
Service connectin nameにazure-dev-hobby
を設定。
(パイプラインに記載したazureSubscription: 'azure-dev-hobby'
)
これで追加は完了
パイプラインを作成して実行
前々回と同様、既存のリポジトリに含まれるファイルをパイプラインに設定する。(azure-dev-ops/iac-pipelines.yaml
)
このとき、初回実行では許可を求められるので許可する。
これで、デプロイできた。