ASP.NET Community Standup - Building HTTP APIs

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[Music] [Music] do [Music] [Music] do [Music] hello welcome to the asp.net community stand-up welcome brady hey thinking about how excited i was yeah so welcome back um we last had you on in september which was a lot of fun um by the way what's that happy birthday again by the way there you go there you go that was fun thanks for thanks for setting that up um yeah okay so uh we are going to be talking about building.net http apis and uh to introduce ourselves i'm john galloway i'm a pm on the.net community team and brady you are i am brady gaster i am a pm on the product team and i do a lot of stuff with web api signalr my favorite thing other than john and azure and your volume is going like this a little bit so i don't know about now thank you okay i'll keep on the mic no worries i'll do the same thing awesome awesome okay well we've got uh we we're worried we're gonna be super rushed and we found out your meeting right after this got cancelled which is which is so great so yeah but we do have a hard stop at 11 30 i was told so we have to have to keep it a little bit in control um awesome i was happy yep exactly i'm gonna start right in on the community links um i'm sharing them in the chat and here we go so um as always these are also they're included in the chat they're gonna be i'll chat them again at the end um they will be in the description and they will be painted in graffiti near your house um so here's the first one this is coming up on uh friday this is our first ever of the series we're doing a learn let's learn.net so this is cool this is uh jamie singleton and cecil phillip uh both awesome people and they're going to be doing this is a beginner friendly series so i mean of course you'll learn some cool stuff from them if you want to be there but think about recommending this to students you know newer people on your team people who are still kind of learning.net maybe people who are programmers but don't know.net yet etc um so this is really cool they are going to be doing like walking through fundamentals of apis like understanding restful apis and then doing kind of a basic 35 minute um you know building an application using asp.net core so one really cool thing about this too is they're building these using the um microsoft learn tutorials so which means if you're going through and you get lost or whatever you can go back and you can redo them in the tutorials and stuff so i'm i'm super excited about this please share this out with your friends and um and all that stuff here's another thing coming up this is on thursday this is a part of the dot net comp series and this is focus on windows so the idea here is that they are going to be talking about how you can use dot net 5 uh and look forward to net 6 for building desktop applications so you know really cool stuff how you can kind of light up your existing applications how you can look forward to building building applications with net six um and the you know full agenda there's some really cool stuff on here including some stuff like um you know i mean there's all the upgrading there's um you know using different services connected services and stuff uh click once which is really cool click once actually like awesome now um and then some some stuff towards the end looking towards the future with dot net six so good stuff i gotta talk fast i've got a lot of links cool i think i saw jimmy angstrom's name on there i love his presentation uh so this i believe is not jimmy angstrom it is his fabulous wife jessica angstrom nice yeah okay they are they are both super funny uh they're they're they're the best yeah so yeah jessica is gonna be i'm talking about um what is she talking about something cool um she's gonna be doing practical tips to improve user experience nice so yeah good stuff i just like how you never know what what avenger they're going to show up as it's always yes exactly um okay this came out last week is it dot net six already starting to roll out first preview so this is looking at overall what's the major work planned and then also what's new in preview one so you know stuff like hot reload micro apis like we've kind of hinted at some of this stuff with guests that have been on the show recently they'll say here's some stuff we're thinking about and here's where it's kind of starting to kind of pull the the plans together um so so some neat stuff there updated single page application support of course blazer http 3 um and all this stuff is tractable trackable in this themesof.net site so that's pretty cool that's cool and then looking at just some of the stuff coming in uh in preview one so i think disposable dynamic component i'll talk about that in a second um dot net watch now does netwatch run by default which is something i've always wanted so that's cool uh one thing that's neat here i think this is you know hopefully we'll dig into this more um with the next blazer stand up in march but this dynamic component thing because the idea here is you can you can call dynamic component and you can pass a type to it as a parameter and you so you can bind to it so i can picture this having multiple different component types depending on am i binding to a product or a order or whatever and i could pass that in or i could have like maybe i'm listing different types of people and i could like have different bindings depending on that so you can pass in both the type and an array of parameters so pretty slick um also i've kind of trying group things to keep saying here blazer deploying blazer to aws amplify what i mostly want to call out here is niels has been doing this series on deploying static static blazer applications to a lot of different hosts so he's done um to azure static web apps to github pages to firebase firebase netlify and then this is digging into aws amplify so the cool thing here is blazer being static you can deploy it pretty much anywhere there are some things you need to do to wire things up to make sure that the routing works and that sort of stuff so he does walk through doing that but i i mostly just want to give a lot of props to like building this resource of all the different way if you want to deploy azure static apps i check out niels site because he does these great walkthroughs on that ed talking about blazer layout components and the cool thing that he does here is contextualize you know for for people that are moving over from or or are considering building blazer applications and are more used to xaml based applications there can be a little bit of a like a mental jump you've got to make from xaml layout to css layout and it can be scary and fortunately uh css has evolved over time to kind of pick up some of the smarts and things that people do like about xaml so for instance css grid and then there's also um flexbox and so he talks about kind of comparing hey if you understand xaml here's how you can understand css grid and then yeah and css flexbox as well so you know i used to live in the xaml world a lot a while ago i'm kind of rusty on it i'm kind of more comfortable with the css but i i do like this kind of being able to kind of map back and forth between those so this is something i'm actually yeah really really cool and i never think of you as a sample person you're like a web person so it's funny i'm 90 web person but i did spend some time back when silverlight was early on doing a bunch of silverlight and i lived silverlight for for a few years and then i actually did a little bit of wpf too um so but there are very different ways of kind of approaching layout to me um so that's cool so is essentially i'm not familiar with this is this because i am a web person specifically web ap hikers uh is this specifically like i can use css to style my my xaml and wpf stuff no so so what he's saying is you can if you're if you're building things like when you're building things in blazer you're going to be building more component based right and you're going to need to like think about component based layout and when you're doing that grids and like those sorts of things are useful and bootstrap will get you so far but bootstrap can be frustrating right if you really want to do kind of more um i if you if you want the control that xaml gives you in layout bootstrap is probably going to frustrate you and so um so what he's doing here is mapping over to the concepts in uh css grid and flexbox that makes sense that's cool that's that's pretty okay that makes more sense yep yeah yeah it's useful useful so uh so uh ben ben's just always doing crazy stuff he went in and my understanding of this from from where i read the poll requests and stuff is this is a tweak for front-end performance um and this is for the signalr javascript libraries and what he's done is tweaked the webpack stuff and webpack is complicated to set up and do correctly and how to manage he's been right so so i mean he just went in and did all this stuff and shrunk stuff way down and and like like shrinking things like cutting them to tiny percentages of what they used to be so yeah this is really neat really neat work there so so ben made ben made that faster and we didn't even think that could be faster yeah or more performant exactly it's a smaller download um based on optimizing stuff for instance um a lot of the stuff with webpack is set up based on uh es uh es5 and there's a lot of stuff now that like now that everyone is like where uh signalr doesn't support ie10 anymore i believe and so there's no reason to support es5 and there's some other things about like go if you if you map over the javascript levels of what is in supported browsers you can tweak the um what's in your web pack and what's in your javascript specifically so and then stuff on the on here from the team like you know reading and and and like saying yeah like basically thumbs up and stuff so nice that's uh that's that's one of the things that's painful about not being able to get a triage every every time we have it yeah some of these details that's cool oh yeah that's great yeah i'll always brenden yell at me later yeah exactly great great to see ben being ben thank you ben that's great then um so now i've got a bunch of kind of releases to call out too um congrats to a lot of people so uh matt and the whole core wcf team have been working really hard um and this is something where i was involved with early on back when i worked with dot net foundation the wcf was contributed to dotnet foundation as a core wcf project and as an open source project matt is a microsoft employee and microsoft like pays for his time to work on core wcf uh but there's like there's also a lot of other people including he calls out in here the aws team so aws is amazon aws has been contributing to uh to wcf so this post is i mean this is like there's a lot of text here but if you're into wcf and i talk to a lot of developers and they're like i'm stuck on framework because i need wcf you know like there are people that have made very heavy investments in wcf so it's really cool to see this moving forward and the amount of care that they put into um into building a solid product something that's evolvable and you know that people can really rely on so like you said here there were some early things in the design that were focused on building something that was very performant for windows only and in building something that runs on multiple platforms they may they needed to make some architectural changes now they rely on async await tasks um and it's supportable and maintainable and it's the the trade-off in performance balance is is kind of negligible at this point but but a lot of work to do this so congrats to mata and the whole team congratulations on that and you you said something this and that's kind of important to me we're talking about apis today um if you're out there and you're building you know your applications for azure and you're using you know wcf and asp.net framework um and you're you're challenged or you want to move to core you're having any issues don't hesitate to reach out um that's one of my jobs one of my many jobs and i'm currently trying to find customers who want to move and like who are using wwe having difficulty with that so my door's open please please send people my way if you have any folks like that cool all right uh let me see uh next a cool little uh another release announcement this is the blazer rebel team so in this release uh they reached a big milestone uh you can install nuget packages configure custom services and reference external static assets so it's it's really cool to see these repel things kind of grow up into something you can actually like build something with so here's an example you know where they're doing that you can you can um they've got you know multiple different files here i mean it's we're building like and hosting a mini uh application so here's our nougat package list and you can you know go in and you know restore your packages and all this amazing stuff so i mean this is really cool congrats to the team that's awesome yeah that's really really cool isn't it i mean it's like so you've got like an ide here and you're building and running an application in the browser and it's just like well you know so and it's neat that it's leveraging like this is running client-side right this is the web assembly and and um so anyways it's it's cool to see like in the past people building these kind of rebel things and even including now a lot of these like rebel-based products they've got to do so much on the server and they've got to be worried about people you know being malicious and mining bitcoins and all this stuff and and it's cool with this it's like we can push some of that down to the javascript sandbox in the browser that's really really neat it kind of kind of makes me lament all the things that i complained about from the point i got up this morning i'm not i'm not having any big problems this is really cool yeah it's a really cool project bro bradies yeah and we'll add that to do it and then we'll check it off because i think they did it yeah really groovy i love that all right the yarp team um they hit preview nine so this is one oh preview nine um some stuff here uh support for dot net core three one and net five so i think those are some of the um main things um so congrats the team we've had them on in the past if if you're interested um so this is a reverse proxy that you can code for in net so you can you know write like rich configuration rules you can do routing and stuff in net code and a lot of other good stuff too you can you can also have kind of combined um configuration so instead of having some config and like yaml and some you know like system way over here and then you've got your.net application over here you can actually have net code all kind of you know getting that reuse so congrats to that team all right more congrats all around dapper dapper 1 1-0 went out last week so so this is cool um we and we just have recently had uh dapper folks uh on the show so that's something you can look i think just one or two shows back yeah but yeah this is great yeah yeah good stuff and then along with dapper if you're getting started um so the team uh my my teammate nish worked with this this is dapperfor.net developers so this is a free ebook that you can read you can view it on the web you can download the pdf you can do both things i guess if you want um so anyhow that's that's exciting so this is a full you know full book that'll teach you like not just a little bit this is this is a full on walk through tons of code and everything so let's go excellent stuff okay i'm getting towards the end um this is a a neat just little tip uh cecil tweeted out this is something that's been since dot net core three hi neil's welcome to the stream i just called you out earlier in the show and showed off your post and i'm sorry you missed it um but uh so this is neat this is a um in an endpoint you can say uh you can you can do a get debug view on an eye configuration route and one neat reason that that this is this is cool and scott calls this out scott addie on the docs team is he says this is extremely useful for answering questions like is this value going to come from app settings or secret json etc and configuration in.net core asp.net core specifically is really configurable and it's really nice how it kind of layers and you can pull some stuff in from from key vault or json or configuration providers and stuff but it also can be confusing to debug what's going on and why is this value not getting read or why where did this value come from so this this is a neat little tip to be able to do that and you can map it to a specific endpoint you could secure it or you could say only indeed in debug mode or whatever so that's cool this is one brady honestly this is this is one you you tweeted about and said it was awesome and so i believe you that it's awesome this is uh azure functions open api extension and then okay and there's some walk-throughs so what i figured is i would share a few links here and then we'll just dig right into them there's there's this open api extension and then there's these three blog posts we want to talk to talk about here there's uh a blog series that we've been doing this is first of all creating discoverable apis um and and all kinds of stuff produces consumes and configuring your project to create you know like rich open api services and then going further from that there's well if you're if you're you know really investing and building good quality apis and doing a lot of development with that you're gonna want tools for it and so you talk about tons of different tools for doing that so many and yeah including a lot of community tools which is cool and then finally one that just went out this morning i know that guy and this is a post that we we worked on together and this is fun this is um visual studio connected services um and this is generating clients http clients based on those open api specifications so and that's that's all the links i've got i'm going to stop sharing my screen and i'll let you talk a bit how's that that's great all right that's been such a fun series to work on john and i've talked about this series since like on october november and we've really wanted to do it so he he decided we're gonna we're just gonna put it on the calendar for february and we're gonna get it done so it's been it's been really really fun uh i've forgotten how exhausting blogging can be so it is it is it's one of those things too where we ask for feedback from the team and they give you good feedback and you're like okay thanks for the feedback but now i have to make those edits and then yeah yeah yeah uh everything i always say software is never finished you know works yeah um yeah those those were fun i think i think one of the one of the most fun things i i got to do with that i forgot to share my screen with you so i'm going to go ahead and do that with you now uh was being able to talk to uh mr steve smith um who works on uh some of the things we talked about oracle he works on api endpoints it's a project uh out there that um is sort of inspired by the idea of like not having controllers but having all the stuff that we know and love from web api and from nbc um he's got a pretty steve smith like blog post tongue-in-cheek blog post um where he talks about how controllers are dinosaurs and they're just like a hold over oh that's right yeah it's a pretty interesting kind of conversation but um i ended up having a chance to meet with steve because we were kind of i was walking through not only the work on the blog series can you click the hide thing down on the sharing oh yeah sure yeah i'll do that right now sorry buddy nope there we go um i'm still up there good um so if you want to take a look at this uh if you look in the blog post that john put out earlier uh the one uh the one for uh the http tools uh the open source stuff you'll you'll see that api endpoints is listed in there and if i were to scroll down i don't know if he's got any code here we go you can see that it kind of hooks up to like swashbuckle and all the other asp.net core middleware because it really is built on top of web api steve just wanted to kind of take web api and make it essentially modular so if you've ever done anything with like nancy um he kind of wanted to kind of take that modular approach rather than having to build controllers for everything and i thought it was i thought it was pretty cool and i met with steve and steve was like use it talk about it steal it whatever you want to do i just want to have an option you know what i mean i just love i love when the community is super open like that that's been great um and i mentioned nancy and it wouldn't be right if i didn't go ahead and show carter as well here now carter is um from what i've looked at and admittedly have not gotten very deep with carter but um from what i've looked at rather than kind of what steve did which was to sort of build on top of the web api uh stuff and build on top of mdc and make it a little bit easier and obfuscate the the controllers away uh the folks at carter kind of felt like they kind of sat a little bit lower in the stack like they kind of sit on top of like endpoint routing and like whatever else um but i wanted to kind of show the carter project for folks who are interested in that kind of endpoint centric approach um i think you'll see more of stuff in our and and what we're doing in asp.net kind of percolate like this we're we're looking at these projects and looking at talking to folks who don't want to do the whole controllers thing and thinking of those other approaches and whatnot um so you might see some things evolve in asp.net i don't want to speak out of turn yet but we're definitely looking at these projects and thinking about what we can do to kind of answer this sort of an approach so that that's been that's been kind of fun to to kind of look at those different projects and think about new ideas i won't get into power apps yet um the only other thing i would want to call out if i scroll down in this post for those of you that are out there using edge sorry to make everybody dizzy uh if i can get to the right place here we go network console so i wanted to point out network console it's actually a feature that's built into uh edge uh the edge browser and if i scroll back out just a little bit you can see that if you look at my earl here i'm not gonna do this today i'm not gonna run network console today um but if you see my earl here you'll see that i'm at just localhost 5000. it's like i've hit f5 and as you know from the.net conf keynote in the session i did there with with web api projects and.net 5 we've actually added swashbuckle asp.net core to the template so you get open api on by default so you get the swagger ui page for free just hit f5 and you're off and running um so this is essentially the the f5 experience this over here is if i were to go into my developer tools and it's kind of interesting i think i can do it here if i go to my developer tools and then i think it's uh i think it's f1 now you go into that okay and that mode is where you would go over to like experiments and then you scroll down and you'll see i've got it checked already so you've got network console checked so i just want to point that out really again what you do is you you open up your open up your uh your dev tools and then you do a f1 and f1 you go into experiments and then you click on network console and i think you have to restart your developer tools at that point you may have to restart your browser i don't know but what it does is it kind of gives you a api testing kind of a experience directly inside of your browser um i know there's a lot of great products out there there's postman there's what is it called rest client for uh bs code that's like kind of built in so there's a bunch of different tools out there but i like that this kind of puts it directly into the browser so if you're building a jam stack application or let's say you're building a blazer webassembly application that uses rest apis on the back end you could actually load your page and look at an individual request that goes back to the server right here and you can click it and basically do edit and resend and now you've got an experience right in here where you can actually edit the properties or edit the request payload that you're going to send or edit any of the headers or anything at all that you want to send over you can actually tweak all that directly inside of your browser so i just wanted to call that out if you're using edge you probably already have it didn't even know about it um and there's a couple of other things in there i believe it can do an open api specification interrogation um i don't know the keystroke for that off the top of my head but um you know if you take a look at network console and you want to learn a little bit more about it reach out and i'll i'll connect you with the team so um there's that i i love having those built-in tools you know i i like both options i like to install like a favorite utility or something that i know where to get and stuff but it's it's great having something that's just going to be in there by default partly because if i'm helping someone else on or writing a blog post or whatever i can say i know everyone's got it right so it's just it's built in exactly it's pretty cool i mean that's that's a nice little feature of it i i've just had a great time with that um it's been pretty cool um i mean when you get the swagger ui page you know it's like but that's kind of my favorite experience for testing apis but um at the end of the day it's great to have those tools directly inside of your browser so and i apologize to you and the audience i can hear that my wonderful son is practicing his recorder so if he i don't hear it in the background okay he's a he's a he's a world-class recorder player um but let me see if i can flip over to oh uh you might want to take me off screen real quick let me log in alright sorry about that all right tell me when you're ready okay that is there we go sorry about that happened yesterday too it's like i keep switching back and forth and it times out um so this is the solution that's in the sample download uh which is currently on my github we can move it to the official one if you want to um but to kind of walk you through at least i keep looking up there uh that's going to make me dizzy so this is the sample we use in the blog post series right correct and i i mean uh so you're you're going to show like the stuff you built for this this apis sounds great sure um so whenever you clone the repo which i know is in the in the blog post links i won't put that up there is there any way to dynamically generate yes yes there is foreshadowing question you'll love this all right so the question was is there a way to dynamically generate an open api specification uh from from code and i say open api specification or description because i work with daryl miller so i have to say it um so that's a great question and what i would show you is if i were to do file new project and do web api right now if you select net five you will get open api on by default using a uh open source package known as swashbuckle asp.net core there's another one out there called nswag um swashbuckle just had like quite a bit of numbers so we wanted to just just use that one um as the template we've talked about getting in swag and a whole bunch of other stuff like api versioning and all other kinds of things like i really want to get a bunch more packages in there but that's a long run so i have to keep talking about it but essentially you get this in your project when you do file a new web api project and you also get what needs to be wired up in your startup cs now i've got a little bit extra in here because i've built this up to kind of show the demos but this first line here this ad swagger gen and this is all in the asp.net uh core documentation there's actually an article specific to swashbuckle and another one specific to n swag so you can pick which one you want to use um but this is really where you dial in uh swagger and you basically tell it you know in this case i'm doing some customization because i'm using uh i'm using a api versioning but can you blow up your font size just a little bit oh yeah sure uh this essentially where's the zoom zoom uh it's it's in the right below the line numbers it says 155 percent uh on the left side oh here we go yep so that's one way i do like that that better yep yeah uh sorry about that um so swagger zen is really what will output your your open api or swagger the interchangeable uh unless you ask daryl that'll basically turn that on and then what we've done in the template is inside of this is development block we've added this as well the use swagger ui and again there's a little more code there than you'll see in the template because i've done some customization but the use swagger and the add swagger gen basically turn on the ability for your web api controller to be interrogated by swashbuckle or nswag at runtime that will then output that open api based on a special url which i'll show you here right now so what i'll do here is i'll just hit f5 and that's going gonna hit i'm running this completely in kestrel uh you could use is if you want um but what i'm gonna do is just open up i just hit f5 and we go directly to that swagger ui page and if i were to click on this link here this is actually the open api which i'll have to zoom in on for my web api controllers this is absolutely generated at runtime dynamically uh using those open source packages now if i were to go i got to zoom back out again that's always the way if i were to zoom out here now you'll see i talked about api versioning a couple of times that's a really important nuget package in the art of web api development we talk about that a little bit also in that open source tools and packages um blog post but one of the things that it'll do is it gives me the ability in my code to actually on my controllers or on individual controller methods i can use things like api version and what that will do is basically say i know that i have these versions of these controllers excuse me of these these api versions in this controller and if i were to scroll down a little bit again sorry for making everybody dizzy uh but if i were to scroll down what you would see is right here i've got a attribute called map to api version that's because i added this method i added this operation rather in open api speak to my api in version 1.2 so theoretically it shouldn't be there for previous versions so if i scroll down here you'll see there's that low inventory method if i were to use this and go back to like 1 0 or 1 1 you'll see it's gone now so that's an example of how api versioning and the stuff inside of web api and some stuff in swashbuckle all kind of snap together using the middleware and the services and the bedrock stuff that we've all implemented on the team so uh now we did not write swashbuckling api version and those are contributed from third parties or open source devs um but we you know we recommend you use them uh because they're fantastic there's a lot of azure service teams for instance that use some of these uh nuget packages to do some of their work if there's good enough for azure it's good enough for me um you can also see here that i've got this products page uh thing if i were to go up here and select one o you should see that that will vanish because that was a method that i added between one o and one one and if i wanted to i could actually go ahead if i wanted to test out my api see if i have any data here you can see that it goes ahead and it takes the version that i've selected and it pre-populates that parameter box right here with the 1-0 if i want to i could go here and just hit try it out it'll give me this execute button and of course that's of course that's going to happen rules so yeah demo rules um i i don't know why it's not exiting there it executes in azure so um but i think maybe i'll have my connection string wired up locally but that's the idea but that's really but that's how it works that's really handy i spend a lot of time you know when i'm doing starting building something from scratch then you end up like curling or doing so you know doing some rest client to do so it's like that saves you time to have something that's and it and it also shows you like if you're posting something it shows you here's the kind of request i expect to see exactly it really really does and like i said i just went to the docs page and i went over here to the toc to web api apps right here that we've got the swagger and open api stuff inside of the web api apps and if you look here we've got an article on swashbuckle and we have an article on end swag and all the different stuff that you can do with that so we we do have great documentation across the board and like how to use these different packages here but that's how you do that on the web api side okay i know it's not as much asp.net but you asked me about the function stuff so what i'll do here is i'll just set this as the startup project and we go through in pretty great detail in the blog post about things like using the produces consumes attributes those basically can specify i'm only going to accept or send you json so if you want to control like kind of how your open api document gets gets uh like informs uh clients as to what you know kind of output you're going to give them that's a really easy way to do it we go through that in the blog post pretty extensively the one other thing i want to call out is this here and i don't have it turned on so i'm going to do this and just turn this off but i want to show you this api conventions here because what that'll do like we talk about in the blog post is there's a lot of situations when you're writing like a web api controller where you might have a method such as create order just to say create order in create order i might do something that i might try to throw you in order for which there's already an order id you know what i mean we would get a conflict in that situation um but i might you know it might work in the case where it works i would want to return a http created response because when you're doing a post kind of the specification says post return creates gets return uh okays so in the case of this api uh one of the things that open api will do is it'll say not only can i tell you what sort of request and response this api was going to give you but i can also tell you the potential http response codes that it will respond with so what the api conventions does at least in the way that i'm using it right here what that will do is it will automatically interrogate um the different pieces of code the different return types and any of your action methods and it will infer in that open api um this method could return conflict could return not found could return okay if you don't do that it'll always say i'm going to return 200. so in the case of a code generator it might not know how to process the response can you scroll back up to that that um that reference with the assembly colon thing at the beginning is not super common what can do you want to talk about why that's required or what that means totally uh that's a great question so what i could have done here is i could have taken this excuse me this attribute i could have taken this attribute and i could have just put it directly onto a particular controller like this but what that means is it's only going to apply to that controller now if i want to go through all 200 controllers in my project and do this i can but if what i really want to do is make sure that it's a global like a convention i can essentially use that same attribute at the assembly level and what is what that will do is it will go through the assembly and find all of the web api controllers and anytime i'm making a call it will it'll just impact them it will impact the way the open api is designed based on what the return codes are in those individual action methods so it's great it's an assembly level thing it's like oh the whole assembly all the controller types i like all the classes decorated as an api controller all of the methods that return an action result figure out what they return and generate the open api to that extent so okay a few questions and stuff coming in so one was somebody asked uh where the code was and so i i just shared the link from the blog post so it's it's github brady gaster and then contoso online orders good old contoso a few questions about like securing apis and that gets a little more difficult and i think i'm guessing to jump to the end this is something really more where like api management makes this simpler is that well or does make it simpler but swashbuckle and and swag both have support for oauth so you could like let's say you if you're doing what i would do uh because i always use uh aad azure active directory or microsoft identity i can't remember what they call it um no offense guys uh but um essentially if i were to create like a client app and the service app the service app would be applied to my web api i'm regurgitating what christos always tells me uh the the client app would be assigned to my web app and then the two would you know have a trust relationship in that context my client app is going to be communicating with my web api using oauth it'll be securing using oauth you can essentially go into your configuration for your swatch buckle or your end swag like wire up and start up cs and you can add code that will and that knows how to do the authorization against a um against uh an oauth source uh you can tell i'm so great at identity um it's great question though because uh christos pinged me recently and said he wants to have me on the 425 show to talk about identity with either signalr web api um so i was thinking about doing a jwt uh focused show that basically shows how to authenticate a web api and then use that same token to make signal our outbound calls so if people find interest in that i could do it um our mutual friend from arizona joe joe g uh joe yeah he has a wonderful web api uh series on his twitch show where he goes through uh a lot of details on uh web api auth um and he used uh the new stuff from christos team microsoft web identity or identity web uh he used all that stuff in his project um and he gave them feedback uh and they took a lot of that feedback um oh cool yeah i would definitely look at joe's show if you want to go deep on like web api how to authenticate it how to get your tokens and all that stuff joe really he put himself out there and learned a lot it was exciting to watch so okay um you put that in your show notes i get it for you yep okay sounds good uh let me see some other questions coming in it's great yeah ask your questions in the chat we're watching all um so we're actually for people watching we're on uh twitch youtube facebook um we're on periscope going out on twitter we're like we're all over the place so ask your questions any of those places we watch them so a question here on this global assembly type for versioning can you do that as well i don't believe that you can and i'm sorry chris and the other members of the api versioning team if i am uh speaking out of turn uh john i'm going to get you a link on this real quick um hanselman's got a couple of great blog posts on api versioning i think that's how me and the rest of the free world actually learned about it originally yeah um i just gave john a link in the chat which i presume he'll share with everybody yeah um the asp.net api versioning stuff supports both asp.net framework and asp.net core and odata flavors um i don't know if you can do an assembly level version for uh api versioning but if it can be done their samples will show you how okay so cool all right taking a bunch of quick questions here um i don't know about this one this is asking is there a way to do yaml based and generate code stubs and models and stuff yes they're totally what it totally is uh darn it i'm not gonna be able to find that link either okay so let me let me tell you about it there is uh there was a hackathon project that uh we put together in the summer of 2020 uh when things got interesting uh and we just had to just to work to keep our minds off of things um and uh some folks from the functions team uh some folks from ca some folks from api management and myself we got into this conversation about what i like to call design first apis um like basically writing your open api spec by hand there's some great vs code extensions to do that as well we'll talk about the blog post but essentially to build your open api spec or description file by hand than to ama code generator at it and to create um essentially like a web api project from it or a functions project from it we started out it would be really exciting like just give me the boilerplate code and let me party on it now if you were to go and look for the swagger editor project which i believe is officially owned by a company called smartbear if you were to look at the swagger editor the swagger editor can generate both client code for open api specs and server code for open api specs and they have scala they have node they have the whole world so you can basically go to the editor.swagger.io i think is what it is and you can you know party all over it and tinker with it um but i know that what we did inside of the vs code extension for both i think it was both azure api management and azure functions um was we put an interesting uh like experimental thing into it uh we called it project stencil uh varad oh yeah uh he did this it was really exciting it was called project stencil and it was one of those like ground swell projects that like people all over the company thought was really like thought needed to happen so we just did a hackathon project made it work and shipped it um and it was really cool it's nvs code extensions for function and apim what you can do is you can go like to the api management portal you can design an api using their like you know portal blade and stuff uh make your operations and everything and then you can go into the vs code extension you can right click that api and say generate an azure function project for me and the next question to ask you says what language do you want so you can pick dotnet node uh or typescript.net typescript java or python um there are opportunities with all four of those generators wink wink knows nudge your mileage may vary it's an experimental project but if you like that idea please reach out because we need all the ammunition we can get like we really believe that there's something to be said for design first um and we want to do a little bit more experiments with that so right now it's kind of isolated to building azure functions we don't have it to build web apis but everywhere is walking distance if we have the time you know we could use auto rest build a couple of new template generators we could write something else we could talk to our friend daryl see what he's got up his sleeve uh there's options uh but i love that you're thinking that way uh design first is really in my opinion the next step so cool um okay so so like i interrupted you with a lot of questions but i think what you've shown so far is we had a bunch like you've been showing us controllers and you've been showing how we can put um you can put attributes on them and you can set up versioning and stuff and you're generating your swagger description based on your controllers exactly exactly now there was some stuff that you did in your blog post where you go in and you configure stuff in your project file you set some project file stuff yeah let me show you let me show you what i was doing there so and i've taken some of that out um which is not not good not good blogger behavior i know um i had some comments from some folks uh people do not like split uh compiler switches let's put it that way all right so what i had essentially done is inside of the blog what you'll see is i first had a series of these which i kind of had this going two ways and it's going to probably air out for now this is really what comes in the templates so this is and there's nothing wrong with that fine but what will happen if i run this open api i can actually i can show you real quick so let me comment this one out um let me comment this one out uh and let me do it like this i'm just gonna give you a quick little uh rundown of what this does uh so i don't have those in here anymore so i'll go ahead and let me set this as my startup project and i'll run this and what you'll see on the swagger ui page will probably be enough information for you to know why this next part matters um so on the swagger ui page what you'll see is that i've got check inventory ship order update product inventory create see these pretty names those pretty names will literally be used by most code generators to generate code or as we'll see later when we talk about power apps uh to to generate kind of like consumption stuff okay and when you don't provide what's called an operation id in uh open api code generators and consumers have to have to guess all right it looks like it guessed poorly it looks like it gets poorly so here's what right so here's what happens in the generated code so here i've got orders and here i've got orders by id all right so if i were to look in the generated code for that and i'll sh and i've got the code in console client and program cs so what i'll do is i'll scroll down until we get to this part and you'll see it's commented out because i it's it's it's the the compiler switch is in there but you'll see here i've got products and i've got products too that's because both of those operations their their their name their name and jason speak is product or products so the code generator is like you didn't really tell me what to do here i'm going to have to guess so i'm just going to start putting twos and threes hey that's better than sharepoint drop a good on it right exactly your word's not mine um so if i scroll up oh i'm doing it over there again if i scroll up in here what you'll see when i get up here is here we've got get products and here we've got get product and then right here we've got update product and these are more these are pretty names see what i'm saying uh and i'm talking about you earlier christos i'm talking about identity you're a little late he always shows up and he goes wait wait you're doing that wrong yeah yeah so this is really what you get when you turn on operation ids so that's why i had those compiler switches in there is i wanted folks to be able to see it before and after but last night when i was working on the code i was like i'm going to do the show i'm just going to take it all out okay um so i apologize for that but the other thing that i had wrapped in those was the produces consumes i'm not going to turn that off but basically what you would get there is you're going to see text json and all the other content types unless you and then like if you don't know how to respond to them when you get a call you're going to break or you'll get a 404 you know what i mean so i like to do this because you know i only like to use jason um so there's that somebody asked a question about yaml um if you're doing like an open api uh thing i i do want to put this uh put this out there swashbuckle and nswag both as well as the uh the open api generating functions uh the open api bindings for functions they will all support uh giving you a swagger v2 open api v2 and open avi v3 with swagger or with json or yaml so you do have that option like if you're a gamble person you can you can ask for the amble and you'll get the ammo instead of the json so um let me flip to this so that kind of explains the operation id which we talked about in the in the code and if i were to go to this function here set is startup project so with a function you know you can you know a lot of folks do functions as static classes and static methods some some folks will you know they'll use the asp.net middleware and the startup ces stuff uh the the normal hosting approach um but we didn't want to preclude folks in either category we wanted to make sure that if you're using the hosting approach with di or you're using statics that it would still work so essentially what we had to do was to kind of give you ways to dial it in with functions the best way to do that is really using is really using attributes so i've got a lot of name spaces so my apologies here and justin's done a great job of documenting this so there's a lot of different docs on these different attributes well let me kind of walk through what they do first so the first one whenever you're writing a function so i've got send low stock notification um you basically have to give the function a name so what i usually use name of here uh that's something i've seen jeff holland do so thank you for that tip um so i actually borrow the name of to do my function name in the same way so and let's dig into that just a second so the nice thing with name of that's that's in c sharp and what's cool with that is that's going to instead of hard hard-coding a string you any time you see a string in code like a little alarm should go off in your head like is that good because you could misspell it or if the string changes you know you have so what's cool here is it generates this string right based on the actual c sharp name exactly exactly so now so now if i go and rename that class it's going to like it's going to like either break like i'll get a compiler error or it's going to like prompt me to refactor or whatever yeah yeah so and i i totally borrow that same approach in my controllers uh this is not a recommendation um i don't give advice uh but i i borrow that same kind of approach in my controllers because i do this explicitly if you're out there and you do a lot of web api and you would like us to put this name property in the template uh feel free to let me know um i was just gonna ask about that like how much of this can be conventional as well a lot okay like a whole bunch um which which uh reminds me there's one of the things that we talked ab is linked i didn't talk about it in the blog post but i would really encourage you to scroll to the very bottom and look in the comments john have you ever heard of the boxed template series yes yeah it's been a little bit but i've do you want to bring that up and or i i don't know if i don't know if i don't know let me see if i've got it here uh i think i think it's in the comments of this post uh boxed here it is yeah so it's but you're right it's been a little bit since i've shouted that out that's a great project um and it's an opinionated like approach it's an opinionated template that like sets up a lot of stuff so some of what you're showing in the blog series is go here turn this on do this add this attribute and what this template tries to do is just say out of the box it's going to be set up that way right correct and and we try really hard in the templates like hey they're really like templates are hard to maintain you know what i mean so we try to make the template small on behalf of our devs um we also try to make the template small on behalf of our community uh by default because we've heard for years like don't make all these assumptions about what i'm supposed to do i don't know how to use any of this stuff um the community tends to as as do i uh tend to want to go learn every single concept you throw at somebody in a template you know so for something like box you're going to be learning a lot you know what i mean um the only beef i have with it i tried it the other day i tried box the other day and you can see i'm on a mac nothing against powershell i'm more of a bash user it's just a personal thing for me um so the the box templates it looks like they require powershell there's one thing i would ask for it would not require powershell okay one nice thing though with powershell being cross platform and everything and you can actually do net install powershell now or net upgrade yeah so we totally can and i installed powershell just to try the box templates yeah there's that nice uh on my mac so it did work um but that's kind of how we did it with controllers now in in functions you know you don't have there's no server one quick um so essentially you know i don't i don't really have a lot of the stuff that i would have you know for other areas so i would i would need to use these attributes attributes are rich throughout all the different functions sdks uh anthony chu wrote some of my favorite ones the azure signalr bindings which i've talked about before on the show um but in this case what we're doing here is we're saying this attribute is basically establishing an operation so you can see here operation id uh you know one of the things justin and i talked about just in you the dev working on this uh we talked about this and i said you've got to make operation id on by default and i want it to be in everybody's face so he put it right there in front so i was really happy about that because it's easy to forget you know yeah and if you read the open api spec it's actually not required but if you use it it has to be independent for every operation in your entire api so that's something you talk about in the blog post is like those operation ids need to be unique if you use them right so that that's part of like i was trashing a bit earlier like oh it generated a stupid name but it's got to make a unique name so it's got to yeah it's got to um and like you know on on on ricoh and the folks rico from nswag and then the folks who work on the autorest team you know autorest is very big on operation ids um you know they you know you can't blame them they kind of like you know you have to you can only do so much you know what i mean um and i talked about that in that first post uh and some people in the comments actually called out you know well uh what was it like discoverable apis and well-described apis aren't necessarily the same thing if i had to do ever again i probably would have called them well-described apis instead of discoverable but details but in this case uh you know i'm basically saying this is a this is going to be an operation id uh or an operation in my swagger in my open api um here i'm basically our this is this open api request body you can see here that it's got body type is type of uh product array i think i actually i guess i'll put it in a different class but if i were to go i'll just leave this open if i were to open up product you can see here just a typical class i probably i couldn't have made a record because i'm in 3-1 but you can see here it's just a typical class and all i'm doing is i'm saying this azure function will take i'm doing it over there this azure function will take a payload of type product array and if you look in the function you can see that i don't have that as a method parameter all right um that's because the function is really it's it's sort of making the assumption that i'm going to do something like i'm going to look at my uh here we go uh where where'd my where i'm reading the request at some point i actually read the request coming in oh i guess i took that card out i got to add that code back um i stopped i stopped doing that oh here it is right here so you can see here that i'm essentially deserializing my request body into a you know array of products and and i'm just looking at the ones that have an inventory count of less than five you know what i mean that's silly uh but it's really just to kind of show that end to end now if i were to run this now this is great because what i end up doing is i just build my function and i use in this case i'm using the minimal number of these attributes because i just wanted to like light it up as a open api decorated azure function and i wanted to specify what my payload was going to look like and after that i was done i mean that's all i want to do everything else is automatic now one of the things that you can do in this is i could wire up something like uh this i could i actually created a class called card metadata or no wait that's not look that's the wrong class sorry i'm jumping around a bit bit much here where did it go here's the wrong class so this is a class that inherit implements this interface i i open api configuration options now what we talked about was there's a few different ways that you can essentially configure the the metadata for your open api inside of a function one of those ways is you can use host json uh one of those ways there was another filing was open api.json we had like a myriad of different like ideas on this one this is my favorite because like i can just read configuration from whatever i want if i'm versioning i could read it here so i just went ahead and made a class and put it directly into my class so it's not a big deal and then this is something that is a holdover from version 4 to version 5 or version 0.4 to version 0.5 it was a issue i found the other day i think justin's actually already fixed this issue in his nougat package and reshipped it um so we're going as fast as we can but if you can kind of imagine the question from earlier like could i take an open api uh spec you know and could i generate code from it that i would then fill in imagine if you wrote your open api spec and then you got code that looked like this and this and then basically inside of the method it said implement here okay see what i'm saying so it would generate that entire shell and then let you put the important stuff where it needed to go so and and a focus there is to like i don't want like i want to describe a service and then i just want to like focus on my business logic and i don't want to spend all the time like wiring stuff together and handling timeouts and all that kind of like random stuff right right like one one example of why that would like why that would save you time is um you know we we talked to a couple of customers who are building apis recently to kind of do some of this work and one of the things that we we asked them we said tell us about your process like like what do you do like how do you design your api and they'd say well you know we meet with the business analysts we have probably like three or four whiteboarding sessions we'll come up with like a mock ui then we'll kind of figure out from that mock ui what the api should look like et cetera et cetera i was like so how many weeks of meetings do you have before you write any code they're like oh like a month you know what i mean so yeah what if a business analyst could go and design the api that their app needs and just generate the shell code and hand it off to a dev i'm not saying all the code i'm not saying do the devs work i'm saying it's like file new project it just file new project is driven by your open api spec versus whatever's inside of visual studio that's that's really all we're saying um cool okay so so like to to look at this in context so far so we've we've talked mostly we've looked at building building the apis how you can configure them attributes you can put on them so that you're building like good quality swagger that's versionable that and and all that kind of stuff um you've shown us some stuff with um looking at azure functions and like the azure function integration um a few things i wanted to make sure we we got time to cover too is the um some of the stuff with connected services and then if you have time to look a little bit at like the api management integration and the low code stuff totally totally do that um so this really is just like the azure function when i hit f5 um on my function you know it knows what urls i'm going to do see here i didn't have to tell it to render swagger ui it just does like the bindings do that for me and then also they've got a render open api document and a render swagger document so you can use either one of those flavors and if you're doing the open api you've got json or yaml so you've got it all nice so this is great for serverless dev i want to try out you know functions and open api so you want to talk about connected services yeah yep and this is something i think a lot of people don't know is like is included so it's a neat thing it's it's kind of cool so essentially we used to have this thing in the in the product i don't know if it's even in here anymore i want to show you this if you've ever used this feature looks like it's gone so that's good there used to be a feature which you looked an ad here uh and it would basically be add uh service reference sort of thing it's like service reference but it used to be add rest api client yeah okay where that that feature is kind of kind of old and kind of kind of gone um really where it lives now is in connected service so what i did in this project here was i right click this project and i literally go to add and then i say connected service and what you'll see in here is that we've got service dependencies and that's where you do things like cosmos db or sql server those kinds of things but we also have this segment right here called service references where i can say open api or grpc so what i can do right now is i could click plus and i'll show you the grpc one first even though we're not going to go into too much detail on it i'm sorry sorry uh is if i click next here now i can actually generate a server or a client project from a proto file so you know whereas rest apis kind of use open api to describe themselves uh grpc services use proto so i could write a proto file and then i could actually aim this proto file and i could generate a grpc app client or i could generate a grpc server stub like i talked about earlier that you can then like put your important code into and we've already done all the wire up so that it will emit grpc for you i won't do grpc today because we're talking about open api and rest apis so i would go here and i would select open api and then you can do two things you can provide a path to a file or you can provide a url path or i can select an azure asset we're eventually going to add azure api management to this button so you'd be able to look at your azure apis inside of api let me just well you'd mention grpc let's just like cross that off the list can you describe how do i choose grpc or open api what's kind of the difference that's a great question this is my answer okay so um grpc uh is what you would want to use like in kind of the same way this is my answer if you ask rob he might give you a different answer or james um grpc to me feels like you would use it in the same places that you would use wcf so if you're inside of an enterprise or you're inside of like a cluster like it's you're very popular inside of like kubernetes clusters um if i were to want to communicate inside of my enterprise or inside of my cluster or i know that both my clients all my clients support grpc that's when i would want to use it the example that i gave yesterday when mads asked me this question was if i have a small embedded device like smaller than a raspberry pi it can't handle like usually it couldn't handle something like grpc uh because it's just low memory low network support et cetera et cetera but it can handle http get and http posts so what i tend to advise people to do even though i don't give advice is if you have a if you have a you know a kubernetes cluster or an aks cluster uh you can put all of your micro services inside of that cluster you can create an ingress on the front of it everything inside of that cluster can communicate using jrpc wcf whatever you want the front door of it would be normal http so that would be where like your rest api is like your rest api coming from a phone coming from a small client coming from a soil temperature humidity checker you know that's where you'd want to do you know rest apis because they're more lightweight so okay yep yeah and there's there's sort of like an architectural feel difference like grpc is remote procedure call it's rpc right and and like this is more service oriented and it's more like yeah so um yeah that was an interesting conversation with ryan the other day on dapper and uh yeah and uh rest apis it really made me think i had a conversation with him right after that show actually so uh because i always talk about rest apis and i was like yeah i'm not stopping no no no that's not what i meant that was a great conversation so um but i'm not going to do this here i just wanted to show you how to get to it you know if you're inside of a project you would essentially right click you would go to add connected service and then you click on the this you're here and then you click on the open api and then you would you know party on it now what's cool here is you're adding this isn't a one-time thing like it's actually adding that reference so you can go if you update the service you can refresh it later right correct cool right so i'll show you something that i do when i build these projects that one day i promise we'll have directly inside of visual studio mads was breaking my heart the other day because he was like don't you remember when i could like you know add a asmx project to my solution and then i could add a desktop app and then i could just hit f5 and they both ran and everything works and i was like yeah yeah crawl welcome um so here's how you can do this yourself so what i did when i did this this open api you know connected service experience thing um if i double click my project essentially all you get in there is this so that's this and if i were to scroll over here you'll see that let me kind of give us some room to breathe you can essentially see here that the first thing is this file it wants to include this open api uh json file that is built from this project right here the api project so if you think about the workflow the api builds during the build and i'm actually using the swashbuckle cli in here we actually use that inside of api and publishing um and you could you know you could do this using n swag two because that's why i can actually output um your open api file and build but i did this by hand and this is in the sample one day we'll have some sort of a gesture where you know once this happens we wire this up for you and you know we're done here we're not there yet um a lot of that is actually customer feedback because some customers were concerned about that so you know we just have to get it right and there's a lot of wrongs um so what i've done here is whenever i do a build like any time i build my api project the thing that will happen after build is the swashbuckle will generate my open api file for me from my assembly after i build my project so i build my api dll then i build the json file that is associated with a dll that basically describes it using open api then this project builds the client project builds so it builds it pulls that json file in then it does a compilation and what's interesting is if you were to if i were to view all files here is this the right button no where's the right button where's view all files john oh it's up it's up at the top and it's like two to the left of the wrench yeah so if i were to expand this i think it goes and it goes there's an object so there's a a question is the swagger generation only for net five and it's it's not right you've no it's not it's all the way back to framework you can do uh swashbuckle goes back to asp.net framework uh all versions i've been using it i've been using this just since you and i worked together which is a long time ago um so if i were to see here this file right here contoso online orders.api client.cs if i were to open that up uh this code is generated by tool and if you were to scroll down you'll see thousands and thousands of lines of code that you would have written yourself it's instantiate an http client properly quinquink make the request get the response back this is important check the actp response code to make sure it's one that i thought i was gonna get like conflict okay not found if it's what i expect to get if it's one of the ones i expect to get look at the payload deserialize the payload into an object pass that object back to the caller you've written that code a hundred thousand times and we know nobody wants to write it again for 1200 lines so we were talking about this when when we were like working on the blog post and it's like you don't want to have to look at that code but that doesn't mean it's not good code it's good quality tested code it's code that the like microsoft api devs argue about and make sure it's perfect and handling all the edge cases and stuff so it's good quality api code it's just code you don't want to have to write and test and fix and maintain and stuff that's exactly right um and we've had we've had many meetings with with all the folks who work on these projects and like we give them feedback just like they give us feedback i want to show one more thing on that can you go back to that client oh yeah you would you would do that i i would yeah sorry so the client that it generates is a partial class so if you did want to extend it because it's code generation you don't want to ever modify generated code but you can extend that partial class so say for instance you want a utility method or you wanted something that was like you know get in check customer blah blah and it does like compile several things together or adds custom validation or whatever you do that in a partial class yep exactly exactly and since it uses the http client underneath you can use like the delegating handlers and all that stuff so that's something i had asked you about before the calls like hey is this something we can talk about so that is something with um http client has support for things like poly for retry and all kinds of other stuff and so you can because you're passing that into this generated client you can configure all those policies you can use poly you can use all those sorts of other things you sure can it's all in there i mean it's literally the same code you would have to write you just don't like writing it yeah it's like like doing a forms over data app or something like that here um i know we don't have much time and i know you want me to show this i'm going to do one more thing and that is uh i want to set this as my startup project and damien brady i'm sorry i'm going to right click publish here but what i'll do is i just want to show you this part of the experience so what i've done is since i've got that swashbuckle action in there and i'll just do a new uh publish profile here and i would select azure and i would do app service uh and then i would pick my app and i'm not actually going to deploy this so there's my web app but look here you see how i've got this new node here called api management okay what that the reason that's there is the project system can see hey alex nice to see you uh um that can actually see that i am emitting open api because i've got a reference to swatchbuckle.asp.net core and what it does is right inside of here it shows me my api management instances so that i can pick one and i would pick store apis and i would do finish and it would just publish my app to app service as soon as it finishes published in the app it's going to use that um we do exactly i actually took the code out of the out of the repo we do exactly the same thing we literally use swashbuckle cli just during that build time step to produce that json file because we you might not want it running on your you know production site then we ship that up to the api manage watch me here we ship that file up to the azure api management management apis so that we can create a new api in your management api service instance how's that so nicely said so we we do all that stuff and what that ends up giving you if i have a browser tab open over here is if i were to go to azure you can see right here now remember i talked to you about operation ids this is my store api that i ingested directly into api management and look at here all of these pretty names john could come along and inherit my apim instance and he would know exactly what everything does here okay let me try it and see if i got the sales pitch correctly from you last time i talked to you about api management because part of me thinks like this is just something i could host with kestrel i could host it and whatever like why do i need to put it up here in api management some cool things with this number one is you can handle like all the versioning you can handle um you can even handle like policies and and i think you can have different like authentication and you can have like i could say there's a you have to have a paid subscription to get access to these certain things and that kind of exactly so let's say you are somebody like stripe and you're like your business is your api you know what i mean you can go over here inside of azure api management and you could set up if i can find it where's products if i can actually find products in here somewhere i can actually have different products and i'm not having any luck finding products you can actually go in here and you can set up different products and different there we go different subscription levels and whatever else you can see here that i've got a starter and i've got it unlimited i might have something that was like admin only and it's the only it's the only you know set of customers that can actually access those admin apis um but it does a lot of other things too like you talked about security i could actually go into this api this is something that christos uh who pinged us earlier uh is looking into uh from the identity team in partnership with the azure api management team is a way to use api management to authenticate the apis versus having all the code to authenticate your apis so api management would become your off layer versus you having to know all the different sdks and everything not proposing that that is a you know one one solution fits all but it is a solution and it's a solution that a lot of people want to do you know investigate one other thing you can do and i'll talk about this in the blog post that's going to come out later this week but if i were to go into this resource group here now you also saw in my in my api management instance if i were to go that's not it in my azure api management instance you also saw how i've deployed that function out um so you see that i've got the store apis and i've also got the notification api which would essentially send an adaptive card to a team channel if i were to go in here now you'll see that i've got this logic app now if i go into that logic app and i go to the edit view and it's failing for me at the moment i've done something awry but you can see that i can set up a recurrence and this is my azure apim instance i can actually write a logic app that will call the individual apis such as initialized like well actually in this case i'm calling my get low my get low inventory products i'm creating a variable that's equal to all the products that i got back then i'm looking at that variable to see if that if that list of products had anything in it and if it does i'm making a call to my azure function and the way i was able to do that is i've got my azure function and my web api behind api management makes sense and then the last thing i'll show you is the other thing i can do is i could build a power app so if you are uh if you're in an enterprise that uses office 365 chances are you probably have power apps access too so i can actually in my api if i go back to my api it's as simple as and my api right here after i've published it to azure api management i can go right here and i can click export and then i'll click powerapps and power automate and when i do that i've got access to that api so that i can build little mobile apps that i can distribute to my powerapps users and if everything's working which it might not be if i click a button here what that'll do is i'll actually make a call out to that api in my app service and get it all back and i didn't have to write any code to build this power app it's all directly inside of the powerapps you know thing uh if i were to go here and actually click edit excuse me i should back away from the microphone um if i were to go in here and click edit to actually open up that power app what you'll see when i single click my button is a formula bar up at the top like with excel like you know like powerapps do and it's actually making a call out to that apim fronted api which then makes a call to my.net code so if i were to click the button right here you can see this clear collect is a method that basically clears a collection and then it calls the store apis dot get products method if i wanted to do something else in here i could actually backspace over this and you can see there's all those api methods that is actually in my web api wow okay that's nice and that's really cool yes yeah so wow that's been fun so this you know the reason i show you this is we like the idea of you know there's a there's a lot of folks out there who you know they don't want to become developers but they have business needs they have to solve you know like hanselman needs his tacos so you know if we run out of stock you know we got to get the stuff in you know so well and it's great to be able to kind of scale things to to where it's appropriate like i love writing code but i do plenty of automation stuff for work using you know logic apps and power automate and stuff where it's like i don't need to maintain an app or i don't want to pay for and we deal with hosting like i'm just going to set this thing up and it's going to just work you know and and not like that but when you think about like if you have four or five different web apis out there together that you need to like snap together and do certain things you could go into your code and you could do all that http client code or you could do something like this this seems easier yeah it's kind of easier to inherit easier to maintain you know there's handle handle the recurrence handle like that and if it fails you get like a nice i i don't know if people watching like are using this much but this is this fits so naturally into like web services and other apis and stuff i use this a ton oh yeah it's great so see here i can pick the store api is now asking which api i want i can even call a specific version if i wanted to you know i could do 1.1 so you can you can really do a lot of damage there it's kind of it's been kind of fun so okay so so we're getting towards the end we have a visual studio toolbox live coming up at 11 30 a.m pacific so in in the last kind of couple of minutes here let's wrap up because we've talked about a lot of stuff oh yeah so so let's like what's what's the takeaway for api developers the takeaway for api developers is keep you know if you're already an api developer you know keep doing what you're doing uh period you know full stop uh the most important thing i would want to leave with you is think about all those cool things we saw at the end like you know being able to like drag and drop stuff together in logic apps being able to like you know give an api to a citizen dev and have them build an app that talks to it and you know do whatever you want this article is the most important part of that if those apis aren't well described they're not you know you can't just walk up to them and look at the open api know what you're looking at and you don't follow certain conventions none of that other stuff will work that's key so i would just say you know learn how to properly build and describe your apis you know test these things out you'll find what works for you you know um but that's really the the main thing is just like think of your api as a thing as a source for reuse you know if people can't if people don't understand it they can't use it okay so so i start by like going through in here this shows how to create those discoverable apis that gives me a nice open api endpoint and then because of that then i can make use of tooling i've got this nice open api like view where i can debug and test and and document my api i can generate client code and then by publishing it and stuff i can do all those kind of fancy things that that you showed at the end there too yeah basically lots and lots of integration possibilities so integration wasn't possible without well described awesome okay all right well we need to wrap up so that the next folks can get all set up uh if uh do stick around if you're watching and you're interested um visual studio toolbox live uno platform sounds really cool and um thanks a bunch brady always amazing to have you on it's been great great okay is that the show with leslie and and uh robert uh it is i gotta say yeah it is i gotta see that that's gonna be cool awesome okay i will switch over to the thanks for watching and thanks for watching folks take care everybody [Music] so [Music] you
Info
Channel: dotNET
Views: 12,498
Rating: 4.9589043 out of 5
Keywords:
Id: Mpf0fCO6NrU
Channel Id: undefined
Length: 89min 52sec (5392 seconds)
Published: Tue Feb 23 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.