Home
%3CLINGO-SUB%20id%3D%22lingo-sub-392580%22%20slang%3D%22en-US%22%3EAzure%20Durable%20Functions%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-392580%22%20slang%3D%22en-US%22%3E%0A%20%26lt%3Bmeta%20http-equiv%3D%22Content-Type%22%20content%3D%22text%2Fhtml%3B%20charset%3DUTF-8%22%20%2F%26gt%3B%3CSTRONG%3E%20First%20published%20on%20MSDN%20on%20May%2021%2C%202018%20%3C%2FSTRONG%3E%20%3CBR%20%2F%3E%3CP%3E%3CBR%20%2F%3E%3C%2FP%3E%0A%20%20%3CP%3EThis%20blogs%20talks%20about%20how%20to%20create%20a%20simple%20Durable%20Function%20App.%3C%2FP%3E%0A%20%20%3CP%3EThere%20are%20three%20components%20to%20Durable%20Function%20App.%3C%2FP%3E%0A%20%20%3COL%3E%0A%20%20%20%3CLI%3E%3CSTRONG%3E%20Main%20%2F%20Starter%20Function%20%3C%2FSTRONG%3E%3C%2FLI%3E%0A%20%20%20%3CLI%3E%3CSTRONG%3E%20Workflow%20%2F%20Orchestrator%20Function%20%3C%2FSTRONG%3E%3C%2FLI%3E%0A%20%20%20%3CLI%3E%3CSTRONG%3E%20Activity%20Function%20%3C%2FSTRONG%3E%3C%2FLI%3E%0A%20%20%3C%2FOL%3E%0A%20%20%3CP%3EDurable%20Function%20App%20needs%20all%20three%20functions.%20%3CSTRONG%3EMain%20%2F%20Starter%20%3C%2FSTRONG%3E%20function%20is%20responsible%20for%20starting%20a%20workflow%20instance.%20%3CSTRONG%3EWorkflow%20%2F%20Orchestrator%20%3C%2FSTRONG%3E%20function%20has%20workflow%20logic%2C%20calls%20activities%20and%20waits%20for%20external%20events.%20%3CSTRONG%3EActivity%20%3C%2FSTRONG%3E%20function%2C%20actual%20work%20is%20implemented%20here.%3C%2FP%3E%0A%20%20%3CP%3EIn%20this%20sample%20Durable%20Function%20App%2C%20we%20are%20going%20to%20create%20a%20workflow%20with%20three%20activities%20and%20one%20external%20event.%20We%20are%20going%20to%20start%20workflow%20via%20PostMan.%20We%20are%20also%20going%20to%20use%20PostMan%20to%20get%20workflow%20instance%20status%20and%20to%20fire%20external%20events.%3C%2FP%3E%0A%20%20%3CP%3EHere%20are%20high%20level%20steps%3A%3C%2FP%3E%0A%20%20%3COL%3E%0A%20%20%20%3CLI%3ECreate%20Function%20App%3C%2FLI%3E%0A%20%20%20%3CLI%3ECreate%20Main%20%2F%20Starter%20Function%3C%2FLI%3E%0A%20%20%20%3CLI%3ECreate%20Workflow%20Function%3C%2FLI%3E%0A%20%20%20%3CLI%3ECreate%20Activity%20Function%3C%2FLI%3E%0A%20%20%20%3CLI%3EStart%20Workflow%3C%2FLI%3E%0A%20%20%20%3CLI%3EWorkflow%20with%20external%20events%3C%2FLI%3E%0A%20%20%3C%2FOL%3E%0A%20%20%3CP%3E%3CBR%20%2F%3E%3C%2FP%3E%0A%20%20%3CH3%20id%3D%22toc-hId-1485073120%22%20id%3D%22toc-hId-1505391364%22%3E1.%20Create%20Function%20App%3C%2FH3%3E%0A%20%20%3CP%3E%3CBR%20%2F%3E%3C%2FP%3E%0A%20%20%3CP%3E1.%20Log%20into%20Azure%20Portal%3A%20%3CA%20href%3D%22https%3A%2F%2Fportal.azure.com%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3E%20https%3A%2F%2Fportal.azure.com%3C%2FA%3E%3C%2FP%3E%0A%20%20%3CP%3E3.%20Click%20on%20the%20%3CB%3E%20Add%20%3C%2FB%3E%20button%20as%20shown%20below%3C%2FP%3E%0A%20%20%3CP%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F101161i62C030E01B0DE061%22%20%2F%3E%3C%2FP%3E%0A%20%20%3CP%3E4.%20In%20the%20search%20box%2C%20type%20%3CB%3E%20Function%20App%20%3C%2FB%3E%20and%20click%20on%20the%20%3CB%3E%20Function%20App%20%3C%2FB%3E%20resource%20as%20shown%20below%3C%2FP%3E%0A%20%20%3CP%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F101162iFBD9BAE3F1AA371C%22%20%2F%3E%3C%2FP%3E%0A%20%20%3CP%3E5.%20Click%20on%20%3CB%3E%20Create%20%3C%2FB%3E%20button%3C%2FP%3E%0A%20%20%3CP%3E6.%20In%20Function%20App%20blade%2C%20set%20name%20to%20%3CB%3E%20devbootcampdurable%20%3C%2FB%3E%20as%20shown%20below%3C%2FP%3E%0A%20%20%3CP%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F101163iE2D1AB2DAE9061B7%22%20%2F%3E%3C%2FP%3E%0A%20%20%3CP%3E7.%20Click%20on%20the%20%3CB%3E%20Create%20%3C%2FB%3E%20button%3C%2FP%3E%0A%20%20%3CP%3E8.%20Once%20the%20resource%20is%20created%2C%20navigate%20to%20this%20newly%20created%20Function%20App%20resource%3C%2FP%3E%0A%20%20%3CP%3E%3CBR%20%2F%3E%3C%2FP%3E%0A%20%20%3CH3%20id%3D%22toc-hId--1067083841%22%20id%3D%22toc-hId--1046765597%22%3E2.%20Add%20new%20Durable%20Function%3C%2FH3%3E%0A%20%20%3CP%3E%3CBR%20%2F%3E%3C%2FP%3E%0A%20%20%3CP%3E1.%20Open%20a%20new%20tab%20in%20the%20browser%20and%20navigate%20to%20Azure%20portal%20%3CA%20href%3D%22https%3A%2F%2Fportal.azure.com%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3E%20https%3A%2F%2Fportal.azure.com%3C%2FA%3E%3C%2FP%3E%0A%20%20%3CP%3E2.%20Go%20to%20%3CB%3E%20devbootcamp%20%3C%2FB%3E%20Resource%20Group%3C%2FP%3E%0A%20%20%3CP%3E3.%20Click%20on%20the%20%3CB%3E%20devbootcampdurable%7Byour%20alias%7D%20%3C%2FB%3E%20Function%20App%3C%2FP%3E%0A%20%20%3CP%3E4.%20Hit%20%3CB%3E%20%26gt%3B%26gt%3B%20%3C%2FB%3E%20button%20next%20to%20Functions%3C%2FP%3E%0A%20%20%3CP%3E5.%20Select%20%3CB%3E%20Function%20App%20Settings%20%3C%2FB%3E%20as%20shown%20below%3C%2FP%3E%0A%20%20%3CP%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F101164iD033432BE9DB12FE%22%20%2F%3E%3C%2FP%3E%0A%20%20%3CP%3E6.%20Set%20the%20Function%20Runtime%20to%20%3CB%3E%20beta%20%3C%2FB%3E%20as%20shown%20below%3C%2FP%3E%0A%20%20%3CP%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F101165iF0322F848849C1D1%22%20%2F%3E%3C%2FP%3E%0A%20%20%3CP%3E7.%20Now%20click%20on%20the%20%2B%20button%20next%20to%20Functions%3C%2FP%3E%0A%20%20%3CP%3E8.%20Select%20%E2%80%9C%20%3CB%3E%20Custom%20function%20%3C%2FB%3E%20%E2%80%9D%20as%20shown%20below%3C%2FP%3E%0A%20%20%3CP%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F101166i67F52763A66556AD%22%20%2F%3E%3C%2FP%3E%0A%20%20%3CP%3E9.%20Change%20the%20Scenario%20to%20%3CB%3E%20Durable%20Functions%3C%2FB%3E%3C%2FP%3E%0A%20%20%3CP%3E10.%20Click%20on%20the%20%E2%80%9C%20%3CB%3E%20Durable%20Functions%20HTTP%20starter%20%3C%2FB%3E%20%E2%80%9D%20C%23%20Function%20as%20shown%20below%3C%2FP%3E%0A%20%20%3CP%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F101167i7DC3D8BC3B85F795%22%20%2F%3E%3C%2FP%3E%0A%20%20%3CP%3E11.%20Next%2C%20you%20should%20see%20prompt%20to%20install%20%3CB%3E%20Durable%20Extensions%20%3C%2FB%3E%20as%20shown%20below%3C%2FP%3E%0A%20%20%3CP%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F101168iF038518B1B37C7E4%22%20%2F%3E%3C%2FP%3E%0A%20%20%3CP%3E12.%20This%20should%20take%20about%202%20min%20to%20complete.%20If%20you%20don%E2%80%99t%20see%20this%20dialog%20box%2C%20try%20again%3A%20go%20back%20to%20step%20%237%3C%2FP%3E%0A%20%20%3CP%3E13.%20Once%20the%20extension%20is%20installed%2C%20you%20should%20see%20this%20below%20success%20dialog%20box%3C%2FP%3E%0A%20%20%3CP%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F101169i6765A2BE32366CAE%22%20%2F%3E%3C%2FP%3E%0A%20%20%3CP%3E14.%20Next%2C%20portal%20will%20prompt%20to%20create%20a%20new%20Function.%3C%2FP%3E%0A%20%20%3CP%3E15.%20Set%20the%20name%20to%20%3CB%3E%20Main%20%3C%2FB%3E%20as%20shown%20below%3C%2FP%3E%0A%20%20%3CP%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F101170iBE4CD62BF4CC0739%22%20%2F%3E%3C%2FP%3E%0A%20%20%3CP%3E16.%20Review%20the%20%3CB%3E%20Main%20%3C%2FB%3E%20function%20code.%3C%2FP%3E%0A%20%20%3CP%3E17.%20See%20the%20%3CB%3E%20functionName%20%3C%2FB%3E%20variable%20and%20%3CB%3E%20instanceId%20%3C%2FB%3E%20variable%3C%2FP%3E%0A%20%20%3CP%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F101171i9E2E111D22406581%22%20%2F%3E%3C%2FP%3E%0A%20%20%3CH3%20id%3D%22toc-hId-675726494%22%20id%3D%22toc-hId-696044738%22%3E%3CBR%20%2F%3E%3C%2FH3%3E%0A%20%20%3CH3%20id%3D%22toc-hId--1876430467%22%20id%3D%22toc-hId--1856112223%22%3E3.%20Add%20Workflow%20Function%3C%2FH3%3E%0A%20%20%3CP%3E%3CBR%20%2F%3E%3C%2FP%3E%0A%20%20%3CP%3E1.%20Click%20on%20the%20%3CB%3E%20%2B%20%3C%2FB%3E%20button%20next%20to%20Functions%3C%2FP%3E%0A%20%20%3CP%3E2.%20Set%20the%20scenario%20to%20%3CB%3E%20Durable%20Functions%3C%2FB%3E%3C%2FP%3E%0A%20%20%3CP%3E3.%20Select%20%3CB%3E%20Durable%20Orchestrator%20Function%20%3C%2FB%3E%20as%20shown%20below%3C%2FP%3E%0A%20%20%3CP%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F101172i9FE65C981659DE7C%22%20%2F%3E%3C%2FP%3E%0A%20%20%3CP%3E4.%20Set%20the%20name%20of%20the%20function%20to%20%3CB%3E%20WorkflowOne%20%3C%2FB%3E%20as%20shown%20below%3C%2FP%3E%0A%20%20%3CP%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F101173i175807A1A6DA977E%22%20%2F%3E%3C%2FP%3E%0A%20%20%3CP%3E5.%20Click%20on%20the%20%3CB%3E%20Create%20%3C%2FB%3E%20button%3C%2FP%3E%0A%20%20%3CP%3E6.%20Once%20the%20WorkflowOne%20is%20created%2C%20review%20the%20code.%3C%2FP%3E%0A%20%20%3CP%3E7.%20There%20are%20three%20activity%20calls%20to%20%3CB%3E%20Hello%20%3C%2FB%3E%20Function%20show%20below%3C%2FP%3E%0A%20%20%3CP%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F101174i874F83E9408FE7BF%22%20%2F%3E%3C%2FP%3E%0A%20%20%3CP%3E8.%20Change%20the%20Function%20name%20from%20%3CB%3E%20Hello%20%3C%2FB%3E%20to%20%3CB%3E%20ActivityOne%20%3C%2FB%3E%20%2C%20%3CB%3E%20ActivityTwo%20%3C%2FB%3E%20%2C%20%3CB%3E%20ActivityThree%20%3C%2FB%3E%20as%20shown%20below%3C%2FP%3E%0A%20%20%3CP%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F101175i96F38D7763C5E047%22%20%2F%3E%3C%2FP%3E%0A%20%20%3CH3%20id%3D%22toc-hId--133620132%22%20id%3D%22toc-hId--113301888%22%3E%3CBR%20%2F%3E%3C%2FH3%3E%0A%20%20%3CH3%20id%3D%22toc-hId-1609190203%22%20id%3D%22toc-hId-1629508447%22%3E4.%20Add%20Activity%20One%20Function%3C%2FH3%3E%0A%20%20%3CP%3E%3CBR%20%2F%3E%3C%2FP%3E%0A%20%20%3CP%3E1.%20Click%20on%20the%20%3CB%3E%20%2B%20%3C%2FB%3E%20button%20next%20to%20Functions%3C%2FP%3E%0A%20%20%3CP%3E2.%20Set%20the%20scenario%20to%20%3CB%3E%20Durable%20Functions%3C%2FB%3E%3C%2FP%3E%0A%20%20%3CP%3E3.%20Select%20%3CB%3E%20Durable%20Functions%20activity%20%3C%2FB%3E%20as%20shown%20below%3C%2FP%3E%0A%20%20%3CP%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F101176iACF1EBF0954E91BC%22%20%2F%3E%3C%2FP%3E%0A%20%20%3CP%3E4.%20Set%20the%20name%20of%20the%20function%20to%20%3CB%3E%20ActivityOne%20%3C%2FB%3E%20as%20shown%20below%3C%2FP%3E%0A%20%20%3CP%3E5.%20Click%20on%20the%20%3CB%3E%20Create%20%3C%2FB%3E%20button%3C%2FP%3E%0A%20%20%3CP%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F101177i137F9DB0B84676F3%22%20%2F%3E%3C%2FP%3E%0A%20%20%3CP%3E6.%20Review%20the%20function%20code%3C%2FP%3E%0A%20%20%3CP%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F101178i40E26BD4E6F1045B%22%20%2F%3E%3C%2FP%3E%0A%20%20%3CP%3E7.%20Update%20the%20code%20as%20shown%20below%3A%3C%2FP%3E%0A%20%20%3CP%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F101179i2FEC51FEBE281E34%22%20%2F%3E%3C%2FP%3E%0A%20%20%3CP%3E8.%20Add%20two%20more%20activity%20functions%2C%20just%20go%20back%20to%20step%20%23%201%3C%2FP%3E%0A%20%20%3CP%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F101180i7638A5E885B1106A%22%20%2F%3E%3C%2FP%3E%0A%20%20%3CH3%20id%3D%22toc-hId--942966758%22%20id%3D%22toc-hId--922648514%22%3E%3CBR%20%2F%3E%3C%2FH3%3E%0A%20%20%3CH3%20id%3D%22toc-hId-799843577%22%20id%3D%22toc-hId-820161821%22%3E5.%20Start%20Workflow%3C%2FH3%3E%0A%20%20%3CP%3E%3CBR%20%2F%3E%3C%2FP%3E%0A%20%20%3CP%3E1.%20Click%20on%20the%20%3CB%3E%20Main%20%3C%2FB%3E%20function%3C%2FP%3E%0A%20%20%3CP%3E2.%20Click%20on%20the%20%3CB%3E%20Get%20Function%20URL%20%3C%2FB%3E%20link%20as%20shown%20below%3C%2FP%3E%0A%20%20%3CP%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F101181iB7F18C91F5E1A96C%22%20%2F%3E%3C%2FP%3E%0A%20%20%3CP%3E3.%20Next%20click%20on%20the%20copy%3C%2FP%3E%0A%20%20%3CP%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F101182i51D152ADF94FF815%22%20%2F%3E%3C%2FP%3E%0A%20%20%3CP%3E4.%20Open%20PostMan%20(install%20it%20from%20%3CA%20href%3D%22http%3A%2F%2Fgetpostman.com%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttp%3A%2F%2Fgetpostman.com%3C%2FA%3E)%3C%2FP%3E%0A%20%20%3CP%3E5.%20Copy%20this%20URL%20into%20PostMan%3C%2FP%3E%0A%20%20%3CP%3E6.%20Rename%20%3CB%3E%20%7BfuncitonName%7D%20%3C%2FB%3E%20with%20%3CB%3E%20WorkflowOne%20%3C%2FB%3E%20as%20shown%20below.%3C%2FP%3E%0A%20%20%3CP%3E7.%20Set%20the%20HTTP%20to%20%3CSTRONG%3E%20POST%20%3C%2FSTRONG%3E%20and%20click%20on%20Send%3C%2FP%3E%0A%20%20%3CP%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F101183i376E60677CAB81B3%22%20%2F%3E%3C%2FP%3E%0A%20%20%3CP%3E8.%20Review%20response.%20Look%20for%20%3CB%3E%20statusQueryGetUri%3C%2FB%3E%3C%2FP%3E%0A%20%20%3CP%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F101184i514C82FE599ACB53%22%20%2F%3E%3C%2FP%3E%0A%20%20%3CP%3E9.%20Now%20click%20on%20the%20%3CB%3E%20statusQueryGetUri%20%3C%2FB%3E%20URL%20in%20the%20PostMan%3C%2FP%3E%0A%20%20%3CP%3E10.%20Add%20these%20to%20end%20of%20the%20URL%20and%20click%20on%20the%20SEND%20as%20shown%20below%3C%2FP%3E%0A%20%20%3CP%3E%3CB%3E%20%26amp%3BshowHistory%3Dtrue%26amp%3BshowHistoryOutput%3Dtrue%20%3C%2FB%3E%3C%2FP%3E%0A%20%20%3CP%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F101185i0FB933D3E74F7F6F%22%20%2F%3E%3C%2FP%3E%0A%20%20%3CP%3E11.%20Review%20response.%20Look%20for%20output%20for%20the%20workflow%20and%20individual%20activities%3C%2FP%3E%0A%20%20%3CP%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F101186iFC0E183CA8ACDCE5%22%20%2F%3E%3C%2FP%3E%0A%20%20%3CH3%20id%3D%22toc-hId--1752313384%22%20id%3D%22toc-hId--1731995140%22%3E%3CBR%20%2F%3E%3C%2FH3%3E%0A%20%20%3CH3%20id%3D%22toc-hId--9503049%22%20id%3D%22toc-hId-10815195%22%3E6.%20Wait%20for%20External%20Event%3C%2FH3%3E%0A%20%20%3CP%3E%3CBR%20%2F%3E%3C%2FP%3E%0A%20%20%3CP%3E1.%20Go%20back%20to%20%3CB%3E%20WorkflowOne%20%3C%2FB%3E%20function%3C%2FP%3E%0A%20%20%3CP%3E2.%20Add%20these%20lines%20before%20return%20statement%20as%20shown%3C%2FP%3E%0A%20%20%3CP%3Estring%20strApprovalEvent%20%3D%20await%20context.WaitForExternalEvent%3CSTRING%3E(%22ApprovalEvent%22)%3B%3C%2FSTRING%3E%3C%2FP%3E%0A%20%20%3CP%3Eif(strApprovalEvent%20%3D%3D%20%22true%22)%3C%2FP%3E%0A%20%20%3CP%3E%7B%3C%2FP%3E%0A%20%20%3CP%3Eoutputs.Add(%22Approved%22)%3B%3C%2FP%3E%0A%20%20%3CP%3E%7D%3C%2FP%3E%0A%20%20%3CP%3Eelse%3C%2FP%3E%0A%20%20%3CP%3E%7B%3C%2FP%3E%0A%20%20%3CP%3Eoutputs.Add(%22Rejected%22)%3B%3C%2FP%3E%0A%20%20%3CP%3E%7D%3C%2FP%3E%0A%20%20%3CP%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F101187i5A23AB1CAFCE060C%22%20%2F%3E%3C%2FP%3E%0A%20%20%3CP%3E3.%20Start%20a%20new%20instance%20of%20Workflow%2C%20by%20click%20on%20the%20PostMan%20URL.%20Follow%20the%20%3CB%3E%20step%20%231%20%3C%2FB%3E%20in%20the%20previous%20section%3C%2FP%3E%0A%20%20%3CP%3E4.%20Now%20try%20to%20get%20the%20status%20of%20the%20Workflow%2C%20Follow%20the%20%3CB%3E%20step%20%23%209%20%3C%2FB%3E%20in%20the%20previous%20section%3C%2FP%3E%0A%20%20%3CP%3E5.%20Review%20the%20results.%20Workflow%20is%20still%20running%20and%20all%20three%20activities%20are%20done.%3C%2FP%3E%0A%20%20%3CP%3E6.%20Workflow%20is%20now%20waiting%20for%20external%20event%20as%20shown%20below%3C%2FP%3E%0A%20%20%3CP%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F101188i23F6EDF1EAB5E710%22%20%2F%3E%3C%2FP%3E%0A%20%20%3CP%3E7.%20Now%2C%20click%20on%20the%20%3CB%3E%20sendEventPostUri%20%3C%2FB%3E%20URL%20from%20the%20PostMan%20results%20for%20starting%20workflow%3C%2FP%3E%0A%20%20%3CP%3E8.%20Remane%20the%20%3CB%3E%20%7BeventName%7D%20%3C%2FB%3E%20with%20%3CB%3E%20ApprovalEvent%20%3C%2FB%3E%20as%20shown%20below%3C%2FP%3E%0A%20%20%3CP%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F101189iE5D73CA3B7946E9B%22%20%2F%3E%3C%2FP%3E%0A%20%20%3CP%3E9.%20Change%20the%20HTTP%20method%20to%20%3CB%3E%20POST%3C%2FB%3E%3C%2FP%3E%0A%20%20%3CP%3E10.%20Select%20the%20%3CB%3E%20Body%20%3C%2FB%3E%20%2C%20select%20%3CB%3E%20raw%20%3C%2FB%3E%20and%20content%20type%20to%20%3CB%3E%20JSON%3C%2FB%3E%3C%2FP%3E%0A%20%20%3CP%3E%3CB%3E%2011.%20%3C%2FB%3E%20In%20the%20body%20field%20type%20%3CB%3E%20%E2%80%9Ctrue%E2%80%9D%3C%2FB%3E%3C%2FP%3E%0A%20%20%3CP%3E12.%20Hit%20Send%20button%20as%20shown%20below%3A%3C%2FP%3E%0A%20%20%3CP%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F101190i00C1EEC3D2AFFC72%22%20%2F%3E%3C%2FP%3E%0A%20%20%3CP%3E13.%20Now%20check%20the%20status%20again.%20Follow%20the%20%3CB%3E%20step%20%23%209%20%3C%2FB%3E%20in%20the%20previous%20section%3C%2FP%3E%0A%20%20%3CP%3E14.%20Review%20the%20output.%20Do%20you%20see%20%3CB%3E%20Approved%20%3C%2FB%3E%20message%20%3F%3C%2FP%3E%0A%20%20%3CP%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F101191i76D10A0F8CA43027%22%20%2F%3E%3C%2FP%3E%0A%20%20%3CP%3E%3CA%3E%20%3C%2FA%3E%2015.%3C%2FP%3E%0A%20%0A%3C%2FLINGO-BODY%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-392580%22%20slang%3D%22en-US%22%3EFirst%20published%20on%20MSDN%20on%20May%2021%2C%202018%20This%20blogs%20talks%20about%20how%20to%20create%20a%20simple%20Durable%20Function%20App.%3C%2FLINGO-TEASER%3E
Microsoft
First published on MSDN on May 21, 2018


This blogs talks about how to create a simple Durable Function App.

There are three components to Durable Function App.

  1. Main / Starter Function
  2. Workflow / Orchestrator Function
  3. Activity Function

Durable Function App needs all three functions. Main / Starter function is responsible for starting a workflow instance. Workflow / Orchestrator function has workflow logic, calls activities and waits for external events. Activity function, actual work is implemented here.

In this sample Durable Function App, we are going to create a workflow with three activities and one external event. We are going to start workflow via PostMan. We are also going to use PostMan to get workflow instance status and to fire external events.

Here are high level steps:

  1. Create Function App
  2. Create Main / Starter Function
  3. Create Workflow Function
  4. Create Activity Function
  5. Start Workflow
  6. Workflow with external events


1. Create Function App


1. Log into Azure Portal: https://portal.azure.com

3. Click on the Add button as shown below

4. In the search box, type Function App and click on the Function App resource as shown below

5. Click on Create button

6. In Function App blade, set name to devbootcampdurable as shown below

7. Click on the Create button

8. Once the resource is created, navigate to this newly created Function App resource


2. Add new Durable Function


1. Open a new tab in the browser and navigate to Azure portal https://portal.azure.com

2. Go to devbootcamp Resource Group

3. Click on the devbootcampdurable{your alias} Function App

4. Hit >> button next to Functions

5. Select Function App Settings as shown below

6. Set the Function Runtime to beta as shown below

7. Now click on the + button next to Functions

8. Select “ Custom function ” as shown below

9. Change the Scenario to Durable Functions

10. Click on the “ Durable Functions HTTP starter ” C# Function as shown below

11. Next, you should see prompt to install Durable Extensions as shown below

12. This should take about 2 min to complete. If you don’t see this dialog box, try again: go back to step #7

13. Once the extension is installed, you should see this below success dialog box

14. Next, portal will prompt to create a new Function.

15. Set the name to Main as shown below

16. Review the Main function code.

17. See the functionName variable and instanceId variable


3. Add Workflow Function


1. Click on the + button next to Functions

2. Set the scenario to Durable Functions

3. Select Durable Orchestrator Function as shown below

4. Set the name of the function to WorkflowOne as shown below

5. Click on the Create button

6. Once the WorkflowOne is created, review the code.

7. There are three activity calls to Hello Function show below

8. Change the Function name from Hello to ActivityOne , ActivityTwo , ActivityThree as shown below


4. Add Activity One Function


1. Click on the + button next to Functions

2. Set the scenario to Durable Functions

3. Select Durable Functions activity as shown below

4. Set the name of the function to ActivityOne as shown below

5. Click on the Create button

6. Review the function code

7. Update the code as shown below:

8. Add two more activity functions, just go back to step # 1


5. Start Workflow


1. Click on the Main function

2. Click on the Get Function URL link as shown below

3. Next click on the copy

4. Open PostMan (install it from http://getpostman.com)

5. Copy this URL into PostMan

6. Rename {funcitonName} with WorkflowOne as shown below.

7. Set the HTTP to POST and click on Send

8. Review response. Look for statusQueryGetUri

9. Now click on the statusQueryGetUri URL in the PostMan

10. Add these to end of the URL and click on the SEND as shown below

&showHistory=true&showHistoryOutput=true

11. Review response. Look for output for the workflow and individual activities


6. Wait for External Event


1. Go back to WorkflowOne function

2. Add these lines before return statement as shown

string strApprovalEvent = await context.WaitForExternalEvent<string>("ApprovalEvent");

if(strApprovalEvent == "true")

{

outputs.Add("Approved");

}

else

{

outputs.Add("Rejected");

}

3. Start a new instance of Workflow, by click on the PostMan URL. Follow the step #1 in the previous section

4. Now try to get the status of the Workflow, Follow the step # 9 in the previous section

5. Review the results. Workflow is still running and all three activities are done.

6. Workflow is now waiting for external event as shown below

7. Now, click on the sendEventPostUri URL from the PostMan results for starting workflow

8. Remane the {eventName} with ApprovalEvent as shown below

9. Change the HTTP method to POST

10. Select the Body , select raw and content type to JSON

11. In the body field type “true”

12. Hit Send button as shown below:

13. Now check the status again. Follow the step # 9 in the previous section

14. Review the output. Do you see Approved message ?

15.