ARM Templates - #7 - Pipeline Release

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
I'm Dean cipolla and this is the Azure Academy this video is by special request we got a comment and we do read the comments that come in and the comment asked for a continuation of the automation series that we did and in that automation series we talked about how to deploy things with arm templates and we started off very simple and got to a very complex deployment and one of the things that was asked was to show how we could do this integrating with a online code repository like V STS are now called Azure DevOps and how we could use a release pipeline to actually manage that deployment lifecycle so what I thought I would start with here is this is the set of templates that we used in our video on the azure firewall and as you can see here we're deploying a hub-and-spoke V net a routing table storage account and two VMs and the firewall itself and the parameter inputs are quite simple just a name and a password for the servers that we're deploying as well as an IP range that'll dictate how the address spaces are set up and all the subnets on the virtual networks so this is a pretty simplistic template that would be very easy to show and how we can connect this out to bsts and so what I wanted to start off with here in Visual Studio and of course if you use a different tool would be slightly different but in here we have the team Explorer and this is where I have connected to a particular repository and this is my repository in Visual Studio and I've got a bunch of different stuff in here and this is my firewall and that looks like over in my visual studio team services are now again called Azure DevOps here's all my repositories and if I go into the firewall repository and then we go to files under repos you can see it looks like all the same content okay and if we open up one of these files you can see it's the same code I've uploaded all of my files here to this repo and then of course you can manage different inches of the repo you could also look at here some of the history of the repo these are all the different pull requests that I've put in and these were just going through in a testing phase so very small tweaks that I made but you can see things here's the the line of code that was changed here's what it was changed to so it does color code of these things and then if I go back here and I'll just look at another commit so you can see all the changes that I made here and showing me the side-by-side differences or you could set this up to just look at the in line differences so I prefer side by side but anyway setting up a new repo itself is actually pretty simple so in your vs TS account you can create yourself a new project your create project and we'll just call this test and this is a test and this is a private repo or you can choose to make it public and then choose what kind of version in control you want get is more of a decentralized repository meaning I have a copy of the code you have a copy of the code and then we make pull requests and then we talk to each other just like github works now in Visual Studio or Team Foundation version control it's the opposite there is a centralized repository where the code lives and I make changes and then I do requests and you have somebody who manages the code centrally and decides what request should be accepted and denied etc so I'm gonna stick with git and then you can choose which kind of work item process you use I like agile so I'm gonna hit create okay and just like that we have a new repository okay so if we go to our files here in the repo now there's nothing here currently so what it's telling us here is I can go to my computer and I can do this or I can hit clone individual studio or clone into any one of these other tools that I use I just do it with Visual Studio myself and there you go Visual Studio is going to open and it's going to connect to that repo and asked me to sign in cetera which I'm not going to do at the moment okay so that's how we create a new repository now once you have that repository you would get another managed connection here saying that you've got a new repository and I can just add one here if I want and this is kind of the opposite way of doing it but you can do it in either fashion so I would just open my repo here and then click on test and connect and then when you connect then it's gonna ask you for a location okay and I'll store the code here and then you hit clone okay now there's currently nothing in that repository so there will be very little to actually clone and then once you have that all set up then you can go back in and you can actually create yourself a BS project and then you can kick it off from there so what I'm going to do instead right now is go back to my firewall alright so that brings us back to our code so here we are now we've got this synchronized so that we're connected to our online repository okay so we're back here now in our firewall repo with this now we want to set up our repository so that when we make a commit from visual studio we want that to initiate a build so for that we need the pipeline now the pipeline has several different components to it the one of which that is necessary for Azure resource manager templates by themselves is the release pipeline so a build pipeline would be where you have to actually compile something so in this case we don't have to do any of that okay we have no packages that we're pushing we're just pushing templates so we're going to create a new pipeline okay and we're just going to start with an empty job here and we'll call this deploy firewall okay and then you can make comments along the way when you do saves so we'll give this release pipeline a name deploy AZ firewall and then we have to give it some artifacts so the artifacts are going to come from our repo and we'll select our firewall repo here and we'll select our source and then it's going to select for us a branch if we have more than one branch we can select that and then check out from the latest of the branch and then you can have a source alias here which I'm fine with just keeping the original name and hitting add the artifact has to trigger the job so we want the commit from Visual Studio when we push out our changes to be the trigger that says go deploy into Azure so for that we click on this item here and that's our trigger so that's going to be a pull request trigger we're gonna hit that and we're going to select that for our master branch and we've got a little warning here that says this stage ok this stage that we're dealing with here is not enabled yet for pull request deployments you can enable this based on deployment into pre deployment conditions of that stage so for that within the stage we got to click on this icon which is the pre deployment condition and so here's our trigger we can have this be manual meaning we go in here and we kick off a deployment manually or after release which is the commit from visual studio which is what we're gonna do okay so we're gonna have this be a pull request deployment and we're gonna enable that and then we go back to our trigger here and you can see that that has now been satisfied when you go in here to your stage there are other things that we can do to to add some other functionality you can add building variables to deploy to dev or prod environments and have them be different deployment locations things like that all kinds of steps that you can take so for right now we'll just go with that and now let's go up here to tasks and you can see in our tasks we have an agent job so what is this so when you deploy something whether it be from as your CLI PowerShell REST API visual studio vs code the portal itself something must talk to Azure and say here's a deployment that I want you to do from Visual Studio or PowerShell or as your CLI or BS code all of this happens by you with your permissions kicking off the job when it comes to Azure DevOps or github we have to enable the system to be able to do that and that's what an agent is now there are different kinds of agents you're going to use a pooled agent you can install agent onto a container to a Windows VM to a Linux VM so I'm fine with using just a pooled agent right now and I don't need to add anything extra special to this so the defaults here are fine so now what we want to do is we'll just save this and we're gonna hit the plus sign here resource group deployment and we'll hit add ok so now what it wants is a name to display here so what we're gonna say is deploy AZ firewall and then we need some details so our subscription that we're going to deploy to and then a particular resource group so now are we going to create a brand new one are we gonna have existing resource group we're gonna do a create or update and then the resource group name that we're gonna type in here is going to be a Z firewall and it will create the resource group for us and we're gonna put that in East us and now it wants to know what is the artifact what's the template is this file existing in a storage account or on github or is it something that's linked to visual studio in our case it's linked so we'll hit the little ellipse here and it goes into our repo and then we can select our particular files so we'll select our as your firewall dot JSON and then we'll feed it our same parameters file ok and then if you want to override the parameter and this is an instance where you might do this if you were using variables and deploying to different environments but I'm just giving you a overview here so we're gonna skip that our deployment mode again if you choose incremental then that will be a quote unquote normal deployment a complete deployment will say anything that's here I'm gonna wipe it out and I'm gonna replace it with this okay so do not use complete mode unless you really really really know what you're doing okay because you could inadvertently delete things so and then there's validation only so I'm gonna use an incremental and then are there any other additional prerequisites for this no in my case there are not and then I don't need any particular outputs or anything else so this is good enough for me so I'm gonna save this okay and when I look at my history here we can see that I've got comments just like we do in the code repo okay so we're pretty much ready to go here so let's go back and or actually we'll we'll just go to our release right here now we can actually create a release all right so this is stage so we know what we're doing and we have the right triggers for it we could create a release directly from here but our intention was to go and do this from visual studio so I'm gonna make a edit to the code here let's see how about we just delete a period and so we've got a red check here that says that there's a pending edit and then we go to our changes and we say and then we'll do a sync and that'll push our code that's all successful and now our release should trigger on its own in a second here and so right now this is the azure portal you see I do not have an AZ firewall resource group currently okay so there's our release and that's in progress if we go back to asher and you can see we've got our AZ firewall and that's already building our resources and it's going through a normal deployment and then as it's going through or even afterwards you can look at the log files here and you can see it does the same kind of things that happen during a normal deployment process the files are packaged they are sent up to Azure and they are staged for deployment and then the deployment begins and then the agent sits here waiting for response from the portal which is basically what you'd get looking through all this here so currently let's see if we check our deployment status there we go we built most of our resources we're just waiting on our service to complete and the firewall itself so that's basically it in a nutshell we'll just wait until this completes here okay so our deployment has completed successfully and we can look at all of our logs here and they would show us that the deployment was successful for this template and you could look through any of the other logs here that you wanted or download them for future use all right so looking back here at the portal deployment succeeded we've got our boxes here up and running we've got our firewall configured and we'll just take a look at the rules real quick so you can see we've got a couple net rules and network rule and app rules so this is all configured out of our template and it looks like everything worked correctly so there you go that's how to do a release from visual studio causing them a trigger to make a sure DevOps perform a deployment of our templates artifacts from our repo to the cloud all integrated together as a single solution hope you enjoyed this video and give us a thumbs up if you thought it was cool and give us a thumbs down if you think it's stunk and we could do something better and give us some comments subscribe hit the notification button we drop a video roughly once a week let us know what you're interested in and this video again was by request let me know what else you're interested in and I'll put it together happy learning
Info
Channel: Azure Academy
Views: 4,679
Rating: undefined out of 5
Keywords: arm templates for beginners, arm templates, arm templates azure devops, arm templates azure tutorial, arm templates tutorial, azure devops tutorial for beginners, devops for beginners, devops tutorial for beginners, nested arm templates, nested arm templates azure, nested arm templates example, arm nested templates, arm template azure, arm template deployment azure, Azure Academy, azure devops, Hybrid cloud foundation, nested deployment, The Azure Academy, yt:cc=on
Id: 8QjE7yn6JME
Channel Id: undefined
Length: 15min 19sec (919 seconds)
Published: Mon Dec 10 2018
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.