LoginSignup
0
0

Azure Static Web AppsにNextjsをAzure DevOps Pipelinesからデプロイ

Last updated at Posted at 2024-01-12

Azure Static Web Apps(SWA)とは

Freeプランでも十分使え、NextjsではプレビューステータスですがSSR,SSG,ISRも動作するというかなりいい感じなサービスです

SWAリソースの作成

デプロイの詳細はその他で作っておきます

image.png

デプロイ

Reposで作成したブランチを任意のタイミングで手動でデプロイすることを想定しています

pipelines.yml
trigger: none

pool:
  vmImage: ubuntu-latest

steps:
- checkout: self
  submodules: true
- task: AzureStaticWebApp@0
  inputs:
    app_location: "."
    azure_static_web_apps_api_token: $(DEPLOYMENT_TOKEN)

トークンは「デプロイトークンの管理」から取得し、Pipelinesの変数に設定しています
image.png

注意が必要なのは2024/01現在SWAはNodejsの18系までしか対応していないため、package.jsonのenginesで明示的にバージョンを指定する必要があります

package.json
{
  "engines": {
    "node": "18.x"
  }
}

デプロイにはサイズ制限があるためstandaloneモードにすることを忘れずに

next.config.js
/** @type {import('next').NextConfig} */
const nextConfig = {
  output: 'standalone'
}
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0