Going Cloud Native with Spring Cloud Azure by Julien Dubois and Josh Long @ Spring I/O 2019

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[Music] yeah we made it alright so hi everybody my name is Josh this is Julian I work on the spring team right good to see you all how are you I'm just before we get too far down the line I mean I'm always curious how many of you are using spring ok good how many of you using a cloud platform like azure ok good ok right on you're going with using well who's using Azure in particular ok good okay so the rest will be converters ok if you have questions oh oh very important very important before I get too far here there's that code ok so we're about to write a lot of code together today we have very little time together unfortunately but during this time we're gonna look at a lot of things and as always the goal is not to remember what has been typed it's more to appreciate what is possible we're gonna look at stuff in Azure and we're gonna then look at how that stuff is supported by api's in the spring community now I I've been a big fan of what Microsoft is doing for spring users for a long time right they have been using they have been building integrations for spring developers for the last at least two and a half years that I've been working with him right and there's teams in in in Redmond right there's teams in China and Shanghai right so it's very interesting to me there's actually full-time there's actually a full-time team with lots of people working on support for Spring at Microsoft which i think is really cool right so so they've worked very closely with the spring team and there the goal is to make their integrations as easy to use and as palatable for spring developers as possible and so there's actually you know there's some really big pieces that are already there right and and I think I was always kind of an interesting interesting thing as well right now in the world it's the number two most widely host platform right most wide to use cloud so being able to right code for that I think it's kind of interesting how many of you know about Satya Nadella the CEO right very interesting person he since he took over the whole you know the motivations for Microsoft have seemed to have changed first of all they they have moved away from this idea that Windows the desktop is the most important hub in the universe and they're in there sort of embraced this idea that it doesn't matter who built the hub as long as they as long as they own it right and so no that's very reasonable it's very pragmatic so there was a friend of mine a guy named Xavier soltero he created a Microsoft he created an app whose name I forget now because it was years ago Microsoft bought that app for iOS that was the number one email client on iOS right so people were using it on iOS more than Apple Mail he bought that company and that technology and they just they just rebranded it Microsoft Outlook for iOS right very smart so I saw that years ago I'm like oh I get it now they just want to be and they just want to control them the platform that's fine right that's what everybody wants to do same thing for Azure there there it doesn't have to be Windows desktop it doesn't even have to be Windows on Azure as long as they control all right so they didn't very sort of open now right and so this is what is it now it's already already more than half of the app instances on Azure are now Linux and dollar and non Windows right and that's a very interesting sort of situation so when I see that kind of happens kind of stuff happening when I see friends like Xavier who who's from SpringSource right xavier worked on IP rick and and all these things back in the spring source day so to see him go to Microsoft and see people like that go to Microsoft they're now Julianne yeah there you go it's a it's a long journey I don't see a lot of smart people going there so so for me to engage the government then I I'm happy why go why I work on a secondary team working on the spring when I can just work on spring but but either way lots of good stuff there so I've spent a lot of time working with people on the on the mic side of the deal right so we just had Teresa nuyen and Kylie being for example on my podcast a bootiful podcast they were from Microsoft as well so bootiful podcast how many of you listen to podcasts okay how many of listen to my podcast the only one that matters okay the rest of you get on there you go bootiful podcasts on iTunes and Google Play so we had people from we had interviews with them I did a I did this blog bootiful oh yes I did this blog series last year and it was very very popular it's one of the more popular things that we've done it's a six-part series to using Azur and spring and so on together so like that that relationship is very very interesting to me and some of my friend Julian here you don't you don't know anything about spring you know what I mean what are you doing since then just ask her or else so so you're now at Microsoft yeah I do one way to go right but gay hipster has always had a good sort of innovation right yeah it's working really good because good right okay so that's very cool so that's we're going to talk about today now how do you get started with Ezra how do you sign up for a new account for people who are haven't done this yet yeah okay so portable desert calm I said okay usually but six $200 of food credits okay and what is that in like that's right yeah those are tons of free stuff for always you know like free cheers do you have unlimited accounts at Microsoft for me yeah I can yeah I do a pivotal so you should come to pit oh that's not much at the sewer you know we have it anyway you know right um okay so we have like so that you can start up there and there's a lot of interesting things that I think for me that make up Microsoft Azure oh great obviously what we're going to talk about today is writing spring apps that talk to infrastructure that's managed by Azure and I think that's really one of the key differentiators there right you can run code foundry on Microsoft Azure we were named pivotal and cut funding particular we're named partner of the year for Microsoft last year the year before I forget because so many people generate you know large customers huge customers that come to piddle they want to run their workloads in the cloud but they want that layer beneath them that allows them to move to another cloud if they need to a lot of these are people that are like well AWS you know I've seen what happens when people run applications on AWS right they end up competing with eight Amazon right Amazon somebody starts building a business so if you're successful or native yes a lot of people like I don't want to risk that or maybe they're in the same market as eight of us right so they're they're doing retail or something like that and they don't want to pay Amazon more money so they go to they're looking for a good option but they're they're a little they're not excited about a Davis and the technology is not you know what they need they can get elsewhere right and they also want portability right they want to go to say okay well Microsoft's got all these really great things but a lot of organizations want multi data center strategies so they go to things like Cloud Foundry so we have a great sort of partnership with Microsoft and as a result a lot of people use that on Azure and so I thought that was kind of interesting and you can run it on there you can run it on kubernetes and there's a Azur aks a kubernetes service you could also there's also a weird thing where you can like it's the azure web yeah that's a thing yeah yeah there's a there's options okay but the point is that's not what we're gonna talk about that because that's all sort of either it's not what I would recommend which is like the fabric fabric is fine but why would you do that instead of something like kubernetes or class I agree and then that's all that's all good but what's interesting about Azure is all this other stuff all this stuff that I don't want to manage right all this stuff and I'm not interested in managing like infrastructure so what we're gonna do is going to build some software today it talks to these different things and we'll introduce how to create them what we're not gonna do is create them on the fly though so if you've ever seen talks that I do I don't usually spend a lot of time doing any one particular thing in my presentations but with uh sewer you know and with any cloud provider not just as you were obviously it takes time you have to provision infrastructure and so I don't want to sit here waiting five minutes making a cup of tea while my infrastructure spins up is that five minutes but it's still longer than I want to wait so we're gonna I've already got rabbits up my sleeve you know that expression you see a magic trick and you got a rabbit up your sleeve so we're gonna build new software today and of course in order to do this we'll go here to my second favorite place on the internet after production start that spring today oh let me um let me see here get status good definitely not gonna commit that I we're doing the slides I think we're done anybody have any questions about the slides okay moving on good downloads good all right so there's nothing there except that poop from the OS so we're gonna go through application we're just gonna use a lasting latest stable thing I'm going to call this Azur and we're gonna bring in the support that we need to build applications today using my stuff's Azur so I'm gonna bring in the web support I want Lombok I want to Microsoft sequel server I think I can see wanting to connect to Microsoft sequel server we app we have but we have Microsoft sequel server support on the spring initializer right because there's such a such a huge demand right I'd to be honest with you I didn't appreciate I didn't know I didn't appreciate before our partnership with him just how popular sequel server is I always thought it was just sort of like all Oracle and then like postcodes in my sequel i yeah but yeah and but a sequel server is awesome right and I'm glad to see that it's very popular so we added it to the initializer and today you know you saw the keynote I think we probably heard about r2 EBC is that true our 2d VCS are reactive a API for sequel data store access you can use sequel server both reactively and nonreactive Lee right so it's actually really it's ahead of Oracle good thing right when you get your pub right so so all that stuff we're going to add that we're gonna add that they're gonna use JDBC and then we need to Azure we need the dependencies for our server so we're gonna bring in a few of the different dependencies I think we're gonna use Azure support though we just need one really right we just need one that will bring in the dependency management that manages the versions of these maven plug-in maybe dependencies and with that we can then just bring in the other dependencies that we need so we've only got a few checkboxes here there's way more options than there are checkboxes okay anything else can you demo yeah I haven't used it no you can do oh yeah okay good well bring keep on good we got a new demo oh good so we're gonna go hit generate in my account okay so I'm gonna open this up okay and while we're there how do I provision key vault oh just I think keyboard okay Oh still it's okay okay one okay beautiful yes beautiful month oh yeah he's now on Windows yes awesome I looked at the new surface pro that's pretty interesting I booted should let's go for myself Pro yeah I want the big one like okay thank you I keep a web serie cluster in there it's yeah it's a very fat jar yeah okay so we've got this now create a key vault yeah okay would you follow uh-huh uh-huh uh-huh good and choose a resource group exists oh yes so it's a choice we carry for we're gonna just let this run in the background yeah and we could oh yeah so people can see well yeah we'll do that again slow note okay so it's refreshing well it's good that's a little bit you never know yeah deployment failed okay so maybe we already nine News oh you already did it we should have refresh the first time so he votes there it is yeah okay go to the resource so the first ones ready and I tell you the second one sweet okay so you can show that later right okay so what we're gonna do is we're gonna build an application that takes advantage of all this stuff we've got a brand new build here in order for this to work we need to add more dependencies right so let's go ahead and we're gonna add some dependencies here and I think the first thing I want to do is I want to look at something that's boring something that you could do without Azur but that would be much more difficult right one of those examples is sequel server sequel server is again just a really interesting thing um again when I think about databases right I mean I think of like true enterprise-grade databases if you ask me 15 years ago which three databases can I guarantee would be a good fit for any organization I would say Oracle sorry Oracle db2 and sequel server these things the features enterprises need like at rest encryption of data right this idea that you can add data to a database and have it be encrypted by the database itself that guy you know PostGIS has for example but these kinds of things are very very useful so what we're gonna do is we're gonna use sequel server and I don't know if you've ever had to manage a sequel server database but it's not something that I enjoy doing in fact I would much prefer not to do it although I guess it's now possible to deploy on a Linux it's possible to run yeah it's a run you can run it on Linux out sequel server so the world is different anyway you can great but the point is I'm not gonna run it at all it's just on a cloud now so how gotten is I've got a sequel server instance I went to my I went to my home essentially and I search for sequel server and then you can you can see that there's sequel servers you create a server and then you create one of those and when you have a sequel server then you create a database right so I've got sequel databases and then in there I've got adventures now this is based on a template image okay provided by Azur it's just a template database called adventure or something rather and then you've got tables in there so where's my tables where's my data browser data security there's a way to view that data query editor that'll work that looks right password what is the password so I'm gonna okay maybe fair that's okay no problem nope so the nice thing about Azur is that they have this thing called a resource group okay and so a resource group you can you can create all these manage infrastructure pieces and assign them to a resource group and then when you're done with your presentation on stage you don't need the resource group and everything that you created gets destroyed so I can show you passwords and I don't care you know it's all gonna be gone in a minute anyway so grip password okay so sequel soon so smart so it's springtime okay so I'm gonna add this here I'm gonna log in hit OK and there's my database tables and I've got a bunch of tables already and you know I've got a table called products so I can say select all from actually one if I can just double click on bagel there's my schema right so select all from product can I do that run whoops I need to specify the schema sales OT that product ok so there you go you know it's pretty basic anybody here use Microsoft Access or something like that in the browser really yeah but it's not made to work I am I used to be for two years yeah [Music] this is it there you go I truly believe this yes like statistically most software out there the competition is some homegrown access or Microsoft Excel solution and I mean how many of you have something written with a spreadsheet somewhere that should be managed by software there you go there's at least a few the rest of you are just too embarrassed or or worse you don't know that it's happening but it is happening so I'm gonna bring in the sequel I'm going to connect to this database here I'm gonna use this query because we know it works and I'm just gonna the it's got a name a what is this message is it's a I guess I want the Select name product number number and then it go all right there you go that's a simple enough query okay so so let's let's now build our application and get it to work with that so we're gonna go to our as our application and I'm gonna create a component can you make can you see that fine is that too small make it a little larger font font make this 22 and I'm gonna say add component class sequel server demo okay an event listener application ready event class public void talk - yeah whatever sequel server there you go and we're gonna do is want to inject the the JDBC template and how many of you've used the JDBC template before it's a very common anything I think if you use spring 15 years ago the reason you got into it was probably because I I'm getting better okay like in the very beginning knows all about this I would always just add the constructor and you know whatever but but now I'm starting to like this Lombok annotation have you seen this before Lombok allows you to synthesize a constructor you say Jeeves 10% that query come on select I'm gonna take this query paste it in there okay and I'm gonna provide a row member so the row mapper and we're gonna create an object to type what did we call this here it's called a product okay so static not short static class product private string number or name yeah and then private into number is that right no strings as well a boutique number right so number and let's map it in the sequel but I'm gonna it's redundant product that product number is City so product that may impact that number it's okay so I'm gonna map it to a instance of this product okay and there you go and what I'm gonna do is I'm gonna visit each product I'll say a new product results set that get string the first field is the name as it capitals yeah capital n and then the second one is the yeah product number okay and that should work that should give me a result like that okay so I'm gonna visit each one of those results that come back I'll say for each and I just want to log it out now using my logger which I'm gonna synthesized here using log4j so there we go log info now in order for this to work I need to config that allows me to talk to a zoo or something it's just standard spring dot data source type stuff right I'm not gonna do anything special here so okay okay properties and data source there we go paste okay so all I'm doing is I'm saying this is the password here's the password here's the URL the URL has a password in it keep that in mind so you need it twice for some reason you could probably get away with not having it here or not having it here maybe yeah I haven't tried it but it should work yeah here we go go go go all right hey look at that so there's our data okay so you can see that was easy enough okay something that now we're just talking to sequel server big win but I don't think I mean yes you can use a xuer to manage sequel server and I think that's a win because you don't have to manage that piece of infrastructure but if you're gonna use a platform if you've gotta use something like Azure which is kind of sticky there should be a really good reason for it and a lot of people for what one of the things that I love about us is cosmos DB right so cosmos DB is a piece of infrastructure that you can't get outside of azure it just runs in a sewer um and I was looking for some I looked up and down I looked left and right I looked everywhere to find out about cosmos DB I was trying to find a way for me to be able to say that I would not use this right I was looking for a way to say this is not the right fit and I didn't have a lot of luck and the reason is because first of all a sewer has more data centers than any other cloud provider so there are no there are more locations for Microsoft Azure in the world than any other cloud provider more more more geographic geographic locations did you know there's even a sewer in China right that's very hard to do do you know freak out yeah China yeah it's how that because that's that's useful it's unique but it's not particularly hard from a government perspective to get there to have a region in China on the other hand is very difficult because of course what happens if you're a public cloud provider in China right the first person that says something bad about somebody in the government if they deploy that app onto that region you know takes down the whole cloud right so that's a it's dangerous so they have to make they have to be very very careful about getting that deployed there and so it's actually a separate it's not it's you can't manage it exactly in the same way that you manage the rest of us who were it's actually a separate company technically but it works right if you if you business depends on being able to go to China that's there that's a big deal if you come here right sometimes this is China property right yeah that's that's to me that's super violent right there you can actually take your code that runs in the rest of the world and get it to go into a huge market you can't afford to ignore this market so so I was looking for reasons why well maybe I don't want to use cosmos maybe there's something wrong with it maybe it's too expensive turns out it's not that if it's competitive what about api compatibility with it what if it doesn't match my expectations well it does actually match what I want to do because you can use it like MongoDB you can use it like a sequel database you can use it like Cassandra so there's a lot of different ways you know what's a thing and we're going 1280 CDC portal so what is it etcb xcd and extremely are true to setup also right yeah there's like one unique thing that just gets on with the SQL right right there's a lot you can it is one database engine that has these different interfaces that you can use now that might sound a little crazy and it might make the question of well what does it actually do well it's a database it's a geographically replicated like database it works very very quickly when you use it in sequel you know you can use your queries against it there are sequel you don't update exactly using sequel but still some very interesting options so the point is if you're using it if you want to use it you can use the low-level API or you can use it from spring data so there's actually a module yeah synchronous up yeah right right No I think we're happy I like this one works with screen data right let's do that that is synchronous right so the point is there's a whole spring data intubation and that's what we're gonna show you here so I'm going to go back to my build and let's see here I'm gonna open up this project file to remember the build file ok did you do on the XML okay and all I want is the version of by the way if you're using Java 12 you're gonna need that draw anything greater than 9 you'll eventually need this so I'm just gonna go ahead and add this right now so Jack's be your little justice oh yeah okay there's that and then I want to bring in the the smoothie hey we go cosmos TV okay the starter so here we are so I'm adding in the Asuma cosmos TV spring woot starter and again I don't have to manage the version because that's already managed by this spring bomb yeah familiar with the spindle status yeah you just import them and you get everything automatic configuration is ready to be used right so what entities do we have in cosmos well we're gonna create it we have an object of type reservation I thought as much just making sure so it's a reservation and we're going to have a document and this is a call Microsoft Azure spring that at cosmos TV core mapping document okay [Music] right alright good so a tidy there's my entity okay so now I'm going to persist this into the database I won't be able to manage that the lifecycle of it and so I'm going to use a document DB repository okay managing entities of type reservation whose primary keys of types of string and that's it once I have this I can now create a cosmos DB demo okay so class cosmos DB demo event listener application or any event class public void cosmos sure component good stuff and in order to get this to work I'm going to inject my reservation repository like so and we're gonna say required arcs constructor and now I want to write some data today base I'm going to create some some records here I'll say steam dot of let's get some names my name is Josh nice to meet you Julian hello buddy how are you Sara Sergey yeah okay um what's your name Lee how do you spell it Nelson Nelson like that okay nice to meet you gusto what about you Eddie Phillip like this Oh like this very cool okay very good what about you buddy like like our spring data okay we have a we have a Derek there's a six who wants to be we need two more victims actually let's see I just want to get the audience involved there we go it's better one more [Music] I'll just think of some names here my Dora the letter and Oh God there we go so nice mini girls room Nelson that's not nothing so this is names okay names dot map name and we want to create a new reservation passing a null for the ID mapping it like this and there's our reservation stream and for each one of those I want to write it to the database all say map or dot for each other or this deposition pause about say if passing on that and there we go those are react there's our nonreactive but super fast code let's run this and see what we get well I need the configuration oh yes so so I'm gonna take these information here there you go I see people taking photos yeah so there's my cosmos DB instance right it's called this is the native database name here's the URI and there's the the key and you can get that by going into of course your your your a copy of portal okay okay cosmos DB going to your instance and then you go to your keys and you're given a primary key and a secondary key okay so I'm just using the primary key you get the URI and a key and you plug that in and then here we run make sure obviously in a normal application you wouldn't store this stuff in your property file you use it the vault yeah right so you use the constant goofy or spring cut config server or the config vault the vault key value volts on Azur and that will store the keys and values separate from the application and then you can just inject them you can just say a dollar sign my property name okay so now there's a product well a lot of products whoa okay how do you do limits anybody know how to do a limit in sequel server is it just limit okay cosmos so top like that okay let's try that out fingers and eyes crossed cool I was awesome thank you okay so that worked and now we can go back to this Cosette saved we say find all that for each so dot map okay actually I'm gonna say that for each let me just get all the records back and we just log it out so and walk for gate that's fine we got two more demos life is good so here we go there's our reservations from cosmos TV there's our data from sequel server now I'm using the sequel data stores here that's fine a very common thing when we build a student system of course is you're not just doing synchronous reads and writes you want to actually decoupled the system especially when you move to the cloud and when you decouple systems what's the easiest way to do that exactly and so there's actually a really interesting sort of branch of work that's being done at Microsoft being lent being led in part by a gentleman named Clement masters just he's all he walks on the AMQP specification just absolute genius mad scientist guy he works at he works on AMQP and he does a lot of work with Microsoft and so the messaging support for Microsoft is just amazing some of the best in the business because this this crazy guy just brilliant guy work sign right so so there's this message press the option called event bus or service bus service buses as they were service bus is that right and and that speaks multiple protocol so you can actually use it from a mqp you can use it from JMS you can use it from a number of different API services most critical well today yeah yeah there's a API binding that allows you to talk to it through an EP you if executed if you want yeah you can use Cupid which gives you a JMS binding so there's a lot of options there or you can just use the native the API and that's fine so that's what we're gonna do is we're gonna use the Neve sort of a API here so I'm going to create a class a service bus demo and what I'm gonna do is I'm gonna right I'm gonna register a listener wait a second because it takes some time for the server to actually recognize that I've been a listener and then I'll register I'll then I'll send some data okay so private final I topic I need to actually bring in the depends here so we go back to this palm that XML and we're gonna add in Azure service bus spring blue starter there we go okay that seems okay to me so we now we're gonna say private final I topic clients and private final I subscription client okay and event listener application ready event public void service bus okay so in this if you are if you know about AMQP if you know about random queue for example then this model for service bus will look very familiar the reason is because it's got the same arrangement same topology as rabbitmq as as a as a AMQP broker so you have this idea of a destination which is where you send messages but those messages don't you don't send it directly to the queue or to the topic you send it to something called an exchange in rabbitmq or in mqp panels and the same thing exists here so you have this you have this idea of I'm gonna send it to this destination and then I have a I have a thing called a subscription which hangs off of that so the producer sends it to one thing the consumer consumes from another okay they're not they're not a sonic JMS where producer and consumer talk to the same queue or same topic etc so this thought I taught I subscript in client that register message handler new iMessage handler I like that it's got eyes this is write net you know we can see that code so completel future that [Music] whatever no okay I don't care about that um I'm gonna do this I'm just gonna log the message right unhand oh I need a exception throw his exception and when the message arrives I'm gonna log out the message okay so log4j log that info new message message dot get content type with correlation ID message get correlation ID and body message dot okay oh I needed to make that a string because it's just bytes so it's it's a it doesn't care about how you represent the data okay so there's my thing okay and log dot error exception and then finally once that's done registering I'll sleep one second and I'll send a message so this dot I taught a client dot send now how do we send the message as who are application it might be yeah there's new message good stuff good stuff that's exactly what it should be hello at instant dot now all right let's try that out two minutes let's just say three minutes it's fine nobody's gonna die okay so we need configuration oh yes fair enough everything um so yeah properties service bus good stuff okay okay so here we're going to you know got a connection string you've got a topic name and you've got a subscription name these are two different things or sending messages to a topic you're subscribing from the subscription okay and new message North correlation ID null and body hello equals hello aunt whatever okay so there's our consumer now we're able to decouple obviously in a normal program you wouldn't send a message to yourself that would be ridiculous you'd have to producer to consumer but I wanted to show you that and now at this point I've got you know I got this I've got a a regular traditional thing that I could have done without a zero like sequel server I've had thing that's completely unique to us or like like cosmos TV I've got a thing that is made better by the fact that azores the distributed cloud that has regions in every world part of world like Kozma like service bus taking advantage of a globally distributed engine network that messaging subsystem benefits from that distribution and now finally if I've got all these moving pieces I've got all these things in the cloud all these things running in spring and they're talking to each other I've got micro services abound I'm gonna need some operational yeah I'm gonna monitor that I'm gonna have a lot of moving parts a lot of confusing pieces so what I want to do is I wanna be able to kind of follow the movement of data in the system so how do you what do you recommend for that insight application inside sorry ooh I am not used to your match windows yeah so inside it's a full moon solution if you use something like to reduce it's kind of the same thing but it's all Aussie by Azure so you have nothing to do to use it and we're good bootephant sides so this is going to give you lots of tiny graph of your absolute by default what's good is that there's an integration or service screen boot so there's also a spinet starter I don't know where you put all your status oh yeah XML this is that c-come on see let's give them that chef's touch I'm here but he used Mac for years yes he's gone to the window no but I will come back to a Mac pretty soon get back next week nobody yeah we fixed a version because yeah so what's going to happen is that as a support of micrometer with it so in the next word is yeah you will have you know micrometer is the new shiny which won't sing from spring boots right and so it's being to still matrix for cash for the data source for Europe well everything then you get some sort of API for that right and so what is that spring would I was going to send show micrometer also data to come inside boots inside that inside at this part there okay I need a binky didn't we already did it no you do it okay so I'm gonna get the key from here this is a key thing to choose in the future right because it's Jamaica later okay good I'm also hoping we could push the key right okay so localhost universe of to ourselves all that so I said too much in service it can take a little time for students to give the data okay I'm making relicensing refund yeah it's going to assume that you can click on live matrix then nobody everything works well yes good yeah there we go so you don't need to it so you click again if you click again you should see them arrive in straightaway which is fun okay so I'm driving traffic on the left you can see it arrival and right already my friends I hope you got something out of this get us it's better than you think so much for coming [Applause] [Music]
Info
Channel: Spring I/O
Views: 1,325
Rating: 5 out of 5
Keywords: springio19
Id: AZFmM6-h_So
Channel Id: undefined
Length: 45min 8sec (2708 seconds)
Published: Thu Jun 20 2019
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.