Slide 1

Slide 1 text

1)1Ͱ΋αʔόʔϨε͍ͨ͠ 1)1ΧϯϑΝϨϯεؔ੢ ߹ಉձࣾEFDS୅දࣾһ ౉ลҰ޺ !LB[@

Slide 2

Slide 2 text

WHO!? ౉ลҰ޺(@kaz_29) ߹ಉձࣾ decr ୅දࣾһ WebΞϓϦέʔγϣϯͷ։ൃ iOSΞϓϦέʔγϣϯͷ։ൃ Ϋϥ΢υΠϯϑϥͷߏஙɾӡ༻

Slide 3

Slide 3 text

ຊ೔ͷ಺༰ w αʔόʔϨεΞʔΩςΫνϟʔʁ w "[VSF'VODUJPOTͷ֓ཁ w 1)1Ͱͷ։ൃͷྫ w ฐࣾͰͷར༻ྫ

Slide 4

Slide 4 text

αʔόʔϨεΞʔΩςΫνϟʔʁ

Slide 5

Slide 5 text

No content

Slide 6

Slide 6 text

r4FSWFSMFTT$POG50,:0
 IUUQUPLZPTFSWFSMFTTDPOGJP lαʔόʔϨεΞʔΩςΫνϟ͸ɺ։ൃऀͷ૑଄ੑΛ ૉૣ͘8FC΍ϞόΠϧΞϓϦέʔγϣϯͱ࣮ͯ͠ݱ ͠ɺεέʔϥϏϦςΟ΍ηΩϡϦςΟɺΠϯϑϥͷอ कͱ͍ͬͨଟ਺ͷྗ࢓ࣄ͔Βղ์͞ΕΔͨΊͷ৽ͨͳ ύϥμΠϜγϑτͰ͢ɻz

Slide 7

Slide 7 text

αʔόʔ؀ڥͷมԽ w Ϋϥ΢υͷొ৔Ͱॊೈʹੜ੒ɾഁغ͕Ͱ͖Δ༷ʹͳͬͨɻ w ελϯυΞϩϯΞϓϦ͔Βͷ୤٫ϚΠΫϩαʔϏεͷོ੝ w αʔόʔ͕ͳ͘ͳΔͱ͍͏͜ͱͰ͸ͳ͍ɻ։ൃऀ͕αʔόʔʹ͍ͭͯ୔ࢁͷ ͜ͱΛߟ͑ͳͯ͘ྑ͘ͳΔͱ͍͏͜ͱɻ IUUQTSFBEXSJUFDPNXIZUIFGVUVSFPGTPGUXBSFBOEBQQTJTTFSWFSMFTT

Slide 8

Slide 8 text

αʔόʔ؀ڥͷมԽ IUUQTCMPHTNTEONJDSPTPGUDPNB[VSFTFDVSJUZCFTUQSBDUJDFTGPSVQEBUJOHWJSUVBMNBDIJOFTJONJDSPTPGUB[VSFJBBTEFQMPZNFOUT Best Practices for Updating Virtual Machines in Microsoft Azure IaaS Deployments

Slide 9

Slide 9 text

αʔόʔϨεͱ͸ʁ w αʔόʔΛҙࣝ͠ͳ͍Ͱྑ͍ w ؆୯ʹεέʔϧͰ͖Δ w ར༻ྔʹΑΔ՝ۚ

Slide 10

Slide 10 text

Α͘ޠΒΕΔϢʔεέʔε w 8FCΞϓϦέʔγϣϯ w ϞόΠϧόοΫΤϯυ w *P5όοΫΤϯυ w ετϦʔϜϓϩηογϯά΍&5- w νϟοτϘοτɺίάχςΟϒαʔϏε w όονॲཧ w ӡ༻ͷࣗಈԽ

Slide 11

Slide 11 text

ࣄྫ೔ܦ৽ฉ IUUQTBXTBNB[PODPNKQTPMVUJPOTDBTFTUVEJFTOJLLFJ

Slide 12

Slide 12 text

ࣄྫGBVMUMJOF IUUQLMPXIBUFOBCMPHDPNFOUSZ 1)1ΧϯϑΝϨϯε෱ԬͰGBVMUMJOFʹ͍ͭͯൃද͖ͯ͠·ͨ͠QIQDPOGVL

Slide 13

Slide 13 text

Α͘ޠΒΕΔϢʔεέʔε w 8FCΞϓϦέʔγϣϯ w ϞόΠϧόοΫΤϯυ w *P5όοΫΤϯυ w ετϦʔϜϓϩηογϯά΍&5- w νϟοτϘοτɺίάχςΟϒαʔϏε w όονॲཧ w ӡ༻ͷࣗಈԽ ࠷ॳʹࢼ͢ͷʹΦεεϝʂ

Slide 14

Slide 14 text

Lambda

Slide 15

Slide 15 text

rIUUQEPDTBXTBNB[PODPNKB@KQMBNCEBMBUFTUEHXFMDPNFIUNM lඞཁͳૢ࡞͸ɺ"84-BNCEB͕αϙʔτ͢Δ͍ͣ Ε͔ͷݴޠ ݱࡏ͸/PEFKTɺ+BWBɺ$͓Αͼ 1ZUIPO ͰίʔυΛࢦఆ͢Δ͚ͩͰ͢ɻ z

Slide 16

Slide 16 text

lඞཁͳૢ࡞͸ɺ"84-BNCEB͕αϙʔτ͢Δ͍ͣ Ε͔ͷݴޠ ݱࡏ͸/PEFKTɺ+BWBɺ $͓Αͼ1ZUIPO ͰίʔυΛࢦఆ͢Δͩ ͚Ͱ͢ɻ z "84-BNCEB rIUUQEPDTBXTBNB[PODPNKB@KQMBNCEBMBUFTUEHXFMDPNFIUNM ͸ͳ͍

Slide 17

Slide 17 text

"[VSF'VODUJPOT

Slide 18

Slide 18 text

rIUUQTEPDTNJDSPTPGUDPNKBKQB[VSFB[VSFGVODUJPOTGVODUJPOTPWFSWJFX l$ɺ'ɺ/PEFKTɺ1ZUIPOɺ1)1ɺ#BUDIɺ #BTIɺͦͷଞ࣮ߦՄೳͳݴޠΛ࢖ͬͯؔ਺Λهड़Ͱ ͖·͢ɻz Ͱॻ͚Δ

Slide 19

Slide 19 text

"[VSF'VODUJPO

Slide 20

Slide 20 text

"[VSF'VODUJPOT w ΊͬͪΌ͍҆ w ೖྗɾग़ྗͷ࿈ܞػೳ͕๛෋ τϦΨʔɾόΠϯσΟϯά w 7JTVBM4UVEJPΛ࢖ͬͯͷσόοά ϩʔΧϧɾϦϞʔτʣ w ΦϯϓϨͰ΋͍͚Δ "[VSF4UBDL w ϥϯλΠϜ͕Φʔϓϯ IUUQTHJUIVCDPN"[VSF"[VSF'VODUJPOT w (JUIVC͔ΒσϓϩΠͰ͖Δ

Slide 21

Slide 21 text

τϦΨʔͱόΠϯσΟϯά IUUQTEPDTNJDSPTPGUDPNKBKQB[VSFB[VSFGVODUJPOTGVODUJPOTUSJHHFSTCJOEJOHT

Slide 22

Slide 22 text

-PHJD"QQT

Slide 23

Slide 23 text

-PHJD"QQ

Slide 24

Slide 24 text

.JDSPTPGU'MPX IUUQTqPXNJDSPTPGUDPN

Slide 25

Slide 25 text

"[VSF'VODUJPOͷػೳ

Slide 26

Slide 26 text

"[VSF'VODUJPO

Slide 27

Slide 27 text

Ϟχλʔ

Slide 28

Slide 28 text

'VODUJPO1SPYZ QSFWJFX w ෳ਺ͷ'VODUJPOΛ౷߹Ͱ͖Δ w "1*.BOBHFNFOUͷ୅ΘΓʹ࢖͑Δ w 'VODUJPOҎ֎΁ͷϦΫΤετ΋ઃఆͰ͖Δ "[VSF"1*NBOBHFNFOU "[VSF'VODUJPOT "[VSF'VODUJPOT1SPYZ "[VSF'VODUJPOT ͪΐͬͱ ͓ߴ͍

Slide 29

Slide 29 text

σϓϩΠϝϯτεϩοτ QSFWJFX #MVF(SFFO%FQMPZNFOU͕؆୯ʹͰ͖Δ

Slide 30

Slide 30 text

$POTPMF

Slide 31

Slide 31 text

"QQMJDBUJPO*OTJUF QSFWJFX ೖΕΔ͔ʜ IUUQTB[VSFNJDSPTPGUDPNKBKQVQEBUFTB[VSFGVODUJPOTOPXJOUFHSBUFEXJUIBQQMJDBUJPOJOTJHIUT

Slide 32

Slide 32 text

%VSBCMF'VODUJPOT Ћ൛ w ෳ਺ͷ'VODUJPOͷ࿈ܞΛൺֱత؆୯ʹ࣮૷Ͱ͖Δ w 'VODUJPODIBJOJOH w 'BOPVU'BOJO w "TZOD)551"1*T IUUQTB[VSFHJUIVCJPB[VSFGVODUJPOTEVSBCMFFYUFOTJPOJOEFYIUNM IUUQRJJUBDPN5TVZPTIJ6TIJP!HJUIVCJUFNTFBDCCCGEC

Slide 33

Slide 33 text

'VODUJPO$IBJOJOH public static async Task Run(DurableOrchestrationContext ctx) { try { var x = await ctx.CallFunctionAsync("F1"); var y = await ctx.CallFunctionAsync("F2", x); var z = await ctx.CallFunctionAsync("F3", y); return await ctx.CallFunctionAsync("F4", z); } catch (Exception) { // error handling/compensation goes here } }

Slide 34

Slide 34 text

public static async Task Run(DurableOrchestrationContext ctx) { var parallelTasks = new List>(); // get a list of N work items to process in parallel object[] workBatch = await ctx.CallFunctionAsync("F1"); for (int i = 0; i < workBatch.Length; i++) { Task task = ctx.CallFunctionAsync("F2", workBatch[i]); parallelTasks.Add(task); } await Task.WhenAll(parallelTasks); // aggregate all N outputs and send result to F3 int sum = parallelTasks.Sum(t => t.Result); await ctx.CallFunctionAsync("F3", sum); } 'BOPVU 'BOJO

Slide 35

Slide 35 text

"TZOD)551"1*T public static async Task Run( HttpRequestMessage req, DurableOrchestrationClient starter, string functionName, TraceWriter log) { // Function name comes from the request URL. // Function input comes from the request content. dynamic eventData = await req.Content.ReadAsAsync(); string instanceId = await starter.StartNewAsync(functionName, eventData); log.Info($"Started orchestration with ID = '{instanceId}'."); return starter.CreateCheckStatusResponse(req, instanceId); }

Slide 36

Slide 36 text

-JHIUXFJHIU"DUPST public static async Task Run(DurableOrchestrationContext ctx) { int counterState = ctx.GetInput(); string operation = await ctx.WaitForExternalEvent("operation"); if (operation == "incr") { counterState++; } else if (operation == "decr") { counterState--; } ctx.ContinueAsNew(counterState); }

Slide 37

Slide 37 text

)VNBO*OUFSBDUJPOBOE5JNFPVUT public static async Task Run(DurableOrchestrationContext ctx) { await ctx.CallFunctionAsync("RequestApproval"); using (var timeoutCts = new CancellationTokenSource()) { DateTime dueTime = ctx.CurrentUtcDateTime.AddHours(72); Task durableTimeout = ctx.CreateTimer(dueTime, timeoutCts.Token); Task approvalEvent = ctx.WaitForExternalEvent("ApprovalEvent"); if (approvalEvent == await Task.WhenAny(approvalEvent, durableTimeout)) { timeoutCts.Cancel(); await ctx.CallFunctionAsync("HandleApproval", approvalEvent.Result); } else { await ctx.CallFunctionAsync("Escalate"); } } }

Slide 38

Slide 38 text

'VODUJPOTͷ࡞Γํ

Slide 39

Slide 39 text

όΠϯσΟϯάͷ࢖͍ํ

Slide 40

Slide 40 text

࡞Γํ w 'VODUJPO"QQΛ࡞Δ w 'VODUJPO࡞Δ w ίʔυΛॻ͘ w ΞϓϦͷઃఆ w ؀ڥม਺Λઃఆ w ࣮ߦ͢Δ

Slide 41

Slide 41 text

࡞Γํ w 'VODUJPO"QQΛ࡞Δ w 'VODUJPO࡞Δ w ίʔυΛॻ͘ w ΞϓϦͷઃఆ w ؀ڥม਺Λઃఆ w ࣮ߦ͢Δ

Slide 42

Slide 42 text

࡞Γํ w 'VODUJPO"QQΛ࡞Δ w 'VODUJPO࡞Δ w ίʔυΛॻ͘ w ΞϓϦͷઃఆ w ؀ڥม਺Λઃఆ w ࣮ߦ͢Δ

Slide 43

Slide 43 text

࡞Γํ w 'VODUJPO"QQΛ࡞Δ w 'VODUJPO࡞Δ w ίʔυΛॻ͘ w ΞϓϦͷઃఆ w ؀ڥม਺Λઃఆ w ࣮ߦ͢Δ

Slide 44

Slide 44 text

࡞Γํ w 'VODUJPO"QQΛ࡞Δ w 'VODUJPO࡞Δ w ίʔυΛॻ͘ w ΞϓϦͷઃఆ w ؀ڥม਺Λઃఆ w ࣮ߦ͢Δ

Slide 45

Slide 45 text

࡞Γํ w 'VODUJPO"QQΛ࡞Δ w 'VODUJPO࡞Δ w ίʔυΛॻ͘ w ΞϓϦͷઃఆ w ؀ڥม਺Λઃఆ w ࣮ߦ͢Δ

Slide 46

Slide 46 text

Έ͍ͨͳͷ͸ɺ΍ͬͯΈͨܥͰ Α͘ॻ͔Ε͍ͯ·͢ɻ

Slide 47

Slide 47 text

Ͱ΋ʜ

Slide 48

Slide 48 text

ςετ͸⁉

Slide 49

Slide 49 text

1PSUBMͰ௚઀ ίʔυमਖ਼⁉

Slide 50

Slide 50 text

No content

Slide 51

Slide 51 text

'VODUJPOͷσόοάςετ w 8JOEPXTͳΒʜ w ୯ମςετ΋͍ͨ͠

Slide 52

Slide 52 text

'VODUJPOͷσόοάςετ ೖɾग़ྗνΣοΫͳΒͰ͖ͦ͏

Slide 53

Slide 53 text

αϯϓϧ

Slide 54

Slide 54 text

0VUHPJOH8FCIPPLT IUUQ5SJHHFS IUUQPVUCJOEJOH

Slide 55

Slide 55 text

'VODTJPOͷߏ੒ ᵓᴷᴷIPTUKTPO ᵓᴷᴷGVOD ᴹᵓᴷᴷGVODUJPOKTPO ᴹᵋᴷᴷSVOQIQ ᵋᴷᴷGVOD ᵓᴷᴷGVODUJPOKTPO ᵋᴷᴷSVOQIQ EJSFDUPSJFT pMFT 'VODUJPOຖʹσΟϨΫτϦ τϦΨʔɾόΠϯσΟϯάͳͲͷఆٛ 'VODUJPOͷΤϯτϦϙΠϯτ ϥϯλΠϜݻ༗ͷߏ੒ IUUQTEPDTNJDSPTPGUDPNKBKQB[VSFB[VSFGVODUJPOTGVODUJPOTUSJHHFSTCJOEJOHT

Slide 56

Slide 56 text

αϯϓϧ'VODUJPOͷߏ੒ . ├── composer.json ├── composer.lock ├── slackbot │ ├── function.json │ └── run.php ├── src │ ├── Functions │ │ └── SlackBot.php │ └── Lib │ └── AzureFunction.php ├── tests │ ├── Lib │ │ └── TestCase.php │ └── TestCase │ └── Functions │ └── SlackBotTest.php ├── tmp └── vendor ├── autoload.php … 'VODUJPOͷσΟϨΫτϦ τϦΨʔɾόΠϯσΟϯάͳͲͷఆٛ 'VODUJPOͷΤϯτϦϙΠϯτ 'VODUJPOຊମ ؆୯ͳϥούʔΫϥε ςετΫϥε IUUQTHJUIVCDPNLB[QIQDPOLBOTBJB[VSFGVODUJPO

Slide 57

Slide 57 text

GVODUJPOKTPO { "bindings": [ { "type": "http", "direction": "out", "name": "res" }, { "type": "httpTrigger", "name": "req", "authLevel": "function", "methods": [ "post" ], "direction": "in" } ], "disabled": false }

Slide 58

Slide 58 text

SVOQIQ run();

Slide 59

Slide 59 text

4MBDL#PUQIQ init(getenv($req), getenv($res)); } … }

Slide 60

Slide 60 text

4MBDL#PUQIQ public function run() { $params = $this->httpParams(); if (!isset($params['user_name']) || $params['user_name'] === 'slackbot') { return; } $response = [ 'text' => '', 'username' => 'phpconkansai2017demo', 'icon_emoji' => ':phpkansai:', 'attachments' => [[ "color" => '#00BFFF', // blue "title" => 'ϝοηʔδΛड৴͠·ͨ͠', "fields" => [[ … ]] ]] ]; $this->writeResponse(json_encode($response)); }

Slide 61

Slide 61 text

4-BDL#PU5FTUQIQ /** * @test */ public function ௨ৗͷॻ͖ࠐΈͷςετ() { $params = [ 'token' => 'DUMMY', 'user_name' => 'userA', 'text' => 'Hello Azure Function' ]; $this->makeHttpRequest($params); $this->makeResponse(); …

Slide 62

Slide 62 text

4-BDL#PU5FTUQIQ $this->slackBot = new SlackBot(); $this->slackBot->run(); $result = json_decode($this->getResponse(), true); $expected = [ 'username' => 'phpconkansai2017demo', 'icon_emoji' => ':phpkansai:', 'text' => '', 'attachments' => [[ "color" => '#00BFFF', "title" => 'ϝοηʔδΛड৴͠·ͨ͠', "fields" => [[ // লུ ]] ]] ]; $this->assertEquals($expected, $result); }

Slide 63

Slide 63 text

1)16OJUͰςετ

Slide 64

Slide 64 text

No content

Slide 65

Slide 65 text

ฐࣾͰͷࣄྫ

Slide 66

Slide 66 text

ӡ༻πʔϧ w J04ΞϓϦͷόοΫΤϯυ w 4MBTI$PNNBOEͰεςʔδϯάαʔόͷىಈɾఀࢭ w λΠϚʔͰ࣌ʹࣗಈఀࢭ w ࣗಈఀࢭͷԆ௕

Slide 67

Slide 67 text

ߏ੒ 4MBTI$PNNBOE IUUQ5SJHHFS 2VFVF "1*࣮ߦ ىಈఀࢭ "1*࣮ߦ ঢ়ଶऔಘ UJNFS5SJHHFS ݁Ռ௨஌ ॲཧ։࢝௨஌ ஗Ԇ2VFVF

Slide 68

Slide 68 text

ࣾ಺޲͚πʔϧ w ݄ॳʹΫϥ΢υܥͷ݄࣍ར༻ྉۚΛ4MBDLʹ௨஌

Slide 69

Slide 69 text

·ͱΊ

Slide 70

Slide 70 text

'VODUJPOΛ࢖ͬͯΈͯ w όονͱ͔ॏ͍ॲཧΛͤ͞Δʹ͸ͱͯ΋ศར దࡐదॴ w ΞϓϦΛ1)1Ͱॻ͍͍ͯΔͳΒಉ͡ݴޠͰ͔͚Δͷ͸ָ w .BDͰ΋ී௨ʹ։ൃͰ͖Δ w %VSBCMF'VODUJPOT͸ظ଴େ

Slide 71

Slide 71 text

՝୊ w 4FSWFSMFTT'SBNFXPSLͰσϓϩΠ͍ͨ͠ w IUUQ5SJHHFS͸ɺैྔ՝ۚϓϥϯͩͱਏ͍ ࠓճͷྫͩͱɺ4MBDLଆͰλΠϜΞ΢τ͢Δ͜ͱ͕͋Δ

Slide 72

Slide 72 text

ࠓ೔ͷαϯϓϧ IUUQTHJUIVCDPNLB[ QIQDPOLBOTBJB[VSFGVODUJPO

Slide 73

Slide 73 text

"[VSF'VODUJPO݁ߏ͍͍Ͱ͢ IUUQTGVODUJPOTB[VSFDPNUSZ

Slide 74

Slide 74 text

'JO