>> There are several ways a Go Developer
can run apps in the Cloud.
Azure provides multiple compute
services to choose from to meet
your apps needs including Web apps and Kubernetes.
Josh Gavant is here to show us how to choose
which one to use today on Azure Friday.
Well, everybody welcome to Azure Friday.
I'm Erik Saint-Martin and today
we have Josh Gavant here with us to
talk about all the various ways that you can
run your Go applications inside the Cloud.
>> Yeah. Thanks Eric.
Great to be here. This is quite an interesting topic.
There are so many different ways
people can run apps in the Cloud,
and sometimes it's a little confusing
what's the best for you,
or maybe you know what's best for you but you need to
know what to choose
from the Cloud that you're running on,
like what fits with what you need.
>> There's a bit of analysis paralysis
there like which is the best way to go?
>> Yeah. There's so many terms like Kubernetes,
and then you've got passes and you've got server lists.
So, what one should you use for what?
What do we have in Azure
that meets those characteristics and things?
So, that's what I wanted to talk about today,
the options we have and
I'm going to demonstrate one of them.
So, I wanted to start with this diagram,
this kind of a concentric circles
where to kind of orient around what we're talking about.
At the very center,
the smallest kind of thing you might have
is a function or server list,
which is basically a snippet.
>> For some small unit of work,
that's something really really.
>> Yeah. I think so most of the time,
and you don't want to have to put up a whole app around,
you don't necessarily want an OS and have to worry about
configuring the entire process of running that function.
So, that's a nice function takes care
of that for you, and then on the other end,
you have a Kubernetes cluster
where you've got multiple containers,
maybe in several pods
interacting to provide a cohesive service.
Then somewhere in between, you have what we call app
service which runs web apps.
It can run them from source say,
that's kind of what I'm representing
with that green circle here.
If you've just got a service
running straight from source,
you can bundle it up into
a container that kind of
lets you define the build process a little more,
define OS level dependencies and
still run it in that same thing.
Then actually
beyond that, let's say you're getting ready,
you're thinking about maybe you
have several containers working
together or several candidates
for Kubernetes pods working together,
then you might consider graduating up
to Azure Container Instances or Azure Kubernetes Service.
Yeah. So, I wanted to focus on the,
I'll skip the screen for a moment,
we'll leave that in the background.
Keep us oriented.
So, you might not even know this,
but Azure has a couple of
services that I wanted to talk about,
the Web App service
and then the Azure Container Registry.
At first, it might not like what's
that have to do with how you run your apps,
but the nice thing is that Azure Container Registry
actually is also a container builder.
It has something called build tasks
which there's a couple of things they can list on,
they can list on for a git commit to like
a GitHub report and then rebuild
your container right away.
They can even list them for changes,
for the layers of the container,
if the OS image that they're depending on changes,
they can actually get notified and
update that and rebuild for you too.
>> So, this is a-
>> Pretty cool stuff.
>> So, instead of just pushing your image
that you built locally up to ACR,
you also have the ability to just push
your change docker file or something to
GitHub and then ACR builds it
and also stores it the same way a registry would.
>> Yeah, exactly.
So, this is kind of our most supported story
for Go apps right now.
I've talked to a lot of customers and some are like,
"Oh yeah, I start with a docker file and every repo."
But some are like, "Why should I involve docker?"
So, at least with this,
these are our most important [inaudible] at least for these,
you just need the docker file you put it up there
once then you focus on your code thenceforth.
We are looking into for the future building
straight from source into
web apps so you don't have to
worry about a container at all.
But right now yes you put
your docker file up there and then the rest is history.
So, I just want to,
let's see, let's open this read-only is fine.
What I want to show you also a
little bit about Azure CLI here.
I'm going to show you the four or five resources
we have to create to kind of set up our build pipeline
and then we're going to go ahead and just run
it and we'll make a change and then
we'll see it pick up that change
and reflect it right away.
>> Awesome.
>> So, yes let me show you the Go app.
It's pretty straightforward.
I've added some stuff to look for
the port environment variable because I know app service
looks for it but then basically I'm
just listening for a request and then returning hello.
>> Pretty straightforward.
>> The script let's just say open read only.
I must have it open somewhere else or a swap file open.
So, I'm not going to focus
on all of the script but I just want to show
a few salient points
and the CLI really can do all of the stuff for you.
Somebody's got to figure out exactly how to make it
work but it can do a lot of cool stuff for you.
So, first I check to make
sure that I have a registry available.
The best way to do that,
if you need to create one is az acr create.
I'd make sure that I get out
the credentials and things that I'm going to need later
on so that I can configure the registry to talk to
web apps and yeah talk to web apps actually.
The next thing I have to do is create an app service plan
which I do with az appservice plan create.
A plan and an app service kind of
lets you run multiple web apps or
multiple function apps all under the same umbrella.
Kind of similar to a resource group at the Azure level.
>> Okay. So, it's more of a grouping
than like a pipeline or something.
It's just kind of like a namespace.
>> Yeah although I think some features might be set at
the plan level I think.
So, after we have a plan, then we can go ahead and create
a web app which here on line 116 is az webapp create.
If you are creating a function app it will
be az functionapp create.
You'll notice that I pointed out
the container image that I wanted to
load and then that's actually the next line here.
I tell it where to look for
the container that I'm going to have
continuously deploying from
the container registry into appservice.
Then finally I'll show you a couple of things actually.
So, I have a couple of things.
One of them is az acr build and that's
another interest and you could do docker build and,
sorry, az acr build is
the equivalent of docker build but in the Cloud.
So that's one way to run a one off
task and then you can do
az acr build-task create
and that actually allows you to specify.
You'll notice here on line 177 commit-trigger-enabled.
>> Okay and that's what tells
it just to monitor GitHub and
basically trigger a new equivalent
of the acr build every time az is in your command.
>> Yeah exactly.
So, let's and I think that
is it and then I curl at the bottom.
So, now if I would run
setup.sh it would deploy all those resources for me,
set up the container build.
I've actually done that all luckily.
So, let's just look at the result.
So, we're opening up the portal.
I'll show you how it looks in the portal.
Let's find the group we created.
So, this one is the one that's
in build right now I believe.
Yes. You see it's currently
building up my sample registry.
But here's what I built earlier, go-tester2-group.
So, resource groups are also kind of a container raising
mechanism not that kind of
container in Azure to kind of group resources together.
You can grant authorization rights
based on a resource group,
you can manage them more cohesively.
So I put all these things into one resource group.
You see I've got my registry there,
tells me all kinds of things that I'm doing.
I can look at the repositories,
you'll see the the one that I just push is here.
I'm actually not sure if build tasks are
listed in the portal.
You might have to go through the CLI to see all that.
Then I have my webapp which had spun
up and I should be
able to hopefully go here and it says hello blank.
We know that if we add in
name equals let's say hi to you I
always say hi to myself Hello Erik.
So the basics work.
If I wanted to now let's go over
here to create a new window and cd back into that repo.
Joshgav go-sample and I
wanted to make a change to that code,
so let's just go into main.go.
This is a little frisky because it
definitely takes a minute or two.
I made a change
and we should be able to let's check on
our- I'm going to change and setup.
Well okay. Just that one.
I'm just going to change that one file so
git add main.go and git
commit here's a change and git push.
Oh, looks like my token has expired.
That's not so good.
>> Demos.
>> Yes. I know what I can do.
Just give me once.
I'll change the token right away after.
How about we do it that way. So, to get a new token.
Settings, GitHub, settings, tokens.
Okay. Let's go ahead and generate a new one.
"Regenerate", copy,
please do your best not to look but I'm
going to change it and then.
>> Everybody else gets to deploy out to your builder.
>> Git push, what happened there.
Git push. Yeah exactly what I was going to do.
Okay cool. So, I pushed it out there.
It only takes a couple of seconds to run.
But now it should be.
We should be able to see that in a second.
A couple of other interesting things now though we
have our container registry here.
You'll notice I'll just
jump in there back to that image real quick.
If I go to the repos.
I think it's here,
"Run Instance", deploy to web app.
There are some things here that can.
Actually, this is probably the most interesting one.
Now, that I'm in the container registry it's
just one small step to start
using ACI instead of web apps.
Of course I might need to change
the architecture of my app a little
especially making sure that it's
totally not stateless something.
But it's- we've actually consider
that like hey container registry
is good for deploying to web apps.
It's also good for deploying to ACI.
>> What can you say are
the disadvantages for using something
like web apps versus ACI?
>> There's a lot of extra value there
like there's authentication services
that they'll run in front of it for you.
They automatically track some HTTP requests
and things and some performance monitoring.
They can scale.
They can automatically can
sort of scaling rules for you that
you scale out as long as you
architect this the right way.
There's also- that's where.
So a couple of benefits of
web apps that we're not totally able to
realize in Go yet is these inner two things.
Sorry it looks small. These inner two.
So the function which is pure source
and then the app without a container,
the service without a container which
is also pure source.
Those things are coming soon.
We actually have them in private internal preview
right now but if people are interested they
should reach out to us and
we definitely would like some feedback on the way
we're doing those inner less- no container involved.
>> Excellent.
>> Yeah. So yes you've got a range of compute services on
Azure all the way down from functions and
snippets all the way up to
Kubernetes and apps and clusters.
You can choose the right ones and we'll help
you run your apps.
>> Thanks so much I mean this is great.
I mean I didn't even realize
that ACR had builders built into it.
>> Yeah. Oh actually.
Speaking of which, let's see if
our app has been updated. Ah cool.
So, it's working now. I lost your name but there we are,
name equals Erik and our change came through.
I'm really happy that that actually worked.
>> That's awesome. Well, thanks
so much for joining us Josh.
So, today on Azure Friday we were learning about
all the various ways that Go developers
can run their applications in the Cloud.