Arm Templates for Beginners | Intro - ARM Templates #1

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
I'm Dean cipolla and this is the Azure Academy so today I thought we would start a series on automation and this is something that's going to become quite a long series because there are so many things to cover in terms of automation so to get the basics of automation we need to understand first the concept of infrastructure as code so when dealing with things in the cloud we have a set of resources that are out there that we can't touch we can't hold but we can interact with through a portal or programmatically and it's that programmatic approach where we want to focus so infrastructure as a code is where we basically take the idea of building computers or data centers or applications and we make some kind of machine readable definition file of what that should look like and that it represents all of the the same kind of physical manifestations of that code that we want in the end meaning we want servers we want those servers to have networks they should have storage they should run applications they should be able to communicate with each other this is all infrastructure as code in the cloud so in infrastructure as code the other concept which is a DevOps concept and don't be scared off by DevOps if you're more on the the infrastructure IT management side of things DevOps is an approach to developing systems and maintaining them and iterating through them for continuous improvement so when it comes to infrastructure as code in relation to building out our infrastructure in the cloud this is going to help us to maintain our systems in our environment so we don't drift from our manage configurations we don't get these weird snowflake systems that we then don't know how to manage properly things are produced in a methodical way where they are planned designed implement did maintained and then at the end of their life cycle they're terminated and cleaned up so all of this is managed through infrastructure as code in Azure and to get us started with some of that I want to look just briefly at our azure documentation so here is our azure portal and let's go to our documentation page and you can find the stuff about the azure resource manager under products management tools as your resource manager so the resource manager is the ultimate engine that is behind everything that we do in Azure today so with the resource manager we have a interface that we can talk to and give it our code declarations and as you see in our picture down here we have these things that are called the provider rest endpoints and then we have tools like the azure portal or a command line like the azure CLI powershell terraform ansible and we have other applications that help us to write code like Visual Studio or vs code you could also write these these templates and something as simple as notepad if you wanted to the tools give you things like intellisense so what in the world is intellisense intellisense is when i'm writing code and i say i want to new as your oak see this box this is intellisense this is that box that pops up that helps you to finish what you're writing as well as I could hit tab and I get tab completion and that's also based on intellisense so it helps you to write your code and helps you to to know what syntax you need to be using and how to how to write these statements in such a way that the system is expecting them so that you can get in turn the thing that you want so that brings us to a topic that we're going to cover quickly and that is the difference between imperative and declarative code writing so a imperative command would be something like what I did here in PowerShell I want a new Azure RM resource group and that group needs a name and let's say that that name is test ok and now we're gonna give it a location and let's say that that is East us and then we hit enter and then what happens well the system then builds us a resource group called test in the east us region because this was imperative lis declared give me this thing and make it over here and do it like this now the declarative way is different than this so in our azure portal if we look at some of our asher academy look at our deployments and let's look at one of these guys so this was our our a a 20-19 jump server that we build and that was the deployment procedure and you know you've seen these things before but this is the template that built it for us now we did this through the azure portal but it saves the deployments here so we can go back and reference them and do other things so here if we look at the the tree that's given to us here we have several different items and these are parameters variables and resources and there's more that could be here but this is it for now and in this section we have a resource called a virtual machine resource and that virtual machine was going to have an OS profile and it's gonna have some kind of hardware which is the VM size and SKU and some kind of storage profile which is what operating system image this was based off of and that disk was built from an image and there were no data disks one network card was used and it was using a diagnostic profile and an availability set and it depended on these other resources being built first okay now based on all of that declarative information the system gets built o in PowerShell if you were gonna do this you would have to say ok so I need to build a availability set so let's write the code for that first and then I need to build a storage account so we can have Diagnostics well so let's build that first and then we need to build a network card ok so now we built that first so we write them out in the code and we say build this then this then this then this and then after that we know we've got all the pieces we need to build our VM and then put it all together but you don't always know all of that ok if you're unfamiliar with the command to build a new VM you may not know that you need all of those pieces to be built first in Azure in a declarative arm template we can say I need this VM to have an availability set use this one if it's not there it'll go make it if this was PowerShell and I said use this availability set and it didn't exist they'd say you're out of luck pal so in a declarative document we say it should have this and it should look like this and then arm figures out does this thing exist and if so use it if not create it ok so it does that extra work for you it's kind of like in PowerShell or in other scripting languages if you were to say check this and if it's this way then do this and if it's not this way if else do something different ok arm does all of that work for you you just tell it I want a VM and I want that VM to be called this and to use this image and you declare I want this arm go make it so alright so if you think give it that way this is the the make it so engine of the cloud okay that's what arm templates basically are and each kind of section that's here has different things of importance this is the parameters section and a parameter is a input that has some kind of type associated with it you can see here we have a lot of strings but then we come down to our admin password and this is a secure string because we want our passwords to be encrypted okay there are many other kinds of inputs that you could use but let's keep going the one thing that I'll point out too is take this input parameter for a second here Auto shutdown time zone now there is no magic formula that means auto shutdown time zone equals anything this is a input parameter you could call this Mama's apple pie the reason why we use a name like auto shutdown timezone is because that means something somewhere else in the document you know we have a public IP address type because in the section of the document where we create the public IP address we need to know what the type is okay because that's related to a function that's related to that that resource so you want to make your parameters as specific as possible so that everybody else can know what it is that you need this to be put into this field secondly we have this variable section now what is a variable so a variable think of it like this way it's a container that holds information that you can call on at a later time so in the concept of PowerShell if we were to make a variable we could make one with a dollar sign and then we say new okay so this is going to be a new whatever let's make this a name for another resource group will say that this is called illy and then let's make another one called Fred and we'll say that this is East us so now if we were to write our imperative statement of New Ager RM resource group and we gave it a name this name is the input parameter and we give it the variable of new Oh got a little anxious there and we give it a location of Fred now that doesn't really make a lot of sense compared to what we did before name was test and location was East us here location is Fred what does that mean well it doesn't really mean anything to anyone except me now if we run this it's still gonna work and we get a resource group called Billy in the east US region but you want to make these things make sense that's why your name has to make senses and input parameter location has to make sense so that we know what it is you're asking for and then when you make variables the variables should make sense because you always want to write your code knowing somebody else is gonna be reading this and trying to figure out what it is that you did okay whether that's a colleague at the same place that you work or you're looking at templates that somebody else has developed okay so you want to write your stuff as clear as possible so that other people can understand what it is that you're talking about and also because you know it makes it easier on you too if you're talking about computer names and admin user names and passwords if you had these inputs parameters here called Jakob and Ferrari and Smith and Wesson you wouldn't necessarily know what they were six months from now or six years from now when you looked at this template so it makes it easier on everybody all right enough of that moving on so in a sure we have a bunch of ways to deploy templates and to help you in writing templates so for that we're going to look at two sections in our all services up here there is a item called templates which I've starred so that shows up on my little sidebar and we'll open that up and this is where you can write templates and store them inside the azure portal so if I pull up this one here this is to build a Cisco firewall appliance and so we have a bunch of different kinds of input parameters whole lot of them as you can see and then after that then we have a variable section which has a whole lot of stuff and you see this looks very different than the last one that we looked at and you go further down and now we're building resources and each one of these resources has their own unique bunches of information that you need and this all looks very long and very complicated and boy look at all those letters on the page how am I ever gonna do that well we don't start with something super complex we start with something simple and the easiest way to start with something simple is something that's easy to understand and already done for you so in this top search bar we're gonna type the word deploy if I can spell and it's deploy a custom template now this is the part in the portal where we are linked to our Asscher github repository where we have something called the QuickStart templates now I'm gonna show you what that is so we say github as your QuickStart templates and this is where we store and the public github repository more than 700 templates to help you to get started okay and we list them out as the level of difficulty so level 100 101 you go down quite a ways and you get down to 201 and then 301 and then you get into some more specialized stuff but looking at it this way it may be a little hard to find exactly what you want we made this searchable box that links to all 700 templates that you can find very easily what you need so if we said I need to build a sequel always on cluster well there you go there's a template right there for it or what if I needed a NFS cluster or perhaps I needed to build a new domain well here I can build a domain controller or a high availability set of two domain controllers or maybe I just need to build a simple Linux VM you can say simple Linux VM or maybe one with accelerated networking so we can click on this and hit select template and that's going to bring us to this screen now this is where we have the front end of the azure portal serving as a way to make input parameters and deploy a resource so here you can select what resource group you want this to deploy to and there's our billy group then you can give it a name and a password and then you can give it a dns prefix something doesn't matter and then you can give it a location now this looks kind of funny this again doesn't look like yeast us to me so this is a template function which we'll get into a little bit later but basically a template function means that we're using some logic in the template to make your life easy here so this function is called resource group which ironically enough has to do with resource groups and it's saying select the resource group where we're deploying which is Billy in the east us and give us the location for Billy and make that our input for our location to build this new VM so let's select the resource group and then give us its location so it's taken Billy from the east us and it's going to populate that information in this field for us okay and then you hit the check box here agreeing to the conditions above which basically amounts to you're using your subscription credits or your going to use funds to pay for building this resource in the cloud and then you would hit purchase and what that's going to do is execute this template and this template has the input parameters we saw admin username password DNS prefix Ubuntu version location there's that funny function that we looked at and there are some different kinds of input values here so we have different types and we have strings and secure strings and then we have this construct here for allowed values and default values which pre-select a allowed value for you and then we have some metadata to help you understand what stuff is but these things don't just exist here in the template and have no other meaning they're here when you mouse over these little tooltips that's the metadata description when you do a secure string that's gonna encrypt the code there the text that you put in there okay when you do those allowed values that gives you a drop-down selection to make people's lives easier instead of having to know that it's 14.0 4.5 - LTS you've put it here for them already you're making their lives easier okay the the other side of this is that we can store these templates so inside here we can add this to our to our templates that we had by doing a copy and then going back to our template section and we're going to hit add we're going to give this a name we'll say simple Linux and open no spaces and then we say here simple Linux VM with network and storage we hit OK and then it gives us this outline which we can highlight and delete everything because we're gonna paste our code and now I've saved this ok and there is our simple Linux VM and if we click on that here we can edit the template change anything that we want in this template in fact let's do that let's hit edit and we'll edit our template here and then we'll change our allowed values we'll take these guys away and then let's not take all of them away let's take these two away there we go and then we'll hit OK there and wait save and then we'll hit deploy and when we hit deploy it looks very much identical to the last one but there's only two values here now because we remove the others so you can customize the templates so it's a good idea to start off by building something we're building something in the portal yourself taking the template bringing it in here looking at it just you know breaking it down figuring out what's in there and then customizing it and that's a good way to start learning about new resources and building out templates so you can see the work that others have done and then build on that so the other part of templates that I wanted to look at quickly is Visual Studio now Visual Studio there is a free version of Visual Studio that you could use and you can find that if we go back to our portal here on download Visual Studio and there's a link right here so you can download the community edition of Visual Studio which as far as arm templates are concerned is exactly the same as using the Enterprise version of Visual Studio so you download this and install it running it as administrator and then when you're done you end up with Visual Studio and we can run all of our arm templates from here I'm going to do a new project and the project that I'm going to do is a Adger resource group based project okay and we're gonna just leave the default values for everything else here and we'll hit OK now in Visual Studio kind of like the QuickStart templates we have a bunch of preset stuff to help you to build things so right now we're just going to start with blank so we're gonna make a custom one okay so this is Visual Studio this is our project and I start off by looking at our as your deployment template and here we have just the blank template well great now what do we do I don't know how to write this code well I mean you always could just insert the code that we got from the QuickStart template and now we've got a whole lot to start from I want to start from scratch so what I can do is right click over here on resources and I can add new resources and now I've got all the resources that are listed here to choose from so I could build a bond to VM and let's just call this test one two three and we'll take a storage account create a new one we'll call this test one two three Linux zero or 91 we'll hit add and then we'll create a new virtual network we'll call this test one two three - V net then we'll hit add wow look at all that it did for us so now we have a bunch of input parameters I mean I mean look at all this pen I just did that for us and and I didn't know anything about how to write all of that and look at all that so it gave us a parameter for our storage account and it gave us different types of allowed values and it gave us a place for our username and for a password using a secure string automatically using these couple versions of Ubuntu that I can choose from it made some variables for us it made some resources to build us a storage account to build us a virtual network a network card and a virtual machine using everything that's needed to build this and it just did it for me through a couple clicks well let's see what else I can do let's let's add some more resources how about let's make a a web app so I can make my own web pages let's call this my web page one and we'll say that this is a app service plan of new plan and there we go now we've added that stuff so you didn't know anything about how to write a website before but there you go all of that through Visual Studio made very very easy now this is where we start and I'll give you a sneak preview of the type of things that you can do okay so here is a bunch of templates that I've written for how to deploy sa P environments in the cloud you can see I've got a lot of stuff here okay and I'm not gonna open all this and show you all this stuff right now but suffice it to say that you can build entire environments whole applications whole enterprises using templates and you can make this stuff be very intricate and complex alright so you can start off with the basics work your way up to how to make things all work together and make different pieces of things all function together here's another series of templates that I did for building basic environments you're gonna do a brand new build for somebody and how do we manage that environment using some governance policies how do we write all of the permissions for what can be used in our environment how do we make our network or storage or compute building the the basic shared resources of domain controllers DNS servers file servers remote desktop infrastructure jump servers and then on top of that building your applications and all of this done through infrastructure as code okay you can literally build everything in the cloud using infrastructure as code right down to the permissions that you grant to people so everything can be done this way everything should be done this way there's nothing wrong with using the portal but the portal is a manual one-click operation with a template I can deploy an entire enterprise and it doesn't take very long at all okay this is the power of automation in the cloud so join me in the next episode of this series where we're going to get into a little more of writing templates in visual studio as well as reusing things that we've already deployed and we'll build some some simple web servers and I'll show you how we can build servers using some load balancers and make our services highly available and then we'll see some failover between the two different web servers and we'll do this with the portal to start and then we'll do it with the automation so you can see how the one translates to the other all right so we'll see you next time
Info
Channel: Azure Academy
Views: 15,280
Rating: undefined out of 5
Keywords: arm templates tutorial, Arm Templates Tutorial Azure Resource Manager, azure arm templates tutorial in hindi, arm templates azure academy, arm templates azure devops, arm templates azure tutorial, arm templates azure tutorial telugu, arm templates best practices, arm templates for beginners, arm templates in azure, arm templates visual studio, arm templates visual studio code, arm template parameters file, azure resource manager template tutorial, azure resource manager templates
Id: typrhntAzk4
Channel Id: undefined
Length: 29min 23sec (1763 seconds)
Published: Tue Sep 04 2018
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.