😀

Azure Functions でパブリックプレビューの Flex Consumption を Azure CLI で試

に公開

新しい Azure Functions ホスティングプランの Flex Consumption が発表されました。パブリックプレビューですが、既に Azure CLI でも使用できるようなので試してみました。

動作確認バージョン

bash
$ dotnet --version
8.0.100

$ func --version
4.0.5801

$ az version
{
  "azure-cli": "2.61.0",
  "azure-cli-core": "2.61.0",
  "azure-cli-telemetry": "1.1.0",
  "extensions": {}
}

検証用の Azure Functions Flex Consumption を作成

bash
prefix=mnrfna
region=eastus

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

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

az functionapp create \
  --name ${prefix} \
  --resource-group ${prefix}-rg \
  --flexconsumption-location $region \
  --instance-memory 2048 \
  --runtime dotnet-isolated \
  --storage-account ${prefix}sa \
  --disable-app-insights \
  --https-only \
  --assign-identity

Azure ポータルで Flex Consumption を確認

functions-flex-consumption-01.png

ローカルで検証用の Functions アプリを作成

bash
func init $prefix --worker-runtime dotnet-isolated --target-framework net8.0

cd $prefix

func new --name example --template HttpTrigger --authlevel anonymous

func start

検証用 Functions アプリをデプロイ

bash
func azure functionapp publish $prefix

Can't determine Project to build. Expected 1 .csproj or .fsproj but found 2 と表示されたので、ローカル環境をクリーンにしてからデプロイしなおしました。

bash
dotnet clean

func azure functionapp publish $prefix

動作確認

bash
$ curl https://$prefix.azurewebsites.net/api/example

Welcome to Azure Functions!

後片付け

bash
az group delete \
  --name ${prefix}-rg \
  --yes

参考

https://techcommunity.microsoft.com/t5/apps-on-azure-blog/azure-functions-microsoft-build-2024-update/ba-p/4146471

https://azure.microsoft.com/en-us/updates/public-preview-azure-functions-brings-new-flexibility-with-azure-functions-flex-consumption/

https://learn.microsoft.com/ja-jp/azure/azure-functions/flex-consumption-plan

https://learn.microsoft.com/ja-jp/cli/azure/functionapp?view=azure-cli-latest#az-functionapp-create-examples

Discussion