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

More than 1 year has passed since last update.

Azure App Service ゾーン冗長を Azure CLI で作ってみた

Posted at

背景と目的

Azure App Service のゾーン冗長が使えるようになった当初は ARM テンプレートからのデプロイしかサポートしていませんでしたが、いつの間にか Azure CLI でもデプロイ出来るようになっていたので、実際に作ってみました。

前提条件

コマンドの実施環境は、Mac + Azure CLI です。

bash
$ sw_vers
ProductName:    macOS
ProductVersion: 12.4
BuildVersion:   21F79

$ az version
{
  "azure-cli": "2.37.0",
  "azure-cli-core": "2.37.0",
  "azure-cli-telemetry": "1.0.6",
  "extensions": {}
}

ゾーン冗長の Azure Web App for Containers を作成

bash
# 環境変数をセットします
region=japaneast
prefix=mnrappzr

# リソースグループを作成します
az group create \
  --name ${prefix}-rg \
  --location $region

# App Service Plan を作成します
az appservice plan create \
  --name ${prefix}plan \
  --resource-group ${prefix}-rg \
  --zone-redundant \
  --number-of-workers 3 \
  --sku P1V3 \
  --is-linux

# ゾーン冗長が true になっている事を確認します
az appservice plan show \
  --name ${prefix}plan \
  --resource-group ${prefix}-rg \
  --query properties.zoneRedundant \
  --output tsv

# Azure Web App for Containers を作成します
az webapp create \
  --name ${prefix}app \
  --resource-group ${prefix}-rg \
  --plan ${prefix}plan \
  --deployment-container-image-name mcr.microsoft.com/azuredocs/aci-helloworld

# (任意)コンテナのポート番号が 80 以外の場合は下記コマンドで Web App に設定します
az webapp config appsettings set \
  --name ${prefix}app \
  --resource-group ${prefix}-rg \
  --settings WEBSITES_PORT=80

# App Service のログを確認します
az webapp log tail \
  --name ${prefix}app \
  --resource-group ${prefix}-rg

# 以下のようなログが出力されます
2022-06-11T00:33:07.477Z INFO  - Pulling image: mcr.microsoft.com/azuredocs/aci-helloworld
2022-06-11T00:33:07.655Z INFO  - latest Pulling from azuredocs/aci-helloworld
2022-06-11T00:33:07.655Z INFO  -  Digest: sha256:565dba8ce20ca1a311c2d9485089d7ddc935dd50140510050345a1b0ea4ffa6e
2022-06-11T00:33:07.655Z INFO  -  Status: Image is up to date for mcr.microsoft.com/azuredocs/aci-helloworld:latest
2022-06-11T00:33:07.657Z INFO  - Pull Image successful, Time taken: 0 Minutes and 0 Seconds
2022-06-11T00:33:07.667Z INFO  - Starting container for site
2022-06-11T00:33:07.667Z INFO  - docker run -d --expose=80 --name mnrappzrapp_1_61b782a0 -e WEBSITES_ENABLE_APP_SERVICE_STORAGE=false -e WEBSITE_SITE_NAME=mnrappzrapp -e WEBSITE_AUTH_ENABLED=False -e PORT=80 -e WEBSITE_ROLE_INSTANCE_ID=0 -e WEBSITE_HOSTNAME=mnrappzrapp.azurewebsites.net -e WEBSITE_INSTANCE_ID=59a138cde462da5311cd196f76bac28953c332522546684d6109711df53d819e -e WEBSITE_USE_DIAGNOSTIC_SERVER=False mcr.microsoft.com/azuredocs/aci-helloworld  
2022-06-11T00:33:07.667Z INFO  - Logging is not enabled for this container.
2022-06-11T00:33:08.852Z INFO  - Initiating warmup request to container mnrappzrapp_1_61b782a0 for site mnrappzrapp
2022-06-11T00:33:09.872Z INFO  - Container mnrappzrapp_1_61b782a0 for site mnrappzrapp initialized successfully and is ready to serve requests.

# Web App にアクセスして「Welcome to Azure Container Instances!」が表示される事を確認します
az webapp browse \
  --name ${prefix}app \
  --resource-group ${prefix}-rg

参考

bash
# リソースグループを削除します
az group delete \
  --name ${prefix}-rg \
  --yes

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?