LoginSignup
0
0

Mac 環境の .NET 8 で GA した Azure Functions を試してみた

Posted at

.NET 8 と .NET 8 対応の Azure Functions が GA (一般提供開始) したので、さっそく試してみました。現時点では、.NET 6 の Azure Fnctions を使っていた自分からしたら、いろんなパラメータを .NET 8 用に追加する必要があって、少々面倒でした。

Azure Functions Core Tools の最新バージョンを導入

brew でインストールしている azure-functions-core-tools@4 は、まだ .NET 8 に対応していませんでした。そこで、GitHub から最新のビルドをダウンロードしてインストールする事にしました。

zsh
% wget https://github.com/Azure/azure-functions-core-tools/releases/download/4.0.5455/Azure.Functions.Cli.osx-arm64.4.0.5455.zip

% unzip Azure.Functions.Cli.osx-arm64.4.0.5455.zip -d functools.4.0.5455

% export PATH=$HOME/functools.4.0.5455:$PATH

% chmod 755 $HOME/functools.4.0.5455/{func,gozip}

% func --version
4.0.5455

ローカルで Azure Functions アプリを作成

zsh
% dotnet --version
8.0.100

% func init mnrdn8 --worker-runtime dotnetIsolated --target-framework net8.0

% cd mnrdn8

% func new --name test --template 'Http Trigger' --authlevel anonymous

% func start

分離ワーカーの .NET 8 設定で Azure Functions 構築

bash
prefix=mnrdn8
region=japaneast

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

az storage account create \
  --name ${prefix}stor \
  --resource-group ${prefix}-rg \
  --sku Standard_LRS

az functionapp create \
  --name ${prefix} \
  --resource-group ${prefix}-rg \
  --consumption-plan-location $region \
  --runtime dotnet-isolated \
  --runtime-version 8 \
  --functions-version 4 \
  --storage-account ${prefix}stor \
  --disable-app-insights \
  --https-only \
  --os-type Linux \
  --assign-identity

アプリをデプロイして動作確認

bash
func azure functionapp publish ${prefix} --dotnet-version 8.0

curl https://${prefix}.azurewebsites.net/api/test

# curl のレスポンスコンテンツ
Welcome to Azure Functions!

検証が終わったら Azure Functions 環境を削除

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