in this video I'm going to show you how to integrate Azure automation runbooks with github
controlling source code is important for good code
management especially when multiple people are working on a project this is
just as true for run books and as your automation and as it is for any other
project in this video I'm gonna show you how to connect it mature automation
account to github before I get started please just take a second and hit that
subscribe button and if you're feeling crazy hit the bell icon so you get
notified when I publish a new video ok you'll need a couple things to get
started as you can imagine you'll need Azure your automation account don't have
one well I have the playlist for you just click up here someplace
there'll be a link that appears they'll take you to a playlist with everything
you need to know for as your automation I'm also using a github account that I
previously set up if you don't have a github account you can sign up for one
for free the free option now allows unlimited
private repositories these are code repositories that are not public making
it a great spot to store all kinds of code did I mention it's free once you
have all that setup you're ready to follow along on the demo so with that
let's get started with the demo buckle up everyone it's demo time
here is my Azure automation account temp demo that's what I'm gonna be
demoing with I have github page open here this is the applications a
authorized OAuth apps are at 0 there's nothing here and I have a repository
over here with a readme file so it's empty so let's connect this automation
account with github I'm gonna start by going into my animation account and
we're gonna go down to source control I bet you probably could have figured that
out I am going to add source control so I'm gonna name this git and under source
control type I have three options I can do a github or I can do Azure repos which
is based on git or Auzre repos based on Team Foundation server
I'm gonna select github and it's gonna ask me to authenticate so here I'm going
to authenticate enter my password and then I'm going to select a repository
here are all my repositories I'm gonna go to temp demo and I'm gonna select the
master branch if I had a folder in this repository I could select it I don't
gonna turn auto-sync on for the demo and I'm going to click Save now well that's
saving let's go over to OAuth apps and if I do a refresh you can see automation
source control is right there
alright so I'm connected now I have my github account connected to Azure
automation source control so down here I have VScode and I also have this
connected to my git repository and that's the same temp demo so let's go in
you can see there isn't the readme file I'm going to create a new file I'm gonna
do temp 1 dot PS 1 and I'll do a simple write output command oops and we'll just
do a hello world and I'll save that and as you can see here the source control
is telling me I've got to change so I'm going to accept that change and then I'm
going to commit the change so that's committed locally now I'm gonna push it
to the repo and we should see that in github and there it is temp 1 dot ps1
has been added now if I go over to source control I'm gonna look at sync
jobs this is gonna take a minute to finish well we're waiting for that to
finish why don't you take a second and let me know in the comments below if
this is something that's really interesting if it's something you're
using maybe you plan to use it or have let me know what your experience
has been or if it's just something you kind of intend to use just type in "Git"
if that's all that lets me know that you're you're interested in this and
maybe this is something I should do more videos on all right there it's complete
and let's go back up to run books now
there it is temp one is published now if I can click on that we can view this the
code behind it there's hello world and I can actually start that and let's see
what happens when we run it as you can imagine it finished and with the output
hello world so that worked now what if we want to update this let's go back to
code and we're gonna put in another line will do we'll just put in hello to you
something simple for illustration purposes I'm gonna go back down here
whoops and I'm gonna save the changes
next I'll commit there we go and I'm gonna push so now I'll update the copy
online and we can go back and watch this take place so it updated 18 seconds ago
that's a pretty good sign let's go back to our automation account and we'll go
into source control watch the sync jobs we can see that's queued we'll give it a
minute to run there we go it's completed and as you can see by the time stamps it
does take about a minute for each to complete if we click on that we can see
some job details and at the very end here it says one file synced so that is
a good sign now I'm gonna go back up to run books and there it is we can take a
look at that and see the changes have been made I don't need to run this again
I know it's going to happen and as a last step
I'm going to actually delete that file so we're going to come back into here
and we'll delete save the changes and
i'll just put a comment in there that we remove the file save it and push as
you can imagine the file will disappear when i refresh here so it's out of the
repo and now I go back over to my automation account source control and
we'll go to a sync job there it's queued running and it's complete and we can go
in and see the job details there it is one file deleted and we can verify that
by going over to run books and no run books found so that's gone that's all
there is to it that's how you link and Azure automation account with a github
repository I hope you found this useful if you did please let me know in the
comments take a second to hit that subscribe button and you can hit the
bell if you want to get notifications when I publish new content thanks for
watching