 Hi there, we'll do another edition of Tuesdays with Corey. I'm back with the existing person Jeff Still breathing still breathing still here still quite humble. Thanks to my lack of action Introductory my Salutation as it were the the the alive Truth It's accurate today. We are going to be spending more time on Azure functions Azure functions and serverless or just as a function pretty we're just gonna focus on Azure functions So what are we so you there's some newness there is one to talk about there is this is this is Fairly hot off the press So one of the things with Azure functions, so we mentioned it in the last episode, which is we haven't watched You need to definitely. It's about it's about a minute of value with seven minutes of garbage So with that So one of the challenges that happens when you're dealing with Azure functions in general and serverless functions This is it unique to Azure is what if I have a process that is complex or long-running and I need to Manage that entire process now before I even go further We showed you in the last one as your logic apps, which is a phenomenal thing to orchestrate across different functions And it does have some capabilities like looping. Yes, but there are still some patterns like If you have a big file that comes in and let's say you have a thousand customer records And you need to go split all of those thousand of records into individual executions You'd like to not have to pull it in every time and then aggregate back in yeah So if you do this by hand today or even with logic apps, it can get very complicated So there's a new piece of functionality for Azure functions called durable functions beautiful. Got it. You got it You nailed that I did and so what durable lets you do is write an orchestration piece all within your function So this is in C sharp no visual designer you code this thing, but it can run Forever it can run as long as you want and it's managing the state and making sure like oh, hey I just spit out a thousand so it doesn't have a time limit for how long it runs. That's right Really the key point. Yeah, okay, and you said C sharp but not exclusively C sharp or exclusively C sharp great question So so and I actually don't know the answer which is what it is scary So there's two pieces to kind of a durable function application One are the actions that you take like go process this record Those actions or activities can be written in any of the languages supported by Azure functions So JavaScript Java C sharp for the time being the orchestration piece the thing that tells you what to do Can only be written in C sharp, but we are working on making accessible for other languages Okay, so you viewers tweet us and let us know which languages you would like to see first Is that fair? Well, I mean I'm kind of landing canceling the whole show now. Yeah, that's fair But C sharp is a beautiful language, please sweet Please tweet us back the Recommendations that you have for languages. Yeah, I have I have I'll have some words with these guys Yeah, please proceed so I'm gonna show you a quick sample app right now just to show you what that one of these looks like So this one's kind of a fun scenario. I have here on my desktop. This is my phone messaging app Okay, because what I wanted to do I know and we weren't invited The functions guys never get invited What I wanted to do here was I I don't know if you've heard of crypto currencies. I haven't eat like Bitcoin Yeah, yeah or Ethereum Again, I'm not seeing very well. Yes, you really kill any on the Asian acting one of the things I wanted to do is Can you watch the price of a coin like I want to get an alert? I want to get a text message alert if Bitcoin crosses a certain threshold or if Ethereum crosses a threshold So I wanted to do this serverlessly and what I wanted to do actually just show you now I'm gonna send a text that says like watch Bitcoin to tell me if it crosses. I don't know $15,000 for right now. I'm sending that text It's firing off an Azure function what you're gonna notice is it's gonna send me back a response here that says We're now watching this coin for you So what you'll see is it actually responded back to me and said hey I'm now watching the price of this I will send you a text message alert if it crosses it and if you want to stop watching text this now I don't want to just watch for five minutes I actually want to watch for like a week or two weeks to know like when should I sell on my stuff So what's powering this behind the scenes is a durable function? Okay, so this is the durable function behind the scenes and this is what the type of stuff you can write So I've been able to write in this durable orchestrator This while loop that says continue to do this action while my the current price is less than the price that I set and While the timeout hasn't been reached because I set a timeout I only want this watch for like a week and if it's more than a week and it doesn't cross it just it's quit working But I like I'm watching Bitcoin here. I could just as easily say like hey Stock market or like go ping my site or watch a newsfeed or like any type of watch or something where I'm spinning up a worker So I sleep for 15 minutes wake up give the current price and just keep doing this Again, we I should have probably prepped on this question at a time Why would you use this versus? Like building your own service right like if you're gonna run it for this long period of time And it's just kind of sitting there right like is it still serverless. Let me see I mean, let's get into some theory. Yes. Yeah for sure So the interesting thing about durable functions behind the scenes is it actually only is running And you're only getting billed when an actual action is taking place. Okay, so when I say sleep for 15 minutes here We actually scale down to zero. Oh, interesting. Yeah, we get rid of everything So it is very much in people's so while they do have durable functions These types of listener some types of functions It's very important for people to be smart about how they put their sleeps in because if they're or their wait periods Sure, because if they are gonna do these wait periods, they're not gonna get charged So that then makes it sort of an ongoing ongoing cyclical event. Sure. Yeah. Yeah, that's that's fair That's fair way. Maybe you haven't thought about it. I've learned something today So the the reason potentially do I do this is one like I can have this long-running process without having to worry about Managing to make sure like is my server alive all the time is my service And then there's patterns that like if you're using functions like here I'm doing a loop maybe I'm just orchestrating a call to a bunch of different functions like if you're familiar with like dependency injection where you want to have a bunch of dependencies, but Dynamically call them you can do that dynamic kind of dependency of functions thing here and have it be serverless So this thing's running but at the same time because it's only waking up every 15 minutes It's still super inexpensive and if I went crazy and I started watching for a bunch of coins Like now I want to watch to see if Cori coin, which is a hot new coin on the market is What's that now a billion so I'm gonna see if it crosses two billion I could go and set up a bunch of these watchers and it's gonna be able to dynamically scale to as many as I need So now it's watching Cori coin, which probably threw an exception behind the scenes unless this coin actually exists But yeah, so that's that's durable functions There's there's it's a more advanced feature of Azure functions for sure But if you are using Azure functions, if you want any sort of orchestration that this might be the right fit There's a few patterns that we recommend. This is really good for we've got some good samples out there But I did want to show it because it can be a powerful tool when you want something serverless But you need it to be a little bit longer or more Stateful than a traditional ephemeral function like that. We're there ephemeral. That's nice. Yeah That was the word of the day today I Pull him back from peewee Herman You didn't even know that was for my time for my time. Oh my goodness. Anyway. All right. Well, this has been I mean really fun Thank you No, thank you back again So, okay, so we should expect So very cool. So basically again these durable functions be able to take advantage of Sort of ongoing functions yet still pay for as you use it which is super valuable and been different from if you set this up as a Service that's running like on a VM or what have you? Yep and You can have it run back-end code. That's any of the languages this front-end code is Dot net only that's correct. Yeah, but we'll be supporting other languages in the soon future in the soon future There you go. All right, and thank you so much for having and thank you guys so much for joining I hope this was a fun show for you as much as it was for us and We'll be we'll be in touch. So it is up in a Azure TWC hashtag at TWC ask questions ask his comments And we'll get back to you. So with that have a wonderful Tuesday. Bye. Bye You check the battery system Thanks, thanks. No, I mean, it's worth our time. Thanks a lot, right? I'm talking about The bank robber was denied a bank The scorpion was denied I owe I owe what I owe. What are you doing that durable functions? Durable Make sure you're doing that Durable a lot of people get stripped up. They say durable durable not that's not what this is That is something else. That's actually a beautiful a beautiful soup With rice and chicken durable functions from assemble This is durable durable function Jeff you've stopped and started a new recording now