[MUSIC]
>> All right, shall we get started for today?
I'm pretty excited to see what happens
with the Azure App Service.
Because Azure's App Service should be really cool
and you can host all sorts of different web apps on there
and it's very, very, super scalable.
It'll be really cool.
To anybody that isn't too familiar with coding or anything,
this is what the Azure App Service does.
It basically means that you can put a website
that requires processing and computing stuff on the backend.
That means things like databases, things like APIs.
That kind of stuff
you can't just put up as a static webpage.
But the App Service, what this does is, for APIs,
all the different websites that have
shopping carts for instance,
or things that have moving pieces
that server needs to track.
All of that stuff requires another server
that processes and crunches those numbers
and remembers those things.
And that you can host.
And so generally you need a server to host it,
but with Azure App Service
you can have up to 10 of them for free and try it out.
Is there a good place to understand
all the different things available in Azure?
Yeah, I think it's azure.microsoft.com.
Here it is.
So Azure has a bunch of different things.
They go from everything from AI driven services,
to hosting, to processing, to storage.
And so they're more like different categories
and they're all under the same name as Microsoft Azure
because it basically has to do with the cloud.
Let's see.
We have an Azure account so it should be pretty easy.
You can just sign into Azure through Visual Studio Code
and that uses the Azure App Service extension.
Let me see if I can get it up and running.
Ah, ah!
It's running.
Can I do, can I close this workspace?
I guess we might work with Visual Studio Code today.
All right, let's try this.
We can sign in.
I'm gonna go through this real quick.
So then we can know exactly how this works.
Okay, we got it all set up.
And so now I think we're ready.
If you don't have an Azure, sign up today.
And we did that already.
We need Visual Studio Code along with Node JS and npm.
We have that.
And you need the Azure Apps Service.
We got all of the extensions installed
except for the Azure App Service.
This is the one that we needed.
All right, let's install it.
We got this.
And then now we have to sign in.
Sign into Azure.
Ohh.
You are signed in.
Now you can close this page.
Okay, it worked.
Prerequisite check.
Ensure you have all the prerequisites
installed and configured.
So we did that.
You should see the Azure email address in the status bar
and your subscription in the Azure App Service explorer.
Let's try this.
All right, here we go.
In the VS Code, now you see your Azure email address.
I see it.
Azure email address, way on the bottom.
Ka-bam
It's got all the things and your subscription.
Now we gotta create our Node application.
Let's do this.
Next, create a Node js application
that can be deployed to the cloud.
Quick start uses an application generator
to quickly scaffold out the application from a terminal.
Let's do it.
What are we going to build?
I guess we can build whatever we want.
We should build a Merry Christmas website or something.
That would be cool, right?
Let's create a repository.
What should we create today?
We need any sort of App Service idea that we want.
What if we had a squirrel counting API
and put it on App Service?
Why don't we do that?
What if we do something pretty useful?
Like just simple but useful.
Like...
Let's do it.
Let's call it counting squirrels.
And then every time you ping,
we'll make a service where you can
create any sort of named counter you want
and then you just count it up, and up, and up.
I think that will be great.
It'll be fantastic.
So we can bet on things like how many squirrels you'll have.
'Cause then we can also make a webpage out of it
and make it real easy.
And so let's try it.
Gitignore template will be node
and the license, we'll say it's an MIT license.
A counting API to test
Azure App Service with NodeJS.
Hi yah!
Once we get it working, then we can do anything we want.
All right, so now that we have this, here's what we'll do.
We go to counting squirrels, found it.
And then open in command prompt.
Ka-pa-ba-boom.
Here we go.
Initialize it, and be a minute.
Version one, A squirrel counting service.
We'll say, count, squirrel, Instafluff,
so many squirrels.
We're going to install Webwebweb instead of Express
because it's super simple.
Scaffold a new application with the Express generator
and run the application.
So we're going to create one.
So let's see, can we do this?
Ohh!
Ba, ba, ba.
It worked.
So then I'll need this.
'Cause I actually just opened it directly in here.
Wow.
New package without a thousands dependencies.
Can you believe it, can you believe it?
Well, now that we installed.
So we can do MPM install directly in here.
This is a seamless, this is so great.
All right, we're going to create const Web, webwebweb.
Web step.
We run this and then we'll say Web.APIs.
We're gonna say, squirrel.
I'm gonna save this as index.js.
And now it's got glowy code.
That's it.
Now it should be running already,
which means local hosts:3000.
Oh look, it worked.
Would you look at that?
A hundred.
That's all we have to do.
We have a Node JS API app.
Holy moly.
So now we can deploy to Azure.
You choose a directory and create new web app.
Okay, let's try this.
Ba ba.
Uh oh.
Oh no.
I put it onto the wrong monitor, y'all.
So now we go here.
I think that's it.
It opened in a completely different tab than I expected.
Oh, here we go.
It's at countingsquirrels.azurewebsite.net.
Now every time we refresh,
it's like everyone is adding to the squirrel count.
We've got to get to a thousand, right?
Gotta get to a thousand.
We're over a thousand.
Wow! [laughs]
This is how you can create a counter
on an Azure web service..
How many lines of code is this?
It's nine lines of code.
Look at that.
Okay, I have an idea.
It should work.
I can bring up the console log in here, right?
So I can do npm.
There's ComfyJS.
And so now we do ComfyJS.onChat.
Two squirrels, it's working.
It's connected to chat.
Which means we should be able to go to chat.
There's been six chat messages since this has deployed.
Everyone put in your favorite emotes.
We'll see a count it count up.
Seven messages, aw snap.
10 messages, 11 messages.
This is gonna be cool.
I can't believe it works.
This is really cool.
This is all we have to do.
Like 21 lines of code.
Now we can count the number of squirrels and chat messages.
All right, I think the next thing we gotta do,
we gotta save these out to a file next.
So then we'll actually be able to load the count
and then increment it and then save it back.
Right now we don't store anything.
We just store it in memory.
We just have chat counts and squirrel count.
Well we'll do this.
We'll do fs equals require fs, that's file service.
We wanna readFileSync.
And then we'll be like, okay, we parsed everything.
Now you can see what it looks like.
We can put chat counts in there.
We could even put a command that just says
save this count and then do it.
Let's do it.
I like it, save the squirrels.
And then we'll be like, fs writeFileSync
It'll be super simple.
Just like that.
So now it is working.
I think it's working.
We'll store a counter for each command.
We'll be like, all right, commands.
If counts, oh it's working.
Reported a critical error.
I think it just took a long time.
It looks like it's saved it.
There's no errors or anything.
It's working.
It just took a little bit of time to deploy.
But now it's working.
Oh, I wonder, let's see.
We'll store a counter for each command.
If counts.
If we don't have command.
Commands...
We do that here and then we're like, ba ba.
We have to deploy one more time.
Dang, we're deploying all things.
So then we could even see how many times
people have done exclamation point drop and stuff too.
This is really cool.
Okay, I'm going to have to use this for everything.
I want to do one last thing with this,
which is I want to see if we can put a webpage.
'Cause we got the App Service
and we know, and we created APIs for it.
If we can create an entire web service for it
then it's gonna be even better.
So let's do a bootstrap page.
Oh, I need coffee.
It's all we have to do.
Squirrel count.
Wow wa!
H1.
All right, let's see if we can finish this.
So I guess we'll just be like, p json-count.
Here we go, this is what it's gonna look like.
Yeah.
It's going to be a webpage.
Waa, it's gigantic. [laughing]
But now check it out.
We got the chat counts and everything.
Counts.
All right, let's see.
This should work.
It worked.
This is a webpage that calls the API
and then says chat has 44 chats,
and one squirrel, and commands.
And it's got all the different commands.
And so, wow!
And so now we're going to Azure.
We're going to deploy this.
Deploy!
We've got an entire web app
that counts squirrels in our channel.
Now we have a webpage for it and everything.
But you can see the counts and the APIs are here.
Think it's working.
We did get something working today.
We did, we got a bunch of stuff working.
Look at this.
I can't believe the Azure App Service
works like this so well.
Thank you again so much, everyone.
We'll see you next time.
Stay fluffy, stay comfy.
Thank you all so much.
Bye!