>> Buffalo is one of the most popular frameworks
to build web apps with Go.
But did you know there's a plug in to
deploy to Azure easily,
and even generate code that will
integrate well with Azure services?
Well, Martin Strobel is going to show us how to build
a Go application with Buffalo and
deploy it to Azure App Service,
today, on Azure Friday.
Welcome to Azure Friday.
I'm Erik St Martin and with me today
is Martin Strobel to talk about Go Buffalo,
and how we can deploy it straight to Azure.
>> Hi, yeah, that's right.
Yeah. As you were saying, that
the Buffalo framework is one of
the most popular ways of getting
a web app started and going quickly in Go.
So, I've been using it for a little while,
making sure that all
of my services can get off the ground,
I can deliver them as quickly as I can.
But, well, it was really easy to get a container,
using a Buffalo app, because it gives
you a Dockerfile or that kind of thing.
I noticed that there were still all of
this work that I had to go to do to
configure the infrastructure in Azure,
to make it so that I could
run that containerized application well.
That just seemed wrong to me.
I felt like this is all boilerplate stuff,
there really out of your way, to just go,
do it, get it done, fast,
try to get as few commands between
somebody and their application running in the cloud.
So, we gave it a shot.
So, if anybody's used Buffalo before,
they might be familiar with this default application.
I can run it here on my local machine.
It's just starts up a background task.
I can come over to a browser, pop it open.
Look, here we go.
Basic Buffalo application.
I've already set up my databases,
so that there's an instance running
on PostgreSQL here on my local machine in Docker.
>> Okay.
>> But, now, I need
to get it into
a position where I can run it in the cloud.
>> We've got to do it live.
>> We've got to do it live, that's right.
I want to have it in the cloud.
My mom keeps telling me that things
are in the cloud, I want to get it out there.
So, there's this handy-dandy plugin
that's available to you now,
under the Buffalo Azure subcommands, called Provision.
If we give it the dash x flag,
it doesn't actually do the point yet.
It just goes and modifies our project,
so that it has the portion
needed so that my plugin
knows how to do the deployment later.
I'll get it. We give it a name.
>> This is similar to like in it
or something I can muster commands.
>> Yeah. That's right. So, instead of doing a Buffalo
in it or a DEP in it or something like that.
This one is specifically.
I intend on putting
this particular application into Azure,
Go initialise that. We give it a name.
So, in this case,
we call it Azure Friday one.
We're off to the races. It did that pretty quick.
All it did was go and hit the wire
to pull down an arm template so that it
knows what infrastructure to go actually deploy in Azure,
and then added the parameters that I had provided here,
and the ones that either detected by going and looking
at the Buffalo project into a file.
So, if we pop open as we
deployed our parameters to our JSON. Take a look.
You can start seeing some of
the particular details that we plugged in
about our project, Azure Friday one.
>> So, it recognize that now we're
using PostgreSQL as the database,
and database name got pulled out. Things like that.
>> That's right. It was, as you were saying,
it's just going and reading the
database,.yml file that was
already part of our Buffalo project.
I did have to go make one tweak to it and replace
the default to context that
Buffalo shoved in there with something that said,
go look for my particular environment variable,
that's where I'm going to want it.
From there, I guess,
it's a good point to say.
Well, what if we wanted to inject
some cloud services that we wanted to use?
So, in addition to just deploying to Azure,
we can actually take this plug in and extend it out,
so that we can take advantage of Event Grid.
A Event Grid is a messaging solution,
that's each to be based inside of Azure,
so that you can get
PUB/SUB mini text between your services.
So, if you do a Buffalo generate.
>> So, in this case, what you wanted
to do is provision this in
addition to the things that it can auto detect.
>> That's right. So, you
would probably want to add into your Arm Template,
it then Grid the topic.
But there's also some code that you want to inject into
your application to actually handle
the events when Event Grid calls you,
because we're going to be adding
a subscriber portion into our Buffalo application.
So, if we say buffalo generate eventgrid,
we're going to call it Ingress,
because that's what we're going to be
being made aware of.
Microsoft.Storage.BlobCreated events by Event Grid.
So, with this one commands,
Buffalo goes and modifies our application to
have added a new path inside of the application,
so that we have a new endpoint expose
that will be able to be called
by Event Grid and handle events that are passed to it.
We also have a file called ingress.go generated for us.
That will go actually,
let the application know that,
when it sees a Microsoft.Storage.BlobCreated event,
it should go and it should use
the statically typed call to serialize that for you.
So, really if you just.
>> Now, this was generated by the plugin itself.
>> Yeah. That's right. So, with one commands,
all of a sudden you've got
stubs that you can go and implement.
Let's say, "Hey, want a new blob
that's created in Azure?Let me know about it."
Then go call this method.
It does all the routing for you.
Just makes everything work.
>> That's awesome.
>> Yeah. Let's see.
So, we were looking at generating that,
and if we want to see it running locally,
we can do another Buffalo Dev.
See those endpoints added into our application.
Just lit up. Now, it is time to get into the cloud.
So, if we take that Buffalo Azure Provision command
from early on before where we give it a dash x
to say don't actually go do it yet.
Now, we're going to really do it.
But we don't need to give
it a name or anything because it cached those parameters,
we'll use all of the same settings that we used before,
so that we have a deploying model
that's configurable and reproducible.
All the good quality stuff that you want to service.
So, this will take off.
It's going to go, make a new Arm Template in Azure.
This takes a few minutes. We don't want to wait for that.
>> We're in a hurry.
>> That's right. So, I have
the same application over here called Azure Friday 2.
It's very similar.
It didn't have the Event Grid stuff added into it.
But other than that, if we take a look,
it has all of the same stuff
we added in azuredeployedljson,
and a new database configuration.
Here we ran that Buffalo Azure Provision
and we waited for it to finish.
If we come over to a browser,
where I already have it typed in,
and we do a refresh.
You'll see we have a Website called Azure Friday 2,
running our containerised version,
running in the Cloud,
connect talking to our PostgreSQL database.
>> All of this, you were able to do straight from
the Buffalo command line without actually having to
go into that easy SLI
or into the portal or anything like that?
>> That's right. Didn't have to touch it.
>> Now, that's a spam.
>> Yeah. I'm really excited about.
I know it's made it so that when I time myself,
I can get a website without a database,
from no new directory,
to running in the cloud in about four minutes.
So, it really, I mean, it's I could do split.
>> Three would be better.
>> Three would be better. I'll work on it.
Bring me back next year, Illl have an update.
>> Well, thanks so much for coming on.
>> Yeah. Thank you. Today we were learning all about
the Azure plugin for Go Buffalo here on Azure Friday.
Không có nhận xét nào:
Đăng nhận xét