0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

[Functions] GitHub Actions でデプロイ[TODO] - Azure - Memo

Last updated at Posted at 2022-10-03

概要

(自分用メモ)

試したこと

Azure cloud上にFunctionAppを準備

RG=g2x04
LOCATION=westus
FUNCAPP=${RG}a1
DBACC=${RG}db
DB=${DBACC}1

az group create -n $RG --location $LOCATION
az storage account create -n ${FUNCAPP}s  -l $LOCATION -g $RG 
az functionapp create -n $FUNCAPP -c $LOCATION -g $RG --storage-account ${FUNCAPP}s --os-type Linux --functions-version 4 --runtime node --runtime-version 16
#az cosmosdb create -n $DBACC -g $RG
#az cosmosdb sql database create -a $DBACC -g $RG -n $DB

ローカルでFunctionプロジェクト作成/デバッグ

func init . --worker-runtime node --language typescript 
FUNC=fgrpql1
func new -n ${FUNC} --template "HTTP trigger"
npm install
npm start

Functionsのデプロイ(TODO:Error)

func azure functionapp publish $FUNCAPP --publish-local-settings -y

GitHubのActions設定

  1. Azure Portal ➔ 関数アプリ ➔ 概要 ➔ 発行プロファイルの取得
    ➔ ダウンロードして保存
  2. GitHub ➔ リポジトリ ➔ Settings ➔ Secrets/Actions ➔ New repository secret
    ➔ Name: AZURE_FUNCTIONAPP_PUBLISH_PROFILE
    ➔ Secret: 発行プロファイルの内容(xml)をそのままコピー
    ➔ Add Secret

workflows(デプロイスクリプト)の準備とデプロイ

https://github.com/Azure/actions-workflow-samples/blob/master/FunctionApp/linux-node.js-functionapp-on-azure.yml
を .github/workflows にコピー

linux-node.js-functionapp-on-azure.yml 編集
env:
  AZURE_FUNCTIONAPP_NAME: g2x04a1      # set this to your application's name
  AZURE_FUNCTIONAPP_PACKAGE_PATH: '.'  # set this to the path to your web app project, defaults to the repository root
  NODE_VERSION: '16.x' 
commit/push
git commit
git push

GitHub ➔ リポジトリ ➔ Actions からデプロイ状況を確認。
Azure Portal ➔ 関数アプリ(FUNCAPP) ➔ 関数(FUNC) ➔ 関数のURLの取得 ➔ ブラウザでURLを開き応答を確認
This HTTP triggered function executed successfully. Pass a name in the query string or in the request body for a personalized response.

参照

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?