Hey friends.
On an earlier episode of Azure Friday, Bruno Borges came by to talk
about Java development with Microsoft in general and Azure in particular.
But we ran at of time with part one and we didn't get to see it in action.
So now part two, Rory Preddy is here to show me all the fun
Java demos we missed in that earlier episode,
today on Azure Friday.
Hey, friends.
I'm Scott Hanselman, and it's Azure Friday.
I'm here with Rory Preddy,
and we're going to hear some more great stuff about Java on Azure.
How are you, sir?
I'm great.
I'm from Johannesburg,
so it's great to actually speak to the crowd around the world.
If you hear my South African accent, it is very deep
and I've got some incredible stuff to show you about Java Azure and also
the incredible developing experience that we have for the Java developer.
I love it.
I want to see some live demos.
I want to hear about the power of open source and the power of Azure today.
Okay, So the first thing I want to show you is
how easy it is to get started with, with Java in VS Code.
So I've installed Java and VS Code here
and the first thing that it does is actually brings up a help center here.
It's our new health center and it says, okay, cool, what do you want to do?
How can we help you?
But it says You want to create a new project.
Do you want to take a tour?
And then it gives you all of the nice little settings that you might stumble on.
And one of them that we're going to attempt
today is I've taken one of the projects that we have here.
So if you go down to spring since the spring Spring pet clinic sample
application, so I've set up my PC with the Microsoft OpenJDK,
you can go into that the let's go here, configure your Java runtime
and then set it up with the Microsoft Open. JDK.
Now that's our version of here
and I've downloaded the Spring pet clinic and I've done a little bit of
configuration to make it a little bit more optimized.
So the spring picnic, it's my solo application that says jazz owners,
pets and vets and you want to take your pet
to the vet so everything is running and ready.
And you see here,
I've got my project here
and I'm going to show you some stuff that you can get started with today.
Scott And it's pretty simple and that's all set up done here.
So the next thing I want to show you is the classic Java project.
Yeah, you've got your source files,
you've got your pom and everything is kind of built in.
You've got Maven here, which is how both scripts kind of like Nugget in PM.
I don't actually know if you use both, but very similar to that.
And I can right click
and I can run the project here, but I want to show you something else here
because we've built in some new screens recently.
Since Bruno spoke to you on the session, we've actually broken some screen. So.
So watch this.
I've got the spring extension and I'm going to click on the
the the actual project chart and then I'm going to go debug.
Now I set with the your,
your friend Burke and I showed him this and he went, Rory
gives us two other languages because what we're doing in here
in this project is we're actually going into all of the beans,
the objects, they're, we're interrogating them
and then we're saying to them, okay, what do you do?
How can we access you and how can we test you?
So I've got my, my, my DBA going here and look at that.
We've got all of the actual objects. Yeah.
If I'm going to own a controller
and then I've got
some great ticks here that will tell you what you're doing.
But more importantly, look at that squat.
I've actually got it done.
So you're expecting your introspect into the Running
Spring app and you've identified each ping, each bin.
You've interrogated it, you know what ports they're listening on
and then you've added a little hint above it in the
for each of those mappings for those rest API.
So a little microservices and you can only do this in Java
because at the spring actuator allows you to introspect all of those objects.
Now I can actually go in there and you can see there I've got my rest goals.
Yep, I want to show you what this app actually does.
I can just click on the API and it will open up and this is my
my picture and I can go find owners and I can just click on find owners.
And then it's about,
oh, it's going to debug, it's going to d-pad breakpoints in here
and I've got all my great ticks there or so and I can see they're there.
I'm checking whether the owner, the last name is blank
and I can go through that
and I can also go through the classic watch and debug experience.
So let's go on
to you can see that I've got all of that.
Not that these are the classic kind of dot net action going on there,
but one thing that I really wanted to show you is it's
got also some of the newer features like Hook
Code, Replace and also add your your your, your, your
and what we call it in there, your debug list debugging.
So if I click on continue here, it's going to go through here
and I can actually go in here instead of saying only last name,
I can just go on the last name.
And then if you click on Heart Code Replace, you'll see there three changes
loaded.
And now I can actually go and it says only last name.
So I'm going to go back into my Microsoft and that simple browser.
Yeah, and let's go to find owners.
We're going to find the owners there
and let me just click that at the back point over there.
But the closet's is actually being hot reloaded without me doing much.
So it's an incredible debugging experience that we have with
the ADD
the URLs, the endpoint mappings, the the bins.
But we've got a little bit more here.
What we've built into here is the ability to you look at that,
you introspect your heap memory.
You can see there, there's my,
my resources, my non heap memory,
my GC posers, garbage
collection courses and also my garbage collections.
Look at that, I'm going to optimize.
And this is built in to the Visual Studio code
extensions that you get all driven by Microsoft and also overseen by Microsoft.
But part of the open source initiative that Microsoft has on
The Voice is code extensions. Yeah.
So my my time debugging and experience
allows me to go in there to test my capabilities.
And when I'm finished with that, I can go into code spaces
with the exact same experience I'm going to drop off into here.
I'm going to just go stop there now.
I'm going to go into Microsoft Code Spaces and
you can see there my my actual edge browser
is using a different thing that I have here, but this is code spaces.
Now I want to do Docker and I want to get this on to Azure.
So how do I do this?
So I've got my on many levels that for a second I want to understand.
So before we were on localhost, yes, we were on right.
And we were doing our local development still in spring.
Now we're in a code space which is a different flavor of local host,
and then we're going to make the jump from this cloud based development environment
into Azure proper is, you know, I do it in code spaces
because this one that I'm using right now has 32
CPU's
and more memory than I've had hot meals.
And as a result, because if I run this locally on my laptop,
it's going to complain.
And over here I can get all of the benefits of running this on Docker
and see exactly how I want to run it on my Azure container.
So I've got my my actual API.
I'm using the,
the actual let's go
the supported versions of the Docker phone.
I'm exposing my port and we use 88 here, not 3000 in don't network.
I've got my app that I already got and then what I do here
is the newer features that we've added to Java
17 allows you to hyper
optimize your Java for a container.
And what do we what do we really, really want to run the Sunny's container apps.
But I want to say yes, 75 Yes, my app only give it 75% of the the memory.
Let the memory go for the other processors.
So I've got my memory here.
But my entry point now ironically I actually created that with copilots
and you can see they create a job endpoint to make them
maximum and it actually goes in and creates it for me.
So I can just go right click and on Docker.
Now this is, this is where sometimes I get a, a crowd
who are I'm about to build a docker image in code spaces
and then I'm going to go into my Docker file here
and I'm going to right click on there and I'm going to go running to Active.
So this is Doctor in darker and darker so I can actually go
and do proper testing here.
So I've got there and I can go open in browser.
Now I can actually say all the Docker files running everything is ready.
Let's just do that and let's go there.
We go to find out nicely.
Nicely done, Nicely done.
Did you just say that it was becoming dark year?
I think that's the word.
Docker. Yeah.
Now more and more Docker as we move into the cloud.
I love it. I've got 32 CPU's in memory.
Why would I not want to use Microsoft Code Spaces?
The last thing I want to do over here is I want to actually check
stop and
on my my local insincere let's go back here and and I know that Bruno
promised you play rock tests and over here I've got my player on test yet
and what this does in going to test here
and the test and player out test
is going to do my final integration test and this is going to run in our process.
It's basically going to go in, create an owner here and I can just right
click on that and it's it's running a proper Chrome browser
and it runs on the GitHub actions to say, enter in.
I want to run that test.
So you can see there, it's busy running here
and it's going to run the engine test.
There it goes. Running test. Yes.
So you're running the playwright test Headless
in a container against the Java Spring site.
Yeah.
And I can run this and Docker also, except sometimes could do this.
It doesn't like you running errant browser processes in code space.
Yes, And that's what I've kind of picked up, that everything's done.
I'm happy with my development.
I've got my my local development.
I've got my actual ad docker development so I can actually go and push this.
I'm going to push this.
And locally here I can just go, okay, cool.
Everything's right. I need to make a change here.
So and the the powers that be
can actually go in and say that, and let's just make a small little change here.
I'm going to push that there. I'm going to commit
4 seconds
and I'm going to connect and push.
When I do that, I use the app command and container,
but it's set up everything for me by going to GitHub actions.
Everything from the start has actually done even added cocoa
analysis for me here.
The only thing I did I changed.
Yeah.
Is I want to use the Microsoft OpenJDK.
Well, call me, call me.
And as spoiled for choice, I've got the Microsoft
OpenJDK a bold that's exactly like I did in my process.
I log into my container.
It went and created all of that for me.
Container container apps, GitHub actions, all of it.
Just with one command. I was blown away.
It's going to push it to the the container image.
It's going to then log into my Azure.
I do need to go in there and give it my credentials,
which are secret and you want to put that in a keyboard also.
And then I'm going to go and create my image and then update my image.
Now, when I did this initially, we did this late at
not just before and Bruno not did a lot of build there.
And the irony is it was incredibly easy to do and incredibly quick.
I want to show you here.
So he has my repo there.
Then I keep you and on my and my actions.
Yeah, you'll see that we've got our actions already.
Now, code Q I was just checking for any weirdness that is coming in here.
You can actually get it to check for injection SQL injection.
And there is my trigger that the Container app actually created.
Let's go in here.
It's building it with a Microsoft OpenJDK.
I've really tested that.
My image works locally and I'm happy with that.
It's going to build the
the local file here and then it's going to go into the deploy.
Now, the deploy is very interesting because I am deploying to Container App
now. I've set my container app to only handle one revision
because I don't want to go in there
and create a staging environment lab on here with you.
So when I do that deploy, it's going to go into
let's open up the Microsoft Azure portal
and overwrite
all the previous revision, which is fine with me.
But if I wanted to do some traffic shaping or any other services
that are related to versioning, I might actually not want to do that.
So here's my actual container API and I want to show you that
live that this is actually working here.
You'll see that when it finishes there.
So let's go to our container apps into our revision management,
and I've set it to single revision on container apps.
We're really happy with that Docker file where we set up the ports.
It'll really pick that up there and it is going to overwrite that revision there.
I've also set it to the scaling to not scale,
but to rather also give it to CPU's.
So forced to suppose and for geeks of RAM
Java's a little bit greedy, I would say when it comes to memory.
We also say that to 75 on the dock a follow there.
So the max replicas. Yeah.
And then on the actual replicas, yeah.
If you want to go through that you'll see the then I've actually said it to
let's wait there and it's going to our scale
to see somewhere there to CPU's and for gigs of Ram.
Let's go.
It's finished here.
It's finished. I've got my deploy process here.
Remember, all of this was set up with container apps.
I got my complete job deployed to my apps.
Yeah.
Now I should be able to go into what are the chances what are the chances
that this works in the first try without a net zero zero.
Rory, there's no chance this works in media,
but it makes the audience want to root for you as the underdog.
There's my app there. It's a really got.
So today's the efforts to really push the traffic and there to 100%
so I can go in there and and going to overview
now it's going to use very basic load balancing to point to that revision.
I can actually go to the revision of myself. Yeah.
Yes. My application URL and easy process.
Oh my goodness.
So it's easy to set up.
It's easy also to debug.
We've got some incredible screens there that no other language and product
actually has easy been to to migrate to
and to get drunk of power of
code spaces you can do your integration test there with play right
and then moving off to contain apps just with container apps app
you've got all of that not GitHub actions into container apps
now this this app yet it costs me about $0.03
over the period of about a year to run because I only really do it on my demos.
I spend it up and then it comes down because it's scaled to zero.
And so which is a great cheap way for me to keep my app running.
That's everything I wanted to show you today.
Coming back to our original session and John,
I got Scott Henson meant to be really impressed and surprised at the
really colorful and powerful ecosystem that Microsoft has with Java.
Absolutely brilliant. Very nicely done, sir.
You stuck the landing.
I didn't believe it was possible, but I am learning all about
Java with Azure today on Azure Friday.
Hey, thanks for watching this episode of Azure Friday.
Now I need you to like it.
Comment on it, tell your friends retweet it.
Watch more as of Friday.