bonjour hi welcome to another video of cloud in five minutes I'm Frank Boucher
and today I want to show you how to build a CI CD continuous integration
continuous deployment for your Asscher functions using the arm template
the continuous deployment is a very powerful and useful tool it's possible
to do with an arm template for a sure resource manager template have many
different video if you want to watch them the link will be in the top right
corner it's in fact it's a big JSON file but the first time you look at it it
seemed a bit complex but it's not when you start little soul it have a look to
a simple a sure function arm template to be able to deploy a a sure function
using an arm template you need at least three resources the azure function the
blob storage and a service plan the function is the function the blob
storage is where when creating instance eating the function will put the code
and everything and the service plan is to define the resources I will be able
to scale or function if we look just a little bit more in detail here inside
the function resources I will have a list of properties one of these property
will be the connection string the reference to the blob storage that will
be created at the same time then I can specify also the runtime for example am
i running java javascript powershell dotnet another list of
element will be a sub resources and one of those will be source control this is
your way to specify where is your code this way when your function will be
instance e that will take the code inside that thing and put it in your
storage in today's demo what I want to do is create an arm template for a
project that is available online you can find it the link will be down below and
it's easy unzip everything this function will
unzip any file that you drop in a blob storage and put it in a second blob
storage therefore I need a second blob storage defined in my arm template so
this is why I created a second node where the blob storage for my files
and also we'll had a few properties inside my function to connect my second
blob storage and maybe have the destination container name and all the
things I need now let's have a look what it looks like in Jason so let's get
started with our template so we'll go open visual studio code and I have an
arm template empty here so just create an empty one and we'll add the three
priming resources that we need so the function blob storage in the
service plan so first let's create our functions or arm func Walla and now
we'll put a function name so function app the service plan so serve this plan
name whips plan like this and then I need to specify the storage name so
storage funk because I will need to storage I want to be sure I'm pointing
to the good one and then I mean also to specify it here so storage funk so those
are if we see here it's the properties so here I'm building the connection
string and I'm using the reference to the blob storage that will create just
in the next resources so storage funk so now I need to specify the runtime in my
sample my demo its dotnet great so now I have everything I need so this is the
properties so this is where I will have those other stuff of course all the code
is available on my get repository you can find it the link will be in the
description so easy unzip everything the code is there you could have a look
let's go back to our arm template great so now what I need to specify my storage
account so arm and then it's the G voila and I need to specify it so I mean it
storage func voila so now I need to specify my service plan so let's add
another one voila and I name it service plan just like
this you could use your function with a service plan and specifying how many SKU
CPU and memory you want to use it I prefer using something dynamic at least
and in this case because my function will run very quickly so I need instead
of f1 for free I need to use the dynamic one so why so I don't need the capacity
instead I will use the tier and it will be dynamic in fact air one more thing
that I need to do to be able to use the dynamic is to specify the API version I
need to use the 2018 Oh 201 otherwise dynamic won't won't be available so the
only thing left now is to specify our source control so we need to get back
inside our function so here I am in the function node so this node here is
function I have my first group here the properties so I need to find where it
hands it stems here and now I will what I will do is I will had a Sun a list of
resources so just had some resources here and I will had a source control
maybe I don't know how to write it and I don't have any sample you could go in
the Microsoft documentation to the bitly slash arm function all the code that I'm
using come from there and then I change it for my project so if you scroll to
the N or mostly to the end you will find the node so here is with the source
control so let's copy paste that and in adapt it to our code that we have so
here I will just paste this and now I need to change it so of course before we
create that sub resource we want this parent to be created so we'll change it
in my case is function app there it is and now I
could use parameter to specify the URL of my repository and my branch so if you
want your deployment to be completely automatic I will suggest to set this
property is manual integration to true and also had the property publish run
book this way you're sure that everything will be deployed in one shot
so there it is we have it so of course we cannot really use the arm template
like that we need to make it a little bit more bulletproof to know how to do
this you can watch my previous video where I
explain and few steps out to make your arm template very strong let's see what
it looks like and then I will demonstrate how to integrate this in a
CI CD so let's jump in another project so this is the code available on github
everything is there so it's the same template I just apply those best
practices so I use a few parameters on lead 3 well I have a base name my get
branch because I'm passing the branch so if I want to change the branch if I'm
working a new feature I could use a different branch than master but by
default it will be mastered and then I'm specifying the name of my destination
folder and I have a few here variables I decided to put the URL for the git
repository inside a variable instead of parameter I fun it a little bit more
stable this way and then I have other resources that we create so with my
connection string to the initial blob storage and then the second blob storage
that I need specifically for my function not generic function and then I have my
source control defined here like we just saw and then I have my first storage
account for the function I have my service plan here detail with the
dynamic specified and I have my cert can't start account where my file will
be dropped and decompressed unzip and this one is a little bit different
I have specify two sub resources and they are containers because I need to
have a drop zone and containers a container is just a folder in the azure
blob storage a kind of container wall will be unzipping the file so there it
is I have my full template so now I could use a button like in my project so
if we go on my github project at github f Boucher unzip everything easy unzip
everything you will have one of those button and if you click on that it will
bring a form to deploy the area this project in your in the user subscription
so this is really useful when you want to give access an easy access to anybody
to create your solution so there it is they just need to specify of course the
subscription the resource group and then the settings will be your parameter and
the description that you specify and that metadata will be available here and
the default value value will be pre-populating everything you just check
this agreement and then click the blue button all the resources will be
deployed but maybe you would like to have it in your subscription and maybe
you know having some secrets that you don't want to share well it's easy you
can also use it in Azure DevOps so let's go in Azure DevOps and let's create a
new release pipeline so we click on this voila all take an empty one and I will
create an artifact for this artifact I will reference my github repository so I
just need to specify my github repository so unzip everything perfect
and now I will go and specify my branch in my case I will specify master and I
will go for it last version of course you pick what you need so there it is I
have everything I need click yes and now I need to specify jobs so let's add a
job and we'll look for arm template so here it is as your resource group
employment that's what I want so so we'll need to specify my subscription I
will need to specify a resource group I can create one if I want so let's say I
want to create a Z unzip everything resource group and I'm specifying the
location I will take the location I want let's say East US for now
perfect I want to now specify the template I want to use so for this I
will click here and now I'm in my git repository so my arm template was in a
subfolder named deployment so I'll pick this deployment assured that Jason
that's my file perfect and maybe I need to specify some parameter file I could
just override the parameter or I could use the parameter file in my case I
specify a default value to everything so I don't even need it but let's say I I
do I do so I'm creating like this and now by
saving that just giving a name that makes sense and for that and this way I
will be able to deploy automatically every time I want it could be based on a
push or it could be after I have some test and validation that was required so
both are very useful if you want to deploy if you want to provide an easy
way to deploy your solution you can use the easy deploy button it's possible to
have those button inside your git repository or any website or you could
use the azure pipeline or in fact many different pipeline to deploy in a
specific editor subscription the arm template are very powerful would it be
for a server less or any kind of resources you want to deploy in Azure I
hope you liked this video and I hope it was useful if you have any kind of
questions the comments on section down below is waiting for you it's always a
pleasure to read you if you did like this video give it a thumbs up share
it's very useful thank you for watching see you next time
you