[MUSIC]
>> Hello folks, welcome to today's stream.
This stream is sponsored by Microsoft Azure.
It's not going to be 100 percent pure Azure content,
but it'll be very much focused on getting
this deployed onto Azure.
Let's go create a list of to-do's here,
so deploying onto Azure.
Deploy the app itself, provision,
I don't need Postgres,
but that would make things easier.
Then basically automate deployment, CLI.
Those are my major goals and
then secondary or alternate ways of deployment.
There's all plugins and SDKs and things like that for deployment,
we're really starting from scratch here.
Let's actually create a branch.
Even though I generally don't like to create branches,
this is a special case.
Let's create a new branch. We're going to call it Azure.
We're on that branch.
Let's get this to compile at 11.
I don't think it's going to be too bad because I think most
of the problems are small.
I've got a few pattern matching places.
That's records, records, pattern matching.
Let's fix the text blocks. What do we want?
I'm really bummed that the IntelliJ
is not asking me to convert this
and say copy string literal into clipboard. Oh, let's do that.
Then what I can do is have this and then
paste it in, so that's fixed.
Let's go rebuild and see what else is broken.
Let's fix the pattern matching.
That wasn't quite what I thought it would do with cast.
Let's take this out and now we'll have to cast this,
create a local variable that should be OAuth
to user is actually that,
and that's OAuth get principal.
No, get authorities get principal, come on.
There we go and cast it, insert that,
and then we can grab this,
do that and that.
I want to convert to a class,
let's rebuild, see where we're at.
Wait seriously, that was it. We fixed it all.
Everything built, now the key is let's run all our tests.
We're going to run all the tests.
Everything works. Let's run
the application just to be sure the application works.
Sign in. That's working.
Everything is working fine. That was the fun part.
To complete this quickstart,
JDK 11, we are there now.
Sign up for Azure subscription, I got one.
Azure toolkit for IntelliJ,
I think I did that, so let's go sign in.
I don't know what it's going to do, so I'm going to go and switch
to my secret window.
Hold on. It was interesting,
it actually popped up a browser that had four options.
One was consumed the CLIs authentication,
and then when there were a couple others about device stuff,
so it actually worked with consuming
the CLI authentication, which was pretty cool.
I did that, I don't want to create a new one.
The Azure Spring Cloud is a service, so I need to create that.
That's a subscription I'll use.
I'm just going to create a new one to be called a mobreg.
This is the name of the service.
Check us I'll also call mobreg.
Here I will make it central, why not?
Pricing. Is there a cheaper tier?
No, that's the cheapest tier, charged per second.
Let's turn on the job in process agent sampling rate,
that seems fine and that's all fine.
I'd like to create. Now I can create.
The service is created.
I think the service though,
is available enough that I can go check connect to the resource.
Let's connect to the resource.
No, not SQL Server, deploy Azure Cloud.
Hey, look, mobreg service,
app, that's my app name, more settings.
Seems to me this should not be under more settings.
Java 11, so build and deploy. Oh, here it goes.
That's interesting. It's documenting this here,
or how to deploy to Spring Cloud.
This is public endpoint,
which I assume I want,
and then persistent storage,
I don't think I want that.
Artifact, I guess this is the creating the app part.
So public endpoint to enable selecting instance Cloud,
did that already, say create app.
I actually didn't have to do create app.
I guess it's then start the deployment.
Let's go run and we'll maximize this.
It's going to run all the tests.
This is most certainly going to fail when it
deploys because there's no database.
Deployment is complete. Oh,
let's actually go back and see what happened.
There are test failures.
There should not be any test failures.
Let's go disable those tests, disabled.
Then the other one is the mobtimer,
sub sender tests, it'll disable that one.
I guess we've got to try that deploy again.
We're going to create a database.
Then let's create a database.
We would like single server, version 11.
Hope that's not a problem because I'm using PostgreSQL 13.
We're going to put this under
the mobreg resource group servername,
mobreg server admin login name,
just do admin and password.
Let's review and create.
Let's go back home.
Let's go back to IntelliJ because it was
deploying, start updating deployment,
says created successfully, and looks like it threw an exception.
Great. Let me go delete.
It looks like I'm going to be creating
a new app but let me go delete the other one.
Spring Cloud app. Let's go delete you.
I'm going to go, let's see.
Create the app with public endpoint assigned,
if you selected Java version 11 when
generating, include the runtime.
This is something it failed to do.
Let's take that and then we'll do that and we'll add a space.
What's my resource group name?
I think it's mobreg. Yes, mobreg.
This case matter? Let's assume it does.
A service instance name, mobreg service.
Name of the app, so I think that's everything I need.
This command requires the extension Spring Cloud.
Think I may have mentioned I was supposed to
install that in some other place.
That's creating the app.
Basically, I want to get to the point where
it's deployed and running at least starts,
and then I want to see the failure
logs because it can't connect to the database.
Let's go ahead and take a look at here.
This is our local PostgreSQL properties.
In fact, let's go back to our list of what we're doing.
This is done, we provisioned it.
As part of that, we need to set the JDBC URL,
basic data source info URL,
username, password, so PostgreSQL.
We did the provision database,
env vars or GitHub OAuth.
We'd basically the client ID, client secret,
specifically the GitHub personal access token.
Go to migration.
That's all good for PostgreSQL.
Let's copy this over and we'll basically call it Azure.
I'll need to set the profile to be Azure.
It's going to grab these properties
for the GitHub client ID and client secret,
and then we'll need the database ones for that.
Let's put here, this is Azure and then this the URL,
which is basically that.
That's the admin username as we'll grab
that and the database password.
I really care if anybody sees it
because you can't get to the database.
It's not demo, it's mobreg,
that's fine and that's fine.
We can deploy again. Let's go do that.
What was the deploy sequence?
Now artifact, deploy mobreg,
mobreg, mobreg, artifact, artifact.
There we go. Let's see what happens.
Well, it looks like it's successfully
connected because it successfully
validated two migrations and migrated
the database. I guess it's up.
Now I will need to figure out how to do the environment variables.
Let's take a look. We'll sign in, this is good.
This is exactly what I would've expected.
I need to now authorize mobreg running on Azure.
We will authorize, I like how
I'm Ted Young and I'm authorizing Ted Young.
We're logged in and I should be able to
go to the admin dashboard, and it's all working.
Let's go create a huddle, and there it is.
Then if I go back and look at it as the member point of view,
then there it is.
We have a successful deployment and operation of the application.
Very nice.
Let's go back to the app.
There's all our traffic or 20 requests.
Of course, if there's much the application map.
There we go. Well, that's cool.
It made 310 calls to the SQL database,
that I can view the details, that's cool.
Get paid 10 calls to apigithub.com.
Yeah, so this application insights is
really cool. Thanks, everyone.
I appreciate you hanging out,
going along for the ride.
Have a great rest of your day and I will see you next time.