>> As Abel would say, you will not believe how ridiculously
easy it is to create a CI/CD pipeline
for your application in Azure.
Abel Wang is here to show us how to
implement pipelines for Azure functions,
App Service, and even Azure Kubernetes Service,
today on Azure Friday.
[MUSIC]
>> Hey, everyone. Donovan Brown here with
another episode of Azure Friday. I'm here with Abel.
He's going to show us how to create
CI/CD pipelines for our applications deployed into Azure.
So what if you're new to CI/CD, we're not,
we looked DevOps, but we have a lot of our customers who
are interested in getting started. How do they do that?
>> Let me show you how.
The whole goal with Azure Pipelines is we want to make this,
as I always say, ridiculously easy.
But this isn't just hyperbole.
Let me show you exactly how easy it is.
>> All right. Cool.
>> So what we're first going to do is we're going
to take an Azure function, a serverless app,
and we're going to go ahead and it's already deployed,
and what we're going to create a
CI/CD Pipeline completely from scratch.
>> All right. Great.
>> So here is my Azure function.
It's just a URL shortener,
and I have my staging environment,
and I also have my production environment.
Now, this shortener, it takes a bunch of parameters like my event,
my channel, my alias,
and original URL, and then when you run it,
it goes ahead and shortens the URL for us.
So if we go ahead and try to run it,
it returns back and hooray for that,
we have a shortened URL right?
Now, the code I have it in a Git Repo on Azure Repos,
and now we're going to go ahead and take
this and build our CI/CD Pipeline.
>> Okay.
>> Right. It's actually really simple to do.
We can start from nothing,
and let's create a brand new pipeline.
So I'll go ahead and create a brand new pipeline.
What we're going to do is we're going to
use the classic editor because
it's easier to see exactly the steps that I'm going to do.
>> In the classic editor versus the YAML editor, right?
>> Correct, right.
>> Then you can also go from
the graphical user interface that you're about to show
us to YAML if you should choose to later?
>> Yes, and I'll show you how to do that as well.
>> Perfect.
>> So the first thing we're going
to choose is we're going to go ahead
and choose the Repo that we're going to grab the code from.
Next, we can go ahead and
actually use the template because remember,
this is an Azure function.
So let's go ahead and scroll down this list,
and we'll see, "Deploy an Azure function."
We're actually build an Azure function.
So we'll go ahead and click "Apply".
Now, what you see is it blows out and
creates for us this build pipeline.
Where it does the NuGet restores,
it builds our solution,
and literally there's not a whole lot that we have to change.
Now, the only thing I'm going to change is
I'm going to go ahead and use my own private agent.
>> Got it.
>> All right. So let's go ahead and save this and queue it up.
>> Yeah, I noticed when you brought down the agent pool,
you chose your private one,
but there's tons of them in there.
There's hosted ones in there that allow our customers
to have instant access to Mac, Windows, and Linux,
but I'm like you, I love my own private agents because they're
fast and I can put
bleeding edge bits on them and things like that.
But very cool. Great. So our build is off and running,
and this is the CI of the CI/CD portion.
>> Correct. So just in case you didn't know,
let's go ahead and take a look at this build again.
The way the build pipelines work,
basically, it's a task run.
It does one task after another after another.
What you do, you can customize this to make it do
whatever you need to just by adding and removing tasks.
Now, out of the box,
we give you hundreds of tasks
for any language targeting any platform.
>> Absolutely.
>> You can just use them. If you
want to do something that doesn't come out of the box,
go ahead and look in our Marketplace.
Our Marketplace, we have now over 1,000 build and
release tasks that our partners have
created that you can just download and start using.
>> The last time I was there is over 1,300.
Every time you go, there's a higher number, that's unbelievable.
>> Yeah. If you want to do
something that doesn't exist in the Marketplace,
you can create your own custom tasks super easy as well.
>> The way I learned to do mine
is because all the ones that come out of the box are
actually developed in an open source project
in GitHub and I just cloned it,
learned how they work, and then wrote my own. Very cool.
>> That's exactly what I did as well,
and there's plenty of blog posts that show you
exactly how to write your own custom tacitly.
>> Absolutely.
>> All right. So let's go ahead and jump back to
the build and it should be relatively done,
and it actually it is all the way done.
So if we go ahead, we can look and see you in the summary.
That's going to show a summary of everything that's happened,
including we can go ahead and see what's actually in the drop,
which should be a zip file.
Let's go ahead and pop this open.
So this is a zip file if my function.
So this zip file is now ready to be deployed.
>> Got it.
>> So at this moment, I don't have a deployment pipeline.
So let's go ahead and create one.
We'll just go to Releases and let me click on that.
From here, it's going to take us to
the visual editor for your release pipeline.
>> Got it.
>> So the first thing we're going to do is once again select
a template and we're deploying into an Azure function.
So if we scroll down the list,
here is a template that we can just start using.
So we'll go ahead and click on "Apply".
The way that you configure your release pipelines,
first you have to configure what stages you're going to have.
So I have a staging environment,
and I also have my production environment.
So I'm going to call my first stage, Staging.
Once, after you do that,
you can go into the actual stage and now you can configure
all the tasks that are going to run to
deploy your application to that particular stage.
Now remember, we used a template,
so everything is almost ready for us.
So the first thing I'm going to do is I'm going to go ahead
and select my subscription.
After I select my subscription,
I do need to choose the correct function that I'm deploying to.
So this is going to be my shortener for staging.
So I'll go ahead and select that.
Let's go ahead and use my agent again.
Well, we could use the Hosted Agents.
>> Sure.
>> My agent is so freaking fast.
>> Like you, I use private ones too.
>> Notice that's all I did.
So we can go ahead and save this and queue it on up.
So let's go ahead and look at our pipeline.
But before I queue it up,
there's some things I probably should do.
Because we also have a production environment.
>> Correct.
>> So let's go ahead and we'll clone this environment,
and we'll call this environment Prod.
I do need to change a little bit because
instead of deploying the staging,
I do want to deploy this to my production environment.
>> Got it.
>> Some other things that you can do is after
you define your stages,
you can define approvers before and after each environment.
So let's go ahead and add an approver here,
and we'll do a post-deployment approver,
and I'll say this is me, to make it easy.
>> This is going to fire
after it successfully deployed the staging,
basically asking your permission,
should I go continue into the production environment?
>> Correct.
>> Exactly.
>> I'm going to add a pre-deployment approver
before I drop my code into production,
just as somebody can approve it before it actually just happens.
>> Absolutely.
>> So you just give us a little bit more control.
So let's go ahead and scroll down,
and we'll go to our pre-deployment approvers,
and I'm going to add myself here.
That is literally all you need to do.
Let's go ahead and save this,
and we'll queue one up, and see what happens.
So we'll go ahead and create a release.
Click on "Create". So what it's going to do
now is it's going to grab the latest build.
Now it's going to start to release
my code first into my staging environment,
and if everything looks good,
then we can improve it,
and then it'll go into the production environment.
>> Got it. Yeah, it takes the zip file that was produced
by your build and downloads it,
and then uses that as
the artifacts deploy into production for you.
>> Yeah.
>> Or into each environment, not necessarily production,
but into staging, and then after staging into production.
>> Correct.
>> Got it.
>> Correct. So if you notice
the Visual Editor for each individual stage,
it looks shockingly like the build, right?
>> Sure.
>> Because it's literally the same agent.
>> Same engine. It has the same engine.
>> Exactly.
>> So the same rules apply.
Basically, if you want to customize it,
you just need to add or remove tasks.
>> Okay.
>> Once again, hundreds of tasks out the box.
You've got the marketplace with thousands,
not thousands, but over a thousand tasks.
>> Right.
>> You can write your own custom task.
>> Absolutely. Anything that you can do from a command line,
there's already a task to do that.
Anything that you want to do from a REST API,
there's a task to actually do that as well.
So pretty much if you can dream it,
chances are you can automate it.
>> Yes, exactly.
>> Cool.
>> So notice, we just deployed our code all the
way out into our staging environment.
>> Yeah, for sure. So if we want to,
we can go back to our pipeline,
and we can see now it's waiting for a post-deployment approval.
So we can look at it, and say.
"You know what? We did deploy. It looks great.
Let's go ahead and approve this."
Now, once I approve it it will go ahead
and flow into the production environment.
So let's approve this. You'll see
that it's now going to go ahead and flow into the production.
But instead of just code blasting in there,
remember I added a pre-deployment approval?
>> Yeah.
>> So now we can approve this.
I can immediately click "Approve" and bits will just start moving.
I can also defer my deployments as well.
So this is a cool feature.
>> Right.
>> Where I can schedule. I can say, "Yes,
I do want to deploy this,
but let's wait until 2:00 in
the morning when nobody's on the system.
>> Sure.
>> So you can schedule when you want it.
But for this demo, we'll just go ahead and click "Approve".
Now, bits start flowing all the way into production.
>> Just to be clear, you put yourself as the approver there,
but it could have been other people.
It could have been groups inside of your Azure Active Directory,
and with release gates, could even be third party systems
that actually act as approvers on either of those points.
>> Yeah. You can add automated approval
using AI and things like that,
approve from one environment to the next.
>> Awesome. So this looks really easy,
but I have to imagine that what
if I don't want to go inside Azure DevOps?
Is there a way that I can have a lot
of this stuff just setup for me?
>> Oh, absolutely. Right. So one of the things I wanted to do
was show you how you can build a CI/CD pipelines for app services.
We could build it manually just like this.
If you do that, you'll see there are templates
that can do all the [inaudible] for you as well.
But I've got a confession to make.
I know I'm a DevOps practitioner.
I'm not the biggest fan of building
out my CI/CD pipeline by hand, right?
So you can use different tools that will help you scaffold.
One of my favorites is an open source project called Yo Team.
>> Yeah, I think I wrote that actually.
>> You did, but it is it is open source.
>> It is open source.
>> But that is, it's one of my favorite tools.
>> It'd better be.
>> It really is one of my favorite tools
to use where from the command line,
you can just say "Yo team",
and choose an app service,
and it will scaffold everything out for you,
including a sample app that you could just start using.
>> Right.
>> So super powerful, super easy to use.
>> Right, and I know I wrote that a while ago,
but I know now that there's actually a way to do
some of that inside of the Azure portal as well.
So can you show us how that works too?
>> Yeah. In fact, you know what?
Why don't I show you how you can use that from
the portal to scaffold your product out into a Kubernetes cluster.
>> Awesome.
>> Because that's like the cool thing.
>> Yes. It's a hot topic right now.
>> All right. So let's go ahead and jump into,
from the portal, we're going to go ahead and create a resource.
The resource that we're going to create
is called an Azure DevOps project.
So here it is, a DevOps project.
We'll go ahead and create that. So let me click on it.
And the first thing that it's going to do is it's going to ask you
what language do you want to create this from.
Now remember I have nothing in place right now.
>> Right.
>> I don't have anything in Azure.
I don't have anything in Azure DevOps.
We're starting from scratch.
You always say, literally say,
any language, any platform, all the time.
This right here approves it.
Look at all these different languages that we support.
With more languages to come down the pipe.
>> Yes. Every time I look at this screen,
there's a different language on there than the last time.
>> So for this example, let's go ahead and
choose "Node" because why not?
>> Yeah.
>> We click on "Next". Now it's
going to ask us- oops, I went too fast.
It's going to ask us what type of framework do you want to use.
We're going to use a simple Node app.
>> Okay.
>> Now it's going to ask us what
infrastructure in Azure do you want to use.
So we want to deploy into a Kubernetes cluster,
so we're going to use AKS.
Now it's going to ask you what instance of
Azure DevOps do you want to create your pipelines in.
>> Correct.
>> So let's go ahead and choose my demo account.
I have way too many accounts.
>> [inaudible] enable starts there. A lot of organizations.
>> I'll update A, B, C, D, E. You know what?
We'll call this "ServerlessAzureFridayDemos".
We'll call this "My Cluster".
Well it's too long. That's good enough.
We'll go ahead and click on "Done".
That is literally all we need to do.
>> Right. Because it goes off and does
the AKS provisioning for you,
the setting up of the pipeline,
and the deployment of the sample app into that cluster.
>> Yeah. It does all of that for you.
It takes a little bit of time
because you're doing quite a bit, right?
Including provisioning. But when you're done,
you get left the portal that looks like this, right?
>> Got it.
>> So on the left-hand side,
that's your CI/CD pipeline,
and all of these links are deep links into Azure DevOps,
into that actual resource.
So it's super easy to navigate.
O the right-hand side, these are all the stuff
that you provisioned out in Azure.
>> Correct.
>> So here's your Kubernetes cluster,
there is your Application Insights
for that cluster, and things like that as well.
>> Perfect.
>> Now, just to show you what's actually going on.
We'll go ahead and click into one
of these deep links into the repo.
So we create for you a sample app in the language that you picked.
So here's my Node.js application,
and it also has all of my ARM templates.
>> Perfect. So you're using infrastructure as
code which is another DevOps best practice.
>> Yes.
>> So provisioning that infrastructure is something
that we can actually see how it was done.
You don't have to go in the portal setting that stuff up.
>> Exactly.
>> Perfect.
>> The next thing that we do is we create for you
a CI/CD pipeline that makes
sense for the technology that you actually picked,
which is Node.js app into a Kubernetes cluster.
So let's go ahead and take a look at
our build pipeline. So here it is.
We'll go ahead and edit this, so you can see what this looks like.
Remember, this is a Kubernetes or a container application, right?
>> Right.
>> So here we go. We create the image.
We push the image, we build it,
then we install Helm and we copy the ARM template.
All right. So now we're all ready to go.
Now, we jump into the release pipeline,
and again we create a release pipeline for you that
makes sense for the technologies that you picked.
So once again, it's only one environment,
but easy not to clone your [inaudible] environment.
>> Just like you before.
>> Yes. If you drill in here,
you'll see the task that we use to deploy
this Helm application into your Kubernetes cluster.
>> Very, very cool.
>> Now here's the million question, right?
Great. You can take the sample app deployed into your cluster.
That's fantastic. But what about my real application?
>> Right.
>> How do you get your real application in there?
Well, remember this repo is just a git repo.
So simple enough for me just to clone it.
Swap out my app with the sample app,
and wait for that. That's all you need to do.
>> Fantastic.
>> Now you're ready to rock and roll.
>> Awesome, man. We're learning all about creating
your CI/CD pipelines for your apps
deployed into Azure here on Azure Friday.
[MUSIC]