0
1

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 3 years have passed since last update.

.NET 6 Preview on App Service を試してみた

Posted at

背景と目的

Azure CLI で .NET 6 ランタイムの App Service が作れるようになったようなので、実際に試してみました。

前提条件

.NET 6 環境は、.Net 6.0.0 Preview 2 を Visual Studio Code から Docker 利用してみた で作成した環境を使用します。

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

zsh
% sw_vers
ProductName:    macOS
ProductVersion: 11.4
BuildVersion:   20F71

% az version
{
  "azure-cli": "2.24.2",
  "azure-cli-core": "2.24.2",
  "azure-cli-telemetry": "1.0.6",
  "extensions": {}
}

実施内容

.NET 6 MVC でランタイム情報を表示するアプリを作成します。

bash
$ dotnet --version
6.0.100-preview.4.21255.9

$ dotnet new mvc -n mvcapp

$ cd mvcapp

$ cat << EOF > Views/Home/Index.cshtml
@using System.Runtime.InteropServices
@{
    ViewData["Title"] = "Home";
}
<div class="text-center">
    <h5>Environment</h5>
    <p>@RuntimeInformation.FrameworkDescription (@RuntimeInformation.ProcessArchitecture)</p>
    <p>@RuntimeInformation.OSDescription</p>
</div>
EOF

$ dotnet dev-certs https

$ dotnet run

https://localhost:5001

Ctrl+C

.NET 6 MVC アプリのディレクトリに移動して、Windows と Linux の App Service をそれぞれ作成します。なお、共同作成者権限でリソースグループの作成から App Service Plan と App Service の作成、カレントディレクトリの .NET 6 MVC アプリのアップロードまで、一連のリソース作成を一つのコマンドで実行します。

zsh
# 環境変数を設定します
region=southeastasia
prefix=mnrdndev

# Windows の App Service を作成します
az webapp up \
  --resource-group ${prefix}-win-rg \
  --location $region \
  --plan ${prefix}-win-plan \
  --name ${prefix}-win \
  --runtime "DOTNET|6.0" \
  --os-type Windows \
  --sku F1

# 同じソースコードで Linux の App Service を試すので、Windows の App Service の情報を消します
rm -rf .azure

# Linux の App Service を作成します
az webapp up \
  --resource-group ${prefix}-lnx-rg \
  --location $region \
  --plan ${prefix}-lnx-plan \
  --name ${prefix}-lnx \
  --runtime "DOTNET|6.0" \
  --os-type Linux \
  --sku F1

実施結果

Windows の App Service で表示されるランタイム情報です。

dotnet6-appservice-01.png

Linux の App Service で表示されるランタイム情報です。

dotnet6-appservice-02.png

参考

Azure CLI Release notes May 25, 2021

.NET 6 Preview on App Service

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?