目次

インストール

Azure CLI (Mac)

brew update && brew install azure-cli

Azure Functions Core Tools (Mac)

https://docs.microsoft.com/ja-jp/azure/azure-functions/functions-run-local?tabs=macos%2Ccsharp%2Cbash

v2.x

brew tap azure/functions
brew install azure-functions-core-tools

v3.x

brew tap azure/functions
brew install azure-functions-core-tools@3
# if upgrading on a machine that has 2.x installed
brew link --overwrite azure-functions-core-tools@3

ログイン

az login

ローカルのストレージエミュレータを使用する場合
https://docs.microsoft.com/ja-jp/azure/developer/azure-cli/azure-cli-configuration#cli-configuration-values-and-environment-variables

export AZURE_STORAGE_CONNECTION_STRING="UseDevelopmentStorage=true"

※以降の az storage コマンドはローカルのエミュレータに対して発行される。

リージョン一覧の確認

az account list-locations -o table

Azure Function の開発

ローカル関数プロジェクトの作成

func init LocalFunctionProj --dotnet

関数をプロジェクトに追加

func new --name HttpExample --template "HTTP trigger"

関数をローカルで実行する

func start

関数をデプロイする

az functionapp deployment source config-zip -g リソースグループ -n 関数名 --src ZIPファイルPATH

参考
Azure Functions の zip デプロイ
Azure Functions のデプロイ テクノロジ

Premium プランの関数アプリを作成する

storageName=mystorageaccount$RANDOM
functionAppName=myappsvcpfunc$RANDOM
region=westeurope

# Create a resource resourceGroupName
az group create \
  --name myResourceGroup \
  --location $region

# Create an azure storage account
az storage account create \
  --name $storageName \
  --location $region \
  --resource-group myResourceGroup \
  --sku Standard_LRS

# Create a Premium plan
az functionapp plan create \
  --name mypremiumplan \
  --resource-group myResourceGroup \
  --location $region \
  --sku EP1

# Create a Function App
az functionapp create \
  --name $functionAppName \
  --storage-account $storageName \
  --plan mypremiumplan \
  --resource-group myResourceGroup \
  --functions-version 2

参考
Premium プランの関数アプリを作成する
Azure Functions の Premium プラン
サンプルスクリプト

リソースグループの作成

#TODO

リソースアカウントの作成

#TODO

Blobストレージの操作

ストレージコンテナの作成

az storage container create -n コンテナ名

ストレージコンテナの一覧

az storage container list

Blobオブジェクトの一覧

az storage blob list -c コンテナ名

Blobオブジェクトのアップロード

az storage blob upload -f ファイルPATH -c コンテナ名 -n オブジェクト名

Blobオブジェクトのダウンロード

az storage blob download -f 出力ファイルPATH -c コンテナ名 -n オブジェクト名

トップ   一覧 単語検索 最終更新   ヘルプ   最終更新のRSS