Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Introduction to Azure Functions
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
TonyTonyKun
December 10, 2017
Technology
0
260
Introduction to Azure Functions
build 2016振り返り 勉強会のスライドです。
TonyTonyKun
December 10, 2017
Tweet
Share
More Decks by TonyTonyKun
See All by TonyTonyKun
Azure Durable Functions で作った NL2SQL Agent の精度向上に取り組んだ話/jat08
thara0402
0
190
これでバッチリ!Azure マルチテナントアーキテクチャ設計のコツ/jat06
thara0402
0
650
Azure Load Testing を使って Azure Functions Flex Consumption の HTTP Trigger のパフォーマンスとコストを最適化してみよう/global-azure2025
thara0402
0
230
Prompty を使って生成 AI アプリケーション開発のプロンプトを管理する/jat03
thara0402
0
65
Azure OpenAI Service で意図せず PTU モデルをデプロイして高額請求されてしまった件/jat04
thara0402
0
78
「Durable Task Scheduler」をチョイ見せ!/jat05
thara0402
0
55
Azure App Service on Linux の Sidecar に Phi-3 を配置してインテリジェントなアプリケーションを作ってみよう/jazug-anniv14
thara0402
0
1.4k
サイクルガードサービス AlterLock の問い合わせ対応業務に Azure OpenAI Service を活用した話/jazug46
thara0402
0
970
Microsoft Ignite 2023 現地参加レポート/ignite2023
thara0402
0
320
Other Decks in Technology
See All in Technology
【Oracle Cloud ウェビナー】[Oracle AI Database + AWS] Oracle Database@AWSで広がるクラウドの新たな選択肢とAI時代のデータ戦略
oracle4engineer
PRO
2
170
コミュニティが変えるキャリアの地平線:コロナ禍新卒入社のエンジニアがAWSコミュニティで見つけた成長の羅針盤
kentosuzuki
0
120
[CV勉強会@関東 World Model 読み会] Orbis: Overcoming Challenges of Long-Horizon Prediction in Driving World Models (Mousakhan+, NeurIPS 2025)
abemii
0
140
Embedded SREの終わりを設計する 「なんとなく」から計画的な自立支援へ
sansantech
PRO
3
2.5k
今日から始めるAmazon Bedrock AgentCore
har1101
4
410
Introduction to Bill One Development Engineer
sansan33
PRO
0
360
仕様書駆動AI開発の実践: Issue→Skill→PRテンプレで 再現性を作る
knishioka
2
670
What happened to RubyGems and what can we learn?
mikemcquaid
0
300
FinTech SREのAWSサービス活用/Leveraging AWS Services in FinTech SRE
maaaato
0
130
AIと新時代を切り拓く。これからのSREとメルカリIBISの挑戦
0gm
0
2.4k
広告の効果検証を題材にした因果推論の精度検証について
zozotech
PRO
0
190
会社紹介資料 / Sansan Company Profile
sansan33
PRO
15
400k
Featured
See All Featured
Public Speaking Without Barfing On Your Shoes - THAT 2023
reverentgeek
1
310
Speed Design
sergeychernyshev
33
1.5k
16th Malabo Montpellier Forum Presentation
akademiya2063
PRO
0
51
Pawsitive SEO: Lessons from My Dog (and Many Mistakes) on Thriving as a Consultant in the Age of AI
davidcarrasco
0
67
コードの90%をAIが書く世界で何が待っているのか / What awaits us in a world where 90% of the code is written by AI
rkaga
60
42k
Testing 201, or: Great Expectations
jmmastey
46
8k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
231
22k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
133
19k
Everyday Curiosity
cassininazir
0
130
Navigating Team Friction
lara
192
16k
Avoiding the “Bad Training, Faster” Trap in the Age of AI
tmiket
0
76
Product Roadmaps are Hard
iamctodd
PRO
55
12k
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