Lock in $30 Savings on PRO—Offer Ends Soon! ⏳
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Introduction to Azure Functions
Search
TonyTonyKun
December 10, 2017
Technology
0
250
Introduction to Azure Functions
build 2016振り返り 勉強会のスライドです。
TonyTonyKun
December 10, 2017
Tweet
Share
More Decks by TonyTonyKun
See All by TonyTonyKun
これでバッチリ!Azure マルチテナントアーキテクチャ設計のコツ/jat06
thara0402
0
630
Azure Load Testing を使って Azure Functions Flex Consumption の HTTP Trigger のパフォーマンスとコストを最適化してみよう/global-azure2025
thara0402
0
210
Prompty を使って生成 AI アプリケーション開発のプロンプトを管理する/jat03
thara0402
0
60
Azure OpenAI Service で意図せず PTU モデルをデプロイして高額請求されてしまった件/jat04
thara0402
0
72
「Durable Task Scheduler」をチョイ見せ!/jat05
thara0402
0
50
Azure App Service on Linux の Sidecar に Phi-3 を配置してインテリジェントなアプリケーションを作ってみよう/jazug-anniv14
thara0402
0
1.3k
サイクルガードサービス AlterLock の問い合わせ対応業務に Azure OpenAI Service を活用した話/jazug46
thara0402
0
960
Microsoft Ignite 2023 現地参加レポート/ignite2023
thara0402
0
310
Azure Container Apps で .NET 7 アプリを Blue-Green デプロイしてみよう!/jazug12
thara0402
0
1.8k
Other Decks in Technology
See All in Technology
Entity Framework Core におけるIN句クエリ最適化について
htkym
0
130
投資戦略を量産せよ 2 - マケデコセミナー(2025/12/26)
gamella
0
440
モダンデータスタックの理想と現実の間で~1.3億人Vポイントデータ基盤の現在地とこれから~
taromatsui_cccmkhd
2
270
Snowflake導入から1年、LayerXのデータ活用の現在 / One Year into Snowflake: How LayerX Uses Data Today
civitaspo
0
2.4k
TED_modeki_共創ラボ_20251203.pdf
iotcomjpadmin
0
150
「図面」から「法則」へ 〜メタ視点で読み解く現代のソフトウェアアーキテクチャ〜
scova0731
0
510
なぜ あなたはそんなに re:Invent に行くのか?
miu_crescent
PRO
0
210
New Relic 1 年生の振り返りと Cloud Cost Intelligence について #NRUG
play_inc
0
240
AWSインフルエンサーへの道 / load of AWS Influencer
whisaiyo
0
220
フルカイテン株式会社 エンジニア向け採用資料
fullkaiten
0
9.9k
会社紹介資料 / Sansan Company Profile
sansan33
PRO
11
390k
アプリにAIを正しく組み込むための アーキテクチャ── 国産LLMの現実と実践
kohju
0
230
Featured
See All Featured
エンジニアに許された特別な時間の終わり
watany
106
220k
AI: The stuff that nobody shows you
jnunemaker
PRO
1
24
DevOps and Value Stream Thinking: Enabling flow, efficiency and business value
helenjbeal
1
70
How to Build an AI Search Optimization Roadmap - Criteria and Steps to Take #SEOIRL
aleyda
1
1.8k
Efficient Content Optimization with Google Search Console & Apps Script
katarinadahlin
PRO
0
250
ラッコキーワード サービス紹介資料
rakko
0
1.8M
The untapped power of vector embeddings
frankvandijk
1
1.5k
Game over? The fight for quality and originality in the time of robots
wayneb77
1
66
Self-Hosted WebAssembly Runtime for Runtime-Neutral Checkpoint/Restore in Edge–Cloud Continuum
chikuwait
0
230
Max Prin - Stacking Signals: How International SEO Comes Together (And Falls Apart)
techseoconnect
PRO
0
51
Ethics towards AI in product and experience design
skipperchong
1
140
How STYLIGHT went responsive
nonsquared
100
6k
Transcript
Introduction to Azure Functions 2016.05.21 //build/ 2016 振り返り 勉強会
⾃⼰紹介 名前 Twitter : @TonyTonyKun(トニー) 仕事 C# で業務アプリケーションを開発しています。 Azure をベースに
ASP.NET を使うことが多いです。 Blog ROMANCE DAWN for the new world http://gooner.hateblo.jp/ Copyright© 2016, JAZUG All Rights Reserved. 2
⼤事なお知らせ このセッションは、2016/05/21 時点の情報を基にしています。 まだ Public Preview です。 最新情報は Web で。
Copyright© 2016, JAZUG All Rights Reserved. 3
Goal Azure Functions の概要を知る イベント駆動型サービスの作り⽅が分かる Copyright© 2016, JAZUG All Rights
Reserved. 4
Azure Functions Overview 概要と特徴 Copyright© 2016, JAZUG All Rights Reserved.
5
Azure Functions とは? イベント駆動型サービス トリガーが発⽕したときだけ処理が実⾏される サーバーレスアーキテクチャ サーバーの構築や保守は必要ない API を公開するだけのためにアプリを作る必要がない 運⽤や課⾦のコストを節約できる
Azure 以外でも同様のサービスが提供されている AWS Lambda Google Cloud Functions など Copyright© 2016, JAZUG All Rights Reserved. 6
ブラウザで簡単にコードが書ける Copyright© 2016, JAZUG All Rights Reserved. 7
さまざまな Trigger と Binding をサポート Copyright© 2016, JAZUG All Rights
Reserved. 8 Type Service Trigger Input Output Schedule Azure Functions ✔ HTTP (REST or WebHook) Azure Functions ✔ ✔ Blob Storage Azure Storage ✔ ✔ ✔ Queues Azure Storage ✔ ✔ Queues Azure Service Bus Queue ✔ ✔ Topics Azure Service Bus Topic ✔ ✔ Tables Azure Storage ✔ ✔ Tables Azure Mobile Apps Easy Tables ✔ ✔ No-SQL DB Azure DocumentDB ✔ ✔ Streams Azure Event Hubs ✔ ✔ Push Notifications Azure Notification Hubs ✔
複数の開発⾔語をサポート メイン C# Node / JavaScript その他(⼀部の Trigger や Binding
のみ対応) F# Python PHP Batch Bash PowerShell Copyright© 2016, JAZUG All Rights Reserved. 9
2つの課⾦モデル Dynamic App Service Plan 実⾏した分だけ課⾦される リクエスト数(100 万単位) サーバーレスアーキテクチャらしいモデル Classic
App Service Plan 従来の課⾦モデル(Free, Basic, Standard, Premium) Web Apps にデプロイしたアプリと共存させるときに使う Functions ⾃体には課⾦されない、Web Jobs に近いイメージ Copyright© 2016, JAZUG All Rights Reserved. 10
Azure App Service に追加されたサービス Web Jobs を拡張したサービス 実⾏環境は Web Apps
なので、同じ機 能が使える App Settings Connection Strings Kudu / Site Extension Remote Debug 便利かつ⾃由度の⾼いサービス Copyright© 2016, JAZUG All Rights Reserved. 11
Demo Hello world Copyright© 2016, JAZUG All Rights Reserved. 12
How .csx works .csx ファイルの仕組み Copyright© 2016, JAZUG All Rights
Reserved. 13
名前空間のインポート よく使う名前空間は、⾃動的にインポートされている System.Linq Microsoft.Azure.WebJobs など 必要に応じて、using を追加する Copyright© 2016, JAZUG
All Rights Reserved. 14
外部アセンブリの参照 よく使う .NET のアセンブリは、⾃動的に参照されている System.Net.Http.dll Microsoft.Azure.WebJobs.dll など 必要に応じて、#r “AssemblyName” で参照できる
Newtonsoft.Json.dll のように、.NET に含まれていなくても、使えるア センブリもある プライベート アセンブリは、bin フォルダにアップロードする “D:¥home¥site¥wwwroot¥{function name}¥bin” に配置する #r “MyAssembly.dll“ で参照できる Copyright© 2016, JAZUG All Rights Reserved. 15
NuGet ライブラリの参照 project.json ファイルをアップロードする ランタイムがパッケージを取得し、アセンブ リに参照が⾃動的に追加される #r “AssemblyName” を追加する必要はない using
を追加するだけでOK アップロードする⽅法 Visual Studio Online ( Monaco ) Kudu FTP Copyright© 2016, JAZUG All Rights Reserved. 16
.csx コードの再利⽤ 別の .csx ファイルで定義されたコードを利⽤できる # load で .csx ファイルの相対パスを指定する
#load "myhelper.csx“ #load "..¥myhelper.csx" Copyright© 2016, JAZUG All Rights Reserved. 17
Demo App Settings から値を取得する System.Configuration の using を追加する プライベートアセンブリを参照する NuGet
Package から Jil Json Serializer を参照する https://github.com/kevin-montrose/Jil .csx ファイルのコードを再利⽤する Copyright© 2016, JAZUG All Rights Reserved. 18
Continuous Integration ポータルからは、コードを編集できなくなります Copyright© 2016, JAZUG All Rights Reserved. 19
Trigger & Bindings トリガーとバインディングの構成 Copyright© 2016, JAZUG All Rights Reserved.
20
簡単に管理できるけど、⼀部の項⽬しか構成できない Azure Portal の Standard Editor Copyright© 2016, JAZUG All
Rights Reserved. 21
Azure Portal の Advanced Editor Copyright© 2016, JAZUG All Rights
Reserved. 22 function.json を編集できるので、詳細な構成ができる
HTTP Trigger https://{site name}.azurewebsites.net/api/{function name} name .csx のコードで使う変数名 authLevel Function:Function
Key admin:Master Key anonymous:認証なし Copyright© 2016, JAZUG All Rights Reserved. 23
WebHook Trigger https://{site name}.azurewebsites.net/api/{function name} name .csx のコードで使う変数名 webHookType genericJson
Github API Key 認証は必須 Copyright© 2016, JAZUG All Rights Reserved. 24
API Key HTTP Trigger と WebHook Trigger で API Key
を要求できる クエリ⽂字列:code HTTP ヘッダー:x-functions-key API Key ⾃体は、D:¥home¥data¥Functions¥secrets に定義されている Function Key 無効なファンクションはトリガーできない ファンクションごと or 共通の API Key Master Key 無効なファンクションもトリガーできる すべてのファンクションで共通の API Key Copyright© 2016, JAZUG All Rights Reserved. 25
Azure Storage Queue Trigger Copyright© 2016, JAZUG All Rights Reserved.
26 引数へのバインド string byte[] JObject CloudQueueMessage など myqueue-items
Azure Storage Queue Output Binding Copyright© 2016, JAZUG All Rights
Reserved. 27 引数へのバインド string byte[] JObject CloudQueueMessage ICollector<T> など outqueue
Azure Storage Blob Input Binding Copyright© 2016, JAZUG All Rights
Reserved. 28 引数へのバインド string Stream JObject CloudBlockBlob など incontainer
Demo Azure Storage Account Replication セカンダリのクールストレージにブロブをコピーする https://blogs.msdn.microsoft.com/cloud_solution_architect/2016/05/09/az ure-storage-account-backup-azure-automation-runbook-azure-functions/ Copyright© 2016,
JAZUG All Rights Reserved. 29
Timer Trigger {second} {minute} {hour} {day} {month} {day of the
week} 6つのフィールドを含む CRON 式 {second} フィールドを省略してはダメ hh:mm:ss 形式も可能 タイムゾーンは UTC で指定する runOnStartup すぐに実⾏するかどうか Copyright© 2016, JAZUG All Rights Reserved. 30
Timer Trigger 10分ごとに実⾏する場合 すぐに実⾏し、毎⽇0時(JST)に実⾏する場合 ⽉曜から⾦曜の17時(JST)に実⾏する場合 Copyright© 2016, JAZUG All Rights
Reserved. 31 "schedule": "0 */10 * * * *“ "schedule": "0 0 15 * * * “ "runOnStartup": true "schedule": "0 0 8 * * 1-5“ "schedule": "00:10:00“
Conclusion まとめ Copyright© 2016, JAZUG All Rights Reserved. 32
まとめ イベント駆動サービスを活⽤していこう トリガーが発⽕したときのロジックだけに集中できる 1つの API のためにアプリを作ってデプロイする必要なし 運⽤や課⾦のコストを節約できる Feedback は、こちらへ https://feedback.azure.com/forums/355860-azure-functions
Copyright© 2016, JAZUG All Rights Reserved. 33
参考資料 Azure Functions の概要 https://azure.microsoft.com/ja-jp/documentation/articles/functions- overview/ Introducing Azure Functions https://channel9.msdn.com/Events/Build/2016/B858
Azure Functions Under the Hood https://channel9.msdn.com/Events/Build/2016/T692 オープンソース https://github.com/azure/azure-webjobs-sdk-script Copyright© 2016, JAZUG All Rights Reserved. 34