1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Azureにdocker-composeでNode-REDのインスタンスを作っておくときメモ

Last updated at Posted at 2025-05-10

Azureにdocker-composeでNode-REDのインスタンスを作っておくときメモ

Node-REDのインスタンスを作るメモです。

流れとイメージ

  • リソースグループの作成
  • サービスプランの作成
  • インスタンスの作成

リソースグループが一番大きなフォルダ、
サービスプランを1つのフォルダとしてサービスプランの中にインスタンスがぶら下がっているイメージ。

サービスプランひとつにたくさんのインスタンスのぶらさげたらCPU負荷がやばかったので安いプランを使うときはサービスプランの中に大量インスタンス作成を避けておく。

準備

リソースグループとサービスプランは事前にあればそれを使うでもOKだけど1から作る場合メモです。

リソースグループを作っておく

管理用にリソースグループを作っておきます。

普段は管理画面からやりますがメモ的に。

$ az group create --name myResourceGroup --location japaneast
{
  "id": "/subscriptions/xxxxxxxxxxxxxxxxxxxxx/resourceGroups/2025-protoout",
  "location": "japaneast",
  "managedBy": null,
  "name": "2025-protoout",
  "properties": {
    "provisioningState": "Succeeded"
  },
  "tags": null,
  "type": "Microsoft.Resources/resourceGroups"
}

サービスプランを作っておく

az appservice plan create --name プラン名 --resource-group リソースグループ名 --sku スケールプラン --location リージョン

こんな感じ B1で作る場合は以下のような感じ

az appservice plan create --name myLinuxPlan --resource-group myResourceGroup --sku B1 --is-linux --location japaneast
{
  "elasticScaleEnabled": false,
  "extendedLocation": null,
  "freeOfferExpirationTime": "2025-06-09T08:20:26.423333",
  "geoRegion": "Japan East",
  "hostingEnvironmentProfile": null,
  "hyperV": false,
  "id": "/subscriptions/xxxxxxxxxxxxx/resourceGroups/2025-protoout/providers/Microsoft.Web/serverfarms/myLinuxPlan",
  "isSpot": false,
  "isXenon": false,
  "kind": "linux",
  "kubeEnvironmentProfile": null,
  "location": "japaneast",
  "maximumElasticWorkerCount": 1,
  "maximumNumberOfWorkers": 0,
  "name": "myLinuxPlan",
  "numberOfSites": 0,
  "numberOfWorkers": 1,
  "perSiteScaling": false,
  "provisioningState": "Succeeded",
  "reserved": true,
  "resourceGroup": "2025-protoout",
  "sku": {
    "capabilities": null,
    "capacity": 1,
    "family": "B",
    "locations": null,
    "name": "B1",
    "size": "B1",
    "skuCapacity": null,
    "tier": "Basic"
  },
  "spotExpirationTime": null,
  "status": "Ready",
  "subscription": "xxxxxxxxxxx",
  "tags": null,
  "targetWorkerCount": 0,
  "targetWorkerSizeId": 0,
  "type": "Microsoft.Web/serverfarms",
  "workerTierName": null,
  "zoneRedundant": false
}

docker-compors.ymlを作成

docker-compose.ymlを用意。

現状のNode-REDは最新がv4.0.9ぽいです。 バージョンにあわせて用意

version: "3.8"

services:
  node-red:
    image: nodered/node-red-dev:v4.0.9
    volumes:
      - ${WEBAPP_STORAGE_HOME}/Data:/data
    stdin_open: true
    tty: true

インスタンスの作成

az webapp create --resource-group $resource_group --plan $app_service_plan --name $webapp_name --multicontainer-config-type compose --multicontainer-config-file docker-compose.yml

さっき2025-protooutというリソースグループ、myLinuxPlanというサービスプランを作ったのでここにnode-red-appという名前でインスタンスを作成

az webapp create --resource-group 2025-protoout --plan myLinuxPlan --name node-red-app --multicontainer-config-type compose --multicontainer-config-file docker-compose.yml
{
  "availabilityState": "Normal",
  "clientAffinityEnabled": true,
  "clientCertEnabled": false,
  "clientCertExclusionPaths": null,
  "clientCertMode": "Required",
  "cloningInfo": null,
  "containerSize": 0,
  "customDomainVerificationId": "",
  "dailyMemoryTimeQuota": 0,
  "daprConfig": null,
  "defaultHostName": "node-red-app.azurewebsites.net",
  "enabled": true,
  "enabledHostNames": [

省略

}

永続化 - WEBSITES_ENABLE_APP_SERVICE_STORAGEの設定

WebAppsでのNode-REDの場合ここの設定をしないと永続化ができず再起動などをしたときに初期化されちゃいます。

設定でWEBSITES_ENABLE_APP_SERVICE_STORAGEtrueにしたいですが、これもコマンドから実行できます。

az webapp config appsettings set --resource-group $resource_group --name $webapp_name --settings WEBSITES_ENABLE_APP_SERVICE_STORAGE=true

常時接続をON

エディターが途中で落ちちゃう可能性を回避したいので常時接続設定もONにします。

az webapp config set --resource-group $resource_group --name $webapp_name --always-on true

無事に起動

CleanShot 2025-05-10 at 17.47.17.png

Azureでdocker-composeのサポートが終了らしい

2027年だからまだ先だけどサイドカーに移行とのこと。サイドカー初めて知りました。

参考記事

1
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
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?