😀

Azure App Service をルートドメインで構築してみた

に公開

Azure App Service をルートドメインで構築した事がなかったので、試してみました。

検証環境構築

bash
prefix=mnrapptest
region=japaneast
domain=example.com

az group create \
  --name ${prefix}-rg \
  --location $region

az appservice plan create \
  --name ${prefix}-plan \
  --resource-group ${prefix}-rg \
  --is-linux \
  --sku B1

az webapp create \
  --name ${prefix} \
  --resource-group ${prefix}-rg \
  --plan ${prefix}-plan \
  --runtime "PHP|8.0" \
  --https-only true

az webapp config set \
  --name ${prefix} \
  --resource-group ${prefix}-rg \
  --always-on true \
  --ftps-state Disabled

「カスタムドメインの追加」で表示される下記レコードをDNSに追加

appservice-rootdomain-01.png

AppService にカスタムドメインとマネージド証明書を登録

bash
az webapp config hostname add \
  --webapp-name ${prefix} \
  --resource-group ${prefix}-rg \
  --hostname $domain

az webapp config ssl create \
  --resource-group ${prefix}-rg \
  --name ${prefix} \
  --hostname $domain

az webapp config ssl bind \
  --certificate-thumbprint $(az webapp config ssl show \
  --resource-group ${prefix}-rg \
  --certificate-name $domain \
  --query thumbprint \
  --output tsv) \
  --resource-group ${prefix}-rg \
  --name ${prefix} \
  --ssl-type SNI

参考

https://learn.microsoft.com/ja-jp/azure/app-service/app-service-web-tutorial-custom-domain?tabs=root%2Cazurecli

Discussion