 Alright welcome everyone. We have 30 minutes. There's a bunch that I want to cover today. So first off as was mentioned I'm Jeff Holland. I am a program manager. I work in the engineering team out of Seattle So I was very excited for the chance to travel out here with a few members from our team as well and talk to you today About Python and specifically with Azure serverless now before we start just to get a feel for the room How many of you here have already used serverless in some form or fashion? That's AWS Lambda Azure functions Google Cloud functions Okay, great. So about 20% and then of those how many of used Azure functions specifically? Okay, I'm very few great. So everyone will learn something today. Let's get started then so for for those who Maybe didn't raise their hand Before I even start I want to set some context like what is serverless? What is with all of the people talking about serverless? How much is hype? How much is just vapor? And to kind of explain how I think about serverless I wanted to use this analogy and that's how did I get here today or how did any of you get here today and specifically this one the the public transportation in Switzerland is a little bit better Than when I give this talk elsewhere and maybe the United States But for me I landed at the airport yesterday morning and I had a problem to solve How do I get from the airport to the Congress Center and there was one option? I'm only gonna be here for a few days. I could have bought a car I could have walked from the airport to a car dealership. I assume there's one close I could have picked out a car put down whatever a couple thousand euros Registered that car with the government. I assumed that on an American passport. I could buy a car I don't even know pay taxes There's a lot that that would involve right. I would now be maintaining that car I would need to make sure that had fuel. I'd need to navigate to the Congress Center And now I own this massive asset of a car for my trip to Switzerland might be a little bit overkill So the other option that's pretty popular is maybe I could just rent a car Rather than just purchase one outright. Maybe I walk down to the car rental Like Avis or something and I say hey, I'm gonna be here for four days. Can I have a car for four days? They're like sure. Here's the keys You're gonna pay 50 euros a day in this car is yours So now it's a lot easier than buying a car. I don't have to worry about changing the oil I don't have to worry about paying taxes or registering the vehicle And now the only things I have to care about are making sure that it has fuel I still have to look up directions to the Congress Center and for times like right now where I'm not driving I'm actually in front of all of you talking. I'm still paying for my rental car whether I'm using it or not I'm still paying that daily rate So the last option which is actually what I'd use whenever I travel is rideshare And this is the ability so that I really go to the airport I opened up the uber app. I said hey, I need to get from the airport to the Congress Center Immediately a car pulled up. They said hey Jeff come on in. I jumped in the back seat Payment was taking care of I didn't ever think about directions. I couldn't tell you how I got here It just happened the driver was concerned about the fuel the driver was concerned about directions I just got in the car got to my destination and I only paid for that car During the time I was actually traveling So why did I give you this wonderful monologue about the decision I made when coming to? Euro Python and the reason is because you can kind of think of this in your different options For how you host your code and how you can run your code So if I have a Python application that I want to run I could go build or maintain my own servers I could get virtual servers in the cloud. Maybe I actually use my own hardware. It's totally feasible It's something I could do but there's a lot of things that now I need to manage and maintain I need to make sure that those operating systems are up to date I need to make sure that my machines have power if I get a big load of traffic I need to make sure that I have enough capacity. Those are all things that now I need to be aware of in managing Now there's also these platform as a service offerings, whether it's in Azure or an AWS or Red Hat or Pivotal These are nice. This makes it so I'm not often managing the underlying machines But I still am in charge of a few things. I need to make sure that it's skilled appropriately I need to make sure that I'm following the kind of constraints of that platform service and very likely I'm paying a fixed cost Whether my code is actually running or not Now serverless to me is very much like this rideshare world in serverless. All you care about is your code You write your code you attach it to the event that you care about and you publish that to the cloud Every other aspect of that application how it scales how highly available it is the security of the operating system All of those aspects that frankly aren't that much fun to deal with get managed by the cloud provider for you in the reason that this is Appealing to a growing number of developers and teams is because it allows me to focus on Solving the problems that I want to solve and some of those other aspects that still need to be solved Maybe I'm okay. Not being the person who's managing that So for Azure Function specifically we have a few languages available today as we start talking about Azure Functions net node Which includes JavaScript and TypeScript Java? Python is in preview today, but I'm really excited. We're actually rolling out the general available update for Python in this next week So very shortly if you keep an eye on blogs Python will be generally available in a few short weeks and as well PowerShell as a language Azure Functions itself is completely open source So not included on this slide or some community contributed languages like go and rust And when we double click on Python specifically There's a few key points that I want to call out here and after this slide I'm actually going to work through and we're going to build a Python Azure Function together So you can actually see the experience a few things the first Azure Functions is entirely open sourced You can see all of the code for every tool the runtime the Python All of that is on GitHub and we love contributions from the community. So feel free to get involved One of the awesome things about Azure Functions though is that the rich development experience that you get and specifically with tools like visual studio code So we're going to spend our time in visual studio code today and it gives you things like local debugging Rich IntelliSense easy published to the cloud now. You don't have to use visual studio code You can use pie charm. You can use sublime You can use any editor you really want the tools work across all editors, but we have a first-class integration with VS code You can trigger your code and you can say hey, I want this Python script to run on a number of different event sources It's going to scale Automatically for you and if your code is never executed if your code never triggers you never pay any money And even when it does trigger you get like a million executions free every single month So very often even when your code does run, you're still not paying us anything. So it's great You get some rich monitoring capabilities and you can also set up some rich CICD whether using Travis Azure DevOps or any CICD tool Jenkins you name it So let's go through now that we kind of have an understanding of what serverless is Azure functions in Python and we want to build something and what I want to build is a simple function a simple API They can analyze the sentiment of some text, right a very hello world kind of example And it's going to allow us to walk us through this experience in the tools So I mentioned we're going to spend most of our time in visual studio code So that's where I'm at now kind of an empty editor. I'll call out a few things There's a few extensions in visual studio code that I'm going to be using to make our life even better The first is this Azure functions extension, which gives us some nice Azure functions tooling The other one here is the Python extension, which is going to give us some nice language options I've got a lot of extensions. So I took me a while to get to the piece Python Obviously all of these with visual studio code are all free and easy to install But if you want to follow along at home, that's what you would need to do So now that I have the Azure functions extension I can go ahead and click in here to the Azure icon and say alright Let's create a new function So I'm going to create a brand new project We'll get a folder for it Let's call this one Euro Python And the first thing it wants to know is what language I want to write this function in Obviously, we want to do Python because we believe in the one true language of Python And I have all of these different event sources. I could make this run every five minutes I could make it run every Friday at 10 a.m. I Could have it trigger on an HTTP request Whenever an image gets uploaded to an Azure storage account or a message gets dropped into queue some data changes in a database You get the idea. There's a lot of different event sources that can say hey go run this script Now I mentioned we want to write an API for sentiment. So we're going to choose the HTTP trigger We're going to call this analyze sentiment. It's going to be the name of our function. I Could require that there's a key and some authentication to invoke this function in this case I'm just going to keep it anonymous and We'll open it in the current window So now the Azure functions extension in visual studio code is going and scaffolding for me this function project And it's gone ahead and open for me now kind of the base template for an HTTP triggered Azure function So this is all the code that exists in my project There's some metadata here that tells it what trigger it uses I also have my requirements dot txt file, which is empty right now But this is the only code that's actually in my whole project. It's very very lightweight It looks almost just like a simple script or a console application But instead of getting passed in like some arguments some string arguments from the command line I actually am getting an HTTP request. So when someone triggers this function, it's going to be an HTTP request And I can now use pieces of that request whether it's the body query parameters inside my code now The simple template is just a hello world function It's just going to look to see if you pass in a name is either a query parameter in the body of the message and Return back a nice and friendly hello, whatever your name was Now what I want to show quickly here before we start analyzing sentiment is again One of the nice things with Azure function is all of the tooling. So I'm going to go ahead here and set a break point And let's go ahead and say we want to start debugging And this is going to go ahead and start a debug session here in visual studio code I didn't have to do a whole lot to do that. I always want to show this flashy ascii art Right now on my Macbook. This could be Windows. It could be Linux. I'm running that open sourced Azure functions runtime So this is the same runtime that will be executing in the cloud But in this case, it's actually running on my machine It's noticed I have this HTTP triggered function and it's even given us this nice local endpoint that I can use to test So let's test it out now. Let's go ahead and send a request to this function So I'm going to go ahead here. I have another very cool visual studio extension That actually lets me send HTTP requests when I just annotate them with this cool Annotation so I'm going to say do a post to that URL and we want the content type to be JSON and Now this awesome visual studio code extension called rest client will let me send the request right here in the editor So I'm going to go ahead and send that request and as soon as I click the send button my breakpoint was hit I'm now debugging this function as I step through it I can see that I got my name property in this case. I left my name is Azure my name is actually Jeff But that's fine. You can call me Azure And when I finish the debug session I get back my response that says hello, Azure So that's kind of the basic experience creating the function debugging it the last step that I would do here is publishing But before we get there, let's actually add in some more complex code I want to do that sentiment analysis like I mentioned and I'm actually going to use a Dependency here that maybe some of you have used before called text blob Which gives me a bunch of machine learning capabilities to analyze text pull out the key phrases pull out the nouns pull out the sentiment and I'm going to replace this kind of basic hello world code and I'm going to faster than you could have believed type in because I didn't type it in type in this code to use text blob To look at the text and pull out the sentiment polarity Now you'll see this in a second But what it's actually going to return back is a number that number is going to be between negative one and one The closer to positive one is the more positive the sentiment the closer to negative one the more negative the sentiment Let's go ahead here. I make sure I'm importing the right stuff as well again using my amazing typing skills So at this point I pretty much have everything I need I could actually run this right now in debug And when I go ahead and run it I could show you now if I say debug again The first thing it's going to do is it's going to go ahead and pull in that text blob Dependency and use it to run for me. So if we now change this It's now running the same thing. It's now analyzing sentiment. I'll go ahead and change this. I'm not passing in a name anymore I'm type passing in text. I'm going to say I am so so happy Go ahead and save that and click send. Oh, I left my break point hanging around. That's okay And you'll see here now I get a sentiment of point eight, right? This was very happy I could even quickly come in and make this one change to I am so so sad and now it's negative point five So my code's working now. I have a simple Python script It's going to get an HTTP request and it's going to tell me the sentiment of whatever the text I passed in Now the one thing I want to call out when I use this library this text blob file locally How it's actually working is that it installed on my machine. I'll show you this at the home directory As part of the what is it nLTK library? There's these nLTK data models that right now are at my home directory that you can kind of see here When I publish this function, it's very important that my function has access to these same models, right? These are the models that my Python function needs So in order to do that I just need to make sure that I actually copy these models into my project directory, right? so now I'm here in the project directory Euro Python and I'm just going to copy the models nLTK data Into the current project. So now those models are available there and I just need to add one more line. Oh Did my super fast typing not work that time it did and this line is just saying hey nLTK You can actually find the models in the current directory. Don't go look at the home directory, right? So just a pattern that's worth noting if you're using things like models in your function You can just include those models in your project directory column directly then And now when I publish which is the last step It's going to take this entire directory the Python script the models It's going to look at the requirements.txt file and it's going to put them in a zip send them to Azure Now one of the new features that we actually are just rolling out now, which I'm going to show you is that when I choose to publish this I actually don't need this flag anymore Text blob requires some native dependencies It requires that I have native Linux dependencies when it runs on Linux when it runs on max It's different when it runs on Windows. It's different still and rather than making you deal with the complexity of knowing Oh shoot. I just built this on my windows or Mac. It's going to be running in a Linux container in the cloud How do I get the right versions? One of the features that we have now is that when I go ahead and click publish And when I say now I mean rolling out in the next week or two now for me because I'm running these bits now What it should do at first. Oh, actually, I need to make sure I've authenticated with my account I realize I haven't done this yet Entari's demo this one will work what it's going to do is it's going to Look at this function that I have realized that it's a Linux Python function It's going to archive the directory like I mentioned But the cool new feature I wanted to call out is that it's actually going to go pull down and do a remote build of Any requirements that I've defined in my requirements dot txt file So it's actually going to use the Linux environment in the cloud to pull in the text blob dependency Do all the building there? You can see it's doing the server side build right now It's uploading my files all this is done for me. So regardless if I'm developing on Windows Mac or Linux I'm confident knowing that my apps going to run successfully in the cloud using this new server side build tools as part of the Azure functions Experience now once that's done, and we don't even have to wait for it fully It's going to give me back a URL that then anybody could call. It's not a local host URL anymore It's going to be a dot azure websites net URL that anyone could then call Passing some text and it's going to give you back a score So it's that easy to kind of get up and running Include dependencies that you need include models that you need and then finally publishing it to the cloud In this case I use the command line because I wanted to show off that new functionality I could have also done the publish directly from right here in visual studio code So once this is there in the cloud I actually have one that I published ahead of time because I figured that it would take a little bit to do the Publishing and build on the internet connection here, but I do have one. It's a dot azure websites net URL and if I go ahead here now and just click the send request button It's going to send the same text off to in this case now this cloud hosted function And now running in the cloud that same Python code is now available to anyone. Okay now to kind of bring this home I want to show you, you know, hopefully you've seen this is a very productive development experience I can quickly get something like a Python script attached to an HTTP request and running One of the other benefits here is the scale the fact that now if everyone in this room tried to call the same API If everyone in this whole city tried to call the same API I want to know that it's going to scale and be available to everyone So to prove this and for the last five minutes, we're going to attach this to some data So I'm going to take that same function that I just wrote the analysis sentiment What I actually want to do is I want to populate this real-time dashboard. So this dashboard is empty right now It's very lonely. This is a product called Microsoft power bi and what I actually want to attach it to is I want this to tell me everyone in the world who's tweeting And I want to know the sentiment of those tweets and where they're tweeting from and the thing that's going to drive Understanding the sentiment is going to be calling that Azure function. We just published Now to attach it to some data I'm going to use another serverless piece of technology in Azure called Azure logic apps Now logic apps is a little bit different than Azure functions because in this case, I don't actually create code With logic apps, it's serverless in the same ways that it scales to zero or scales to n But here I actually create workflows and I can integrate with different services So I want to connect my Azure function to Twitter Just to show you some of how Azure logic apps works There's actually over 200 out of the box connectors here that you can use in your serverless applications in Azure To connect to services like Twitter. I'm scrolling down. You probably recognize these other ones Hey, when someone uploads something to Dropbox when someone adds something to github sales force SAP on-premises Dynamics 365 one drive Google Drive send grid you get the idea, right? There's a bunch of services here This is all function code that I don't have to write Because when I want to integrate with Twitter, I can just say hey Let me integrate with Twitter in this case. I want to trigger this whenever a new tweet is posted and I want to listen for a trending topic I look today Euro Python is trending locally But there are a bunch of tweets globally around spider-man because the new spider-man movies been coming out So I could now trigger whenever someone tweets about spider-man check Twitter every 30 seconds. That's fine And now start to call things like my Azure functions and say hey, here's that Azure functions I just wrote the Euro Python one and I want you to go ahead and analyze the sentiment of that tweet Okay, now for the sake of time, I'm not gonna go build this whole thing from scratch And wait for you to watch me fill out the designer Hopefully you get the idea of how a logic app works So actually I have a previous version from late last night where I actually built this entire workflow It's only four steps nothing too crazy Right, so I do the same trigger trigger on spider-man The first thing I'm gonna do is I'm gonna analyze the sentiment You'll see here I'm looking at the tweet text as the text that I'm passing into that Azure function. We just published I'm gonna go then categorize this I have another Azure function that pretty much just gives it a color if it's positive green if it's neutral yellow if it's negative red and Then the last one is I'm going to publish these all to that real-time dashboard that I showed you a second ago So now let's actually watch these functions scale as soon as I click save here And we'll actually click run so we can watch it debug This logic apps now going to start listening to Twitter and hopefully somebody in the world right now is tweeting about spider-man And if not someone in the audience could but I suspect they will I picked spider-man specifically because it's been noisy And you can see here's an example of one that just got executed But I guarantee that there's hundreds more that are firing right now while I'm talking You can see now that someone tweeted Far from home spoilers. Whoa. I'm not going to read the rest of that tweet Apparently there are spoilers in this tweet, but the sentiment of the tweet I can see it called my function It got back a score of point one and so forth So kind of the grand finale and crossing our fingers that this all works This is where the suspense comes in we should now see this power BI dashboard Hopefully I don't have to click refresh here. Oh man. This is the grand finale. This is the part that really has to work We should see this dashboard here. Okay, it's lit up. I just had to click refresh So now this is filling up with data And you can see here There's been a few tweets that have come in not very many not as many as when I ran this last night It's a little bit earlier in the US right now where a lot of those tweets were coming from But at least these five tweets have triggered. I can see the sentiment. They didn't provide a location They're all yellow with the green circle. That's super intuitive But if I leave these on or if I keep refreshing you would be able to see this dashboard just comes to life So if hundreds of people started tweeting, there's a few more. I see some from Europe. There might even be people in this room Thank you for your participation if you did Oh Not that location though. This isn't streamed, right? But that gives you the idea So so the thing here I was I was hoping this would have been a noisier Twitter topic But the idea here is that if thousands of people were tweeting that simple function that 20 line function that we wrote Just a few seconds ago can just automatically scale and be available to all of those requests as they come in That's really where Azure functions comes in. I didn't have to think about that. You didn't see me SSH into any servers You didn't have me configure any knobs of scale settings. I don't have to I just say here's my code Here's the event. I want you to trigger on and then let it go to work All right, so for next steps for the last five minutes. There's a few things here I'd encourage all of you to go give Azure functions a try The probably the best place to start is our quick start. This is entirely using the command line tools So it does work with VS code like I did But if you're using pie charm if you're using sublime if you're using whatever other editor the same quick start will work Just great for you and you can get up and running and just run this all locally even without an Azure account If you do want an Azure account, I didn't have a link here if you go to Azure comm slash free You can get a massive free credit. I think it's like 200 euros To get started with Azure though Azure functions is pretty much free for most everyone because of the million executions a month You get for free. We also have a video that walks through building an app similar to this one just a different scenario One of the things I wanted to mention is there's serverless library net This is a website that has a bunch of samples of different functions that people have written So if I come here and I say hey, I want to look at Python samples these come from customers These come from developers on our team. You can see here. They're stuff with like a Python one that does some serverless IOT I know there's some here about data cleaning someone one of our customers built a data cleaning pipeline using ML and Python I could click in here edit it directly in Visual Studio code or browse to the code on GitHub to give me some samples As I get started and learning about what I can do with functions if you're interested in the code I used with text blob I posted that on my own GitHub account and then finally if you haven't stopped by the Microsoft booth already Please stop by we've got awesome socks. We have many members from both the Azure functions team the visual studio code team Jupiter notebooks were more than happy to help you come talk to us get some swag get some of those socks and stickers And if you're interested specifically on Azure functions and serverless We have a Twitter handle on the Azure functions account as well as my own personal one So hopefully you've understood and this gives you an idea of what Azure functions are how easy they are for you to get Started with and how you could start to take advantage of not having to worry about all those complex pieces of hosting an application And just get started with the code that you want all using a fully open tool set in Azure functions So thank you all very much. It's been awesome being with you all here today Thank you Jeff And great talk so any questions we have some time please come to the microphones Thanks Jeff quick question if I wanted to docker eyes a number of small flask apps and bang them up on Functions, so I don't have to worry about them. Can I do that now? Is it viable for production? Yes, so I actually was debating whether I was going to show this or not as I looked in that If I heard you right you want to docker eyes the functions correctly, so one of the benefits about Azure functions being open source and our kind of Engagement with the open source community is have actually just come back into this existing project I'm not going to change anything. This is the one we wrote from scratch But I'm just going to write this command to initialize a docker file now automatically without me even having to do the work This tool looked at the project and it's actually generated for me here a valid docker file That will run Python functions in any environment that I want to run them in now I could even publish these containers to Azure and have them run because sometimes I might want to say like hey I actually want to customize the environment. I want to install Whatever some package that might not be included in our image you can do that here and publish it But the other one that we're seeing increasing interest in is that I could docker eyes this and run it maybe on premises In fact recently we've announced a project in partnership with red hat called Kata Which will give you serverless scaling serverless event-driven scaling for containers running in kubernetes And Kata works natively with Azure functions and containers just like this one So if I wanted to run functions in a container Maybe as part of a kubernetes microservices in the cloud or on premises maybe an open shift Using a combination of this docker file and things like Kata I can get the same serverless scale experience in a production ready way right now So definitely something that that we've provided actually first-class tooling support for those docker scenarios and in something with we hope many of you Take advantage of so great question All right, I think we have time for one more. Yeah, yeah Thanks for the demo. I was wondering why is my uber only allowed to rise for 10 minutes Yes, you get kicked out of your uber after 10 minutes in the function world Yes, so Azure functions. We have a few pricing models. The first one is the consumption one That's what is published you by default. It scales to zero. It can scale up to whatever and there is a 10-minute execution limit That's there mostly because of how the consumption plan works for recycling machines very often That's as much as we can kind of guarantee without us worrying that we're gonna reboot it that said though We actually do have an option which is getting Python support actually next week called the premium plan And the premium plan has the same serverless scale It's a little bit more expensive as the name would make you believe it's premium But one of the features you get from it is you can actually have unbound Unbounded I was making my hands very big unbounded Executions so you could have executions that last for six hours eight hours in the premium plan is the only place where we're not going to Guarantee we're gonna recycle these VMs super often So that's the model today though. It's a common request So feel free to keep giving us feedback as well, but it is an option. You just have to choose a different hosting plan Great Okay, so I think that's all the time I want to make sure that there's time for the next speaker to come up because there's an awesome keynote I believe about public speaking so a very good topic as well. So with that, thank you all again very much. It's been awesome