Automation tools for Azure infrastructure - BRK3266
![Automation tools for Azure infrastructure - BRK3266 Automation tools for Azure infrastructure - BRK3266](/pic/automation_tools_for_azure_infrastructure_-_brk3266/N1RjN0RodEplVE0_.jpeg)
Automation. Tools for our infrastructure. I'm. Really grateful. That you. Pick this session for, this time slot. What. We will cover today are, a couple, of different automation. Tools that we can use to provision. And manage, as your infrastructure. Some. Of those tools are created by Microsoft, some of those tools are third-party. Tools. We. Will talk about as a partial in air CLI, the command-line, tools. Created by Microsoft, will talk about arm, templates. Also Microsoft. Thing. As. Building. Blocks. Kind. Of a new thing that was, created. By one. Of the teams inside of Microsoft and, then we will cover terraform, in ansible. Created. By harsha Corp and Red, Hat. My. Name is Alexander, Nicholas I'm a freelance, partial, and Azure trainer, I'm, also cloud in data center management MVP. And Microsoft. Azure MVP. As. I'm covering private, and public, cloud, I like to call myself hybrid, NP MVP. I'm. Also, one of the cofounders of partial. Magazine.com, site that covers everything around, PowerShell. I'm running, it with a couple of my, partial, MVP. Friends. So. What is the goal, with automation tools what do, we want to accomplish. Every. Portal is great, is getting better and better I'm, particularly. Satisfied. With the latest changes that, happened just before. Ignite. And probably, some of those changes will happen during ignite. But as a portal, is a great learning tool, you. Use Azure portals to learn about new services, with. A helpful tool tips some. Helps there error. Messages, are good if you, don't. Know that you need to use all the. For. Example a casing, is different for storage accounts you will get a nice error, message there so you, will be guided through the Wizards how, to provision. Your resources. But. Using as a portal. Is not. Scalable if. You need to create one VM it's okay but, if you need to create 10 VMs hundred, VMs you. Need to have some kind of automation, we, need management, that it's consistent, and it's, scalable. And. Automation. Tools are allowing, us to have. Automation. For a complete, lifecycle. Of. Deployment. And management, of, infrastructure. When. We talk about different, infrastructure. Automation tools, we. Can kind of group. Them in. Three. Groups the tools, for automating. Configuration. Of the VMS so. We, can have control, on how our VMs, are configured, from the inside, then. Automating, infrastructure. Management. All. Those supported. Resources, that are needed when you work for example with, your VMs so, networking, stack storage. And then. We have also, automation. Of application. Deployment. And delivery, we, will not cover that part this is a focus. Of for this session is infrastructure. And. When, you look at all of them you will notice, that is some kind of a glue you will always, find, Azure, PowerShell and as your CLI, somewhere. There right even if you use templates. You. Maybe, need to deploy, them using, some command, line tools or if, you work, as your building blocks they. Are based on as your CLI for example so those, command line tools are really really important. When. We talk about configuration. Of our VMs. We. Can use a couple of different tools for, example. Very popular, or ansible, chef. And puppet and, also. Microsoft own desired, staying configuration. You. Can fully configure, your VMs, it's up to you in your team inside your organization. Do. They prefer, one. Of them or maybe, a mixture, you, can actually use, chef and puppet. Use. For example DSC resources. Inside of your work. You. Can also customize, your. Linux. VMs during initial, booting using, cloud in it it's also supported, for, distributions. That are available in, our marketplace for, Linux, but. If you want to have control is a ssin that covers all Azra VMs both Linux, and Windows, you, can use VM, extensions, in particular you, can use a custom script extension. And. It can run bare, scripts, or a PowerShell, scripts or you can use a run. Command feature write comment feature is really interesting, it especially, for troubleshooting because, you can use run command to run scripts. And target. Machine that it's not even available over. Network, that's. Really really crucial because sometimes. You, might make some mistake, or something can go really. Wrong with your machine you cannot access it anymore and then. You can use the run command as a. As. A solution for it. We. Talked about management. Of, infrastructure. Then. For. Building. The, infrastructure. Using, code. Here we can use our templates, as your, building blocks or a terraform, but. Sometimes, it's needed, not to use just the images that are available to you in Azure marketplace, you. Will need to use probably, your custom, image, for.
That One we can use Packer, to create a custom, image and then, uploaded, that to Azure and use. It for, provisioning. VMs, in, Azure. There's. Also one interesting service. That, started. A couple of. Years ago as some kind, partial. As a service, as your, automation but. Now it can also runs. Python. To, scripts. And. It's. Probably. When you see the name as automation. You might, think oh this is only for automating, asier. Resources. That's not true with, an automation, you can actually go, across all, the clouds. As, your, VMs, VMs. Or, physical, machines on, premises, or, some other public. Cloud. Providers. How. You can use them, what. Is the way to use all those tools you. Can use them locally, using. A PowerShell or some other shell, or. You can use, windows. Subsystem, for Linux which, allows you to run. Linux. Tools on. Windows. 10, almost. Like a native. Environment. It's just amazing how it, works you, will see that a little bit later during, my demos you can also use as a cloud shell as a cloud shell is. Available. In a portal when you click next to a Bell, icon on a shell icon or you can use the dedicated shell. Ashcombe, link and, you, will get a choice to work, in a bash environment, or in a partial environment both, of them actually run on the same Linux container. Why. Because, PowerShell, core is now available. On, Linux, Windows, and Mac so. They use that so that you have one environment with. Some predefined, pre-configured, tools and it's, up to you to, pick bash or PowerShell, core if. You're more familiar with the PowerShell you will work in that environment more, in bash you will go to bash, but. You are actually using the same container underneath. And all those tools the Filmation, are actually, available, to you in. Cloud shell you, don't need to install terraform. You don't need to install ansible. You don't need to configure them they're, already, pre-configured and pre-installed, for you and they. Are regularly, updating, the images to, follow the new over to install the new version system. The. Main editor at, least, for for me it now is Visual Studio code, Visual. Studio code is free. It's. A lightweight and it's, cross-platform, so. It works both Linux. And Windows and also on a Mac, all. Of those tools that we will mention today have. Extensions. For, visual. Studio code so, that you can nicely from, one. GUI. Work, with those, different, tools, without. Leaving, visual studio code. If you prefer if you and if you also set up your environment to run containers, then. You can run those tools in a docker containers, as well what.
Is The benefit of that you. Can just pull a proper. Container, image run. Your container, do. Your job, execute, your tasks and then, close. Your container, in your system. Will, be clean as before, you, don't need to worry about different, versioning you, don't need to worry. About potential, problems, if you have multiple, versions of the same tool installed on the machine of any of, those and. You can always get the latest one that it's offered by, Microsoft or. Some. Other vendors. So. Let's talk about Azure. PowerShell, Azure. PowerShell is, actually. A Ezzor RM, a set of modules to, use as a, resource manager, model. You. Can get it from PowerShell. Gallery partial, galleries and microsoft owned. And. Hosted. Repository. For all partial artifacts. Scripts, modules. DSC. Resources. Or, you can download for the github, repo. It. Will download the MSI file, the difference between those, two way, of installing, it is that. If you install it from a PowerShell gallery using, install. Module, you. Will. Get if you install it like, one version in there later another, one you will get both version side by side which. Is really good in a way that you can kind of a test if, you have a new version in suddenly your script breaks, you. Can load the previous version, and test, it again and see if it works in previous one then, probably. A new bug is introduced, in your new version and then, you can file bug on a github repo and they, will then fix it, if. You install it with MSI, then if you override the, previous, version, of PowerShell. So as, a power so that's a little bit of a difference we. Have also something new called, AZ which, is a set of modules that can, run on both Windows PowerShell and PowerShell, core it's, available to you when you work, in Azure cloud shell environment, and. It's. Very. New, it's still version zero. To zero but. The, way how it works is that they, also changed, the prefix for commandlets, but, they enable. All the aliases. So all your scripts that worked with, Azure RM, will, continue, to work okay, you, don't need to worry about those problems because. All the new a Z, commandlets. Are aliased, to measure, RM, as well right so there is no breaking. Changes. There with. Name. So. Let me show you a. Demo. Of as. Partial hmm. So. What you see here is a Visual. Studio code I've just picked a team of partial, is C so that, transition, is easier, for people that still work with IC, and. When. You install it you need to authenticate. I already, authenticated, to, Azure subscription so.
Why, Is it useful to use Azure PowerShell even, if you want to work, with templates, or. Some other tools you, can use Azure. PowerShell to, find out what's. Available to, you in your subscription, okay. So, for example, we. Know that we have. 54. Regions. Of Asia, I think worldwide but, not all of them are available in every single subscription, okay so, to know. What's going on really you need to. Run. Get Ezzor RM, location, and then, you will get a list of. Only. Regions, that are available to me when I use this particular. Subscription. The. Same thing goes for as, a provider and this, is really, interesting this is the list, that you will get for, things that are already registered. For you but. There is a way to say. List, available and then you will get the list of registered and, not registered, why, is that important, sometimes, Microsoft. Release. A public, preview of some. New feature and that public preview is not immediately, it's. Back up by provider, but that provider is not immediately, registered so you knew that you need, to do that manually so, in case it's something that it's kind of a part of documentation but doesn't work immediately you can always check if your provider is registered. If it's not then, you will register right so you'll know more, what's happening the same thing goes for example, to check, the available, machine, sizes, in, your, subscription. So, you will get this nice, information about, the number. Of CPUs, in the. RAM. Memory and. Number. Of course and all, that really nicely from, command, line. There's. Also a way to get the list of available. SKUs, so, that you know that. Some. Of them are. Available. Some. Of them are not available this subscription, so, if that happens and you know that you want to use standard. And. Cs6. Sv2. Then, you can call support and see if they can enable, that one in your subscription okay. So. Those are the all things, that are kind of partial, is really useful. To find out what, is your environment and how you can work with it. Let. Me show you here, how to really. Quickly. You. Create, a VM using, PowerShell, using. Something. Called smart. Default if. We look at the syntax, for new, Azure RM. VM. You. Can. See here. That. The, only thing that are mandatory the only parameters, that are mandatory are credentials. In name. So. Just specify credential, in name you, can create a VM you. Will not worry about anything else, everything, will be created for you isn't, that good for, testing. Purposes just, perfect, so. I'm already a. Authenticated. Created. A credential, here and, I want to show you this, that you can use what if you. Know that in PowerShell what if is kind of a safe Internet it will tell you what, will happen without, actually, executing, code so. If. You run it with a what else which, specific. Just the name and credentials. It. Will tell you, what. Will happen what, kind of a resources. We'll be created. During. The process of creation. Of a VM. If. You want to create, a Linux, VM. You only need to specify. Image. Because. By default. They. Think like when you work in a PowerShell you are more like a Windows guy so by default they will create a Windows machine for you if, you want to create a Linux one you will say just -, image and pick one of the available images, boom - CentOS, or Debian. Or somewhere, else something else so let me just show you the output here which is really awesome, when, you run. Creation. With the - verbose. We. - were both parameter. You, will get all this during the creation so that you know what's. Happening, and you don't need to go to a portal to check what, is the actual default VM size what. Are the values for subnet, for, being for, virtual network. What are the ports that will be open for you okay so you can get that information there really, nicely and at. The end you, will just get configuration, that the VM is created, the. Only obstacle. Here is that. This. Is really, like for the demo purposes, when, you look at the names of those resources. They are not very helpful right and this is not something that you will do in production, but for, demo, testing when you really really quickly need, the VM to, try, something, this is just perfect. If. You want to have a full control on. The. VM that you will create this. Is what you need to do you need to create all the resources, they are needed you need to create a V net you need to create public, IP address if you want to connect. To it you need to have a network. Security, group to allow access you need Nick. And. I. Will. Just need this a little bit later, so those, are the kind of steps. For that you, will need to create a resource group to put your VM there and. Then you. Will specify credentials. In this case I'm working with a Linux. Machine that I want to use, only, with. The, SSH. Keys, not, with the password so I'm using here like a demi password. That I will not actually use because I will disable it maybe later in the process so.
I Need to go through a creation of a subnet, or virtual, network then. A public, IP, open. A port and do. All that stuff you're. Going to have a creation, here, I will finally creation. VM and I, can also have a way to generate. SSH. Keys on my machine add them, to, configuration, and then, send that configuration, to Azure so that error I can actually, perform, the action and create all, those resources, for me so, as you can see there is a lot of things here and when, you pick this imperative, approach to create a VMs this. Is not production already code right we will need to have a lots, of those error handling things, there right so the. Beauty. Of for, me of using, partial is for ad hoc scripting. But you nearly lead. To the need to do something really quickly and get some information. But there is a better way to actually create, those resources. Especially for complex, production. Infrastructure. Environments. Let. Me get back to. Slides. There's. A CLI, is a command. Line experience. That. Microsoft, created, in. Particular for Linux, developers. At first and, they. Created it because it was across platform, before PowerShell. Was, cross-platform. So, they needed a solution for guys if you work for a Linux environment. It's. Also available on, Mac, Linux and Windows you can run it from cloud. Shell which is now just amazing, because you need to do anything you would just get it if you are very new to as your CLI the, best way to learn about it is to run AC interactive. Command which will put you in interactive. Mode with, lots of help, tooltips. In, intellisense. And all that so that you can just easily. Learn. How to work, with it because the syntax is if you are coming from a PowerShell background. A little bit different you can also run as a CLI, in a docker container. You just need to run, dr., run /. -. IT, for, interactive. Sometimes. - - RM, - remove it once when you are done and then. Specify, the image damage is provided, by Microsoft, its Microsoft. /. Ezzor - CLI, and it's not that big it comes very quickly to your machine and you just can, get the latest version. That they provide there and work nicely with it so, let, me show you now. How, the azure CLI, works with, with. VMs, and how. We can actually kind. Of a combine the azure CLI, in and partially, so, here for a same, kind of a goal, to create quickly, a VM. We need first to create our, resource. Group using. Easy. Group creates see the syntax is a little bit different than a partial, but at the same time you. Can get used to it because again. After. A couple of days, or maybe weeks, you will get get, it and it's kind of a grouped into those commands. That you say AC group and then you have all those verbs. That you can use all those actions that you can use with a group. The. Really thing. That I like when I work with either CLI, to create. The Linux VM is that I can, automatically. Generate SSH. Keys in this command if, I don't have them already if. I have them already they, will be just reused. In whole process of creating that VM so. This, is the output. That you will get when you when you run that and. What's. Interesting for, me is that when you let. Me just, switch. To. -, bash here. When. You run. The. VM, show to. Get information about, the VM what, you get back is a. JSON, so. That JSON string now, needs, a new query. Language, called James, pot to, get some information from it so if you are coming from a partial background, is a little bit of a challenge, how to get that right. Because we, are used to go, through a power, show objects, - to get information. But still you can master James, pot as well that's not that's not a problem what I want to show you here that it's so. This is the syntax for example, it looks a little bit weird for the PowerShell guys but it's also very effective if, you are coming from a Linux background and you work those tools and you know the syntax for but. If you don't want to learn, the new syntax for querying information. Then. You can kind of a combine the, letter. CLI, in partial. You, can get, the JSON string, from Azure CLI, convert. That to, a partial, object and then, continue. Processing. That, through partial, isn't that cool you. Just cannot combine two, different tools, and you, were again, on familiar, terrain. When you can just use the, partial knowledge for example so here, for example if I want to get the NIC ID I will run either, CLI, command, pipe.
That To Jason then. Continue, with. Partial, syntax, actually. To get information. By, the properties, and things so. If, I do this and then I, run. To see what's unique. ID I will get the NIC ID here right. Then. I PID, and, at. The end I will get, the public IP address using the same. Methods for that so. If. Everything works at the end I should get the public IP address so. I started. Created that with the azure CLI, got, the JSON file converted. Into PowerShell, and got it from a parachute I'm not saying that this is something that lots. Of people will do but. It's good to know that it's possible because, if, you are more familiar with the powers of syntax and all that you can always turn, it in, your benefit. To. Get back to slides. Let's. Talk about arm, templates, some. Templates, are, declarative. Way to, provision. As a resources. Resources. Are JSON. Objects here, you, can customize those templates, using, parameters. And. It's. Very powerful. You. Can create, really really complex environments, using it but. It's also the authoring, part is a little, bit harder, than I would like you, have and usually, how it works you will search, for on. A github for a quick start. Arm. Templates, provided by Microsoft, and a community and try, to find something that it's close, to your solution, and then. Try, to kind of change, that a little it's, kind of a little bit hard to start, from scratch writing. But there are so, many those templates. Available now. In probably. You, will find something that suits your needs, when. We work with the arm templates one, of the environments is visual studio but if you don't want to use Visual Studio because you think that's more for developers, Visual, Studio code can help you as well because there is an extension, for. Arm tools there too, that can help you with all the outline, and all that stuff so. To. Show, you how that looks. Like you will not, create, one from from scratch I will. Just show. You here, that in. Arm I have. Here. Arm template, that it's. Created. To. Provision. A Linux, VM so. As you can see it's pretty long there is lots of lines of code. Here all those resources need, to be defined. But, to help us with that we have this JSON outline, so that we can go through, all the steps that are needed there we have a sections. For parameters, for variables then, for resources, and at the end for output. As. Well because sometimes you want to get some feedback, after. You created something you want to provide fully qualified domain names, string, for example or maybe public. IP address or, even, instructions. How to connect, to. That machine, what is the username that it's needed an IP address for, a connection for example so. Every. Arm, template, has a schema, and a content, and then parameters. Block. Is not, mandatory, but, usually. You will permit eyes because, it, needs to run in a kind of create, in a different environments. Here. When, you have it you will get kind of a point, to a proper, sections of your code when you can fix. Something or modified, it if you download it from from several apps you. Can then use this, template, to do. A provisioning. From Azure PowerShell or air CLI, or, you can actually use it also in as a portal, and create. A custom, deployment, in Azure portal as well every. Time when you create something, in Azure portal you, actually get also, a template, for. It that you can reuse later, for. Redeployment. Another. Tool that I want to cover. Here is building. Blocks. Every. Building blocks is created. By pattern and practices, team, of Microsoft. And, it's. Based on their. Communication, with lots of customers, when they learn what. People are doing and they observed, and create, some proven, practices some. Best. Practices, default, so. They created a new tool AZ BB, do you like those new names for all those CLI, tools so. The AC BB, and a, set of predefined. Arm templates, are, dealt to help you to. Create, your. Deployment. It's. Based on the edge CLI, so that's prerequisites. You need to have as a CLI, pre-installed. Before you install AC, BB, and how. It works you. Actually need to specify a, settings. Following. The schema. Of the JSON, building blocks then, AC BB. Will merge those settings, with. Defaults. Provided, by a tool. After. That produce, a set, of parameter. Files and, then. Deploy. Those parameter. Files together, with, predefined.
Arm Templates, for you, so. Maybe it's not easy to follow but as, a, safe picture is worth a thousand, words so you can see here the, same thing but visually. We. Have default, settings you use a CB tool to get parameter. Files, and then, during, deployment, the parameter files will. Be combined with the templates at the end we will get tools. It's. It's really interesting concept, and. Let. Me show you. How. Easy. Actually it is to to be used so, when. Well. Easy. BB. Let, me see. So. Here is a. Very. Simple. Settings. File. That. I want to create a virtual, network simple, syntax is much simpler, in the file is much simpler than template, that we have seen really right you. Define, the virtual network a subnet, and then, for virtual machines here, you even have a VM count. Property, that says how. Many virtual, machines you want at the same time, so. If you for your demos. Or for your production once, to have a couple of identical. VMs. You will just change the number here and you will get 5, 10 or or more, the, only thing that I don't like here is this visible password, in, so. Once when you have this and you. Can, go. For, example here to partial and you will say like AZ BB, specify. A resource, group a, subscription. ID. Location. When you want to, create that and then, point to the DES JSON file is say just deploy. When. You say that it will create two parameter, files, and let. Me show you how they look like. So, this. Is the first one that covers, the creation. Over network. Network. Stack, so you see how it expanded. And the, other, one is much, much longer but, you don't need to create any of this everything. Will be created for you by that, tool. Real. Really, exciting. Thing for me I don't, know if they will work more on it but at. Least I'm using that a lot for. Kind of a really really quick demos, that are not that simple. Because it just provides, me a lot of abstractions, that I don't need to think about every single detail there. And. Then this is the output of everything when you get all those resources there, are created. For you and in, the end of everything. You, get your, full deployment of to BMC, and have ability, set. And everything, is fine, you can also extend it I mean I'm going here about kind, of a simpler. Examples. But you can always add, some additional things. Using, a DSC. Extension, or a custom script extension, run some, random, scripts there, to enable. Web servers, and to provide the content for those web, servers or configure something else. The, interesting, way. To, work. With your as your, infrastructure, is. Terraform. There. From templates, created by hajikko. They. Allow. You to, define. Your entire, Ezzor infrastructure. Now it's even possible to. Combine. Them, with arm templates, and then. Use. Them together it's. Really really cool I think that we have also a couple of sessions about that, at. Ignite one of them is actually today about, terraform, and kubernetes. So. The. Terraform, engine, also, can work with multiple clouds, which which is another benefit. So, that if you learn how to work with Asher you. Can also, use. That knowledge for something, else or if you know how to work with some other you can apply it to Asher you, need to have different templates but as I said like knowledge is the same you. Don't need to install it or you can install it locally you can configure it locally but you don't have to it's, immediately, available to you when you use Azure cloud shell, everything. Is pretty fine everything, is just, there you just need to use it. The. One that it's in the cloud shell is perfect, for kind of a single developer, but if you have, a team that works with the terraform, then, there is a better even.
Better Solution for it in Azure, marketplace, asier, give, us a, terraform. Instance based on Linux it, is pre-configured. For a team's work in, the use something, called the remote state I will talk, about it a little bit later and. This. Is really really awesome because you just have like instance. Do you have an image that it's pre-configured, for you with, all the needed tools and they also add some, additional tools are there, in you. Have immediately, a perfect, environment for your whole team of terraform. Developers. We. Have also two extensions. For visual studio for. Visual studio code we. Have a terraform which is created. By. Community. Members, and then, we have a shorter form that it's actually created by Microsoft, they, can help you during the authoring, part in. Local. Instance. Of Visual Studio code what. Is really cool is that you, can. Work. With those things locally. Create. A tera from template files locally, and then, you can upload them to cloud shell and run. The deployment, in, cloud shell. Let. Me show you how that works. That's. So. Work for working with with. The terraform. This. So. Let, me show. You first how the template. Looks like. So. Template. Is, written. In. Their own template. Language also it's, kind of a similar, to. Other. Syntaxes, that we have in a json and in in a Yambol but, it's more, human-friendly, I think just, easier, to read, it than in a json files so. Here we have again, the same kind, of a scenario we want to create a. Just. A Linux VM so. This. Is the section where we'll define. Everything. That it's needed to create a resource. Group then. A virtual, network a subnet. A public, IPS you see how those things are the same in every single. Solution. That we pick in every single tool we, have the same things and, then, a network. Security groups and all that what. Is really interesting here is that, when. You work, with terraform, and this is a local file I. Don't. Want to install there from locally. On my machine for, example or I don't want to configure. It even I can install, it just we have some benefits, of running extension. There but I don't need to run it in environment. That it's just local. Yeah, I can leverage a cloud, shell here so. To get the cloud shell inside, of your, Visual. Studio code, you, need extension, called as your account so. How that works you say ctrl. Shift B to sign, in I already signed in and then you say open bash in, cloud shell when, you say that just. Another. Terminal. Will, show up in, Visual Studio code, isn't. This awesome, so. This is something that runs in a, Linux container, somewhere. In. Azure data, center, and, now, I having, it here, and. It, looks like it's local, it's, just another shell, so, here. When we when we look I have a bash. Which. Is windows. Subsystem for Linux I have. PowerShell. Thanks. To partial extension, and I have every, cloud shell as another. One, just. Beautiful and I also set up my Visual Studio code so, that I can with a keyboard, shortcut run, any, selected, line from. A local, file in. Active. Terminal, it, doesn't matter if the terminal, actually. Exists, on my machine or, is it a cloud shell I can. Send the line over. Wire to, a cloud shell and execute it there. So. Isn't. That just magic. For. Me it is so. Now. We are in a dashing, cloud shop and. Let. Me go to my terraform, files folder and I have all careful. Things. So. I'm now there. Let me run there so. All of those are not, there come, on. I'm. In a Linux, environment. So. You can see I have a this. Terraform. Underscore. As your TF file that I've just shown you that it's local, but I uploaded. To. A. To. A cloud shell and how, you upload it you right do the right click on a tab. And there, is option upload to cloud shell which. Is just beautiful so. The. Beauty of terraform. Is that you have a couple of those. Steps. That you need to perform so, with terraform. In it the telephone, will check your file and see if everything, is available that it's needed are all those providers and modules available to. You so that you can use them so. If I terraform, in it and i'm, running, that with, the keyboard shortcut so that's why you know seeing, that I'm executing this. It. Will initialize. Provider, plugins, check, the environment, see, if everything is there said oh you are fine you, can just continue working. With it okay, after. That comes. Something, that I really miss with our templates something that it's really really cool, the. Telephone, will tell. Me what. Will actually happen. When. I run, tariffs, or apply which is a command for deployment. It's. Kind, of what if in. PowerShell, if you remember, okay so, when, I run tariffs on plan. Let. Me do it again with, the GUI so that you. It. Will. Look. At my file. Look. At the state look. At all the resources they are defined in that, file in them tell me no changes, your infrastructure, is up-to-date. Nothing. WiII happen if, you, actually run, it the.
Beauty Of template, and declarative, approach, with. Building, your infrastructure, is that both, arm templates, and telephone templates, are idempotent. Which means if, you run a, couple. Of times the same template. Nothing. Will be, this. Destroyed. Nothing, will be there. Is no harm in it the. Whole process will actually first check if the resources are there if, they are there they, will be skipped if. There is a change then the change will be applied, but. All, those things that are already there we'll. Stay there where it is in the state they, had before you, actually run it so, in this case if. I. Run. Terraform, apply. What. Will happen is that. They. Will try to. Apply. And then they we see that everything is okay and it was like okay nothing will nothing, will change so. You will get this message apply. Complete. No. Resources, are added not change not destroyed. Once. When you are done with your. Deployment, with your project you don't want to use, it anymore. Destroy. It with the terraform, don't. Go to a portal, or some other tool and delete. Certain, stuff why, because. Then you. Will invalidate. The. Terraform, state this, is how that Tara phone plan works, they. Create, a file that contains the state of your deployment, and this is how they compare, so, if you go outside of a tool and change. It then. That's not the same thing that terraform is aware of right so. Be, aware of that. Another. Tool that I want to mention is ansible. You. Can use ansible, for, infrastructure. Provisioning, but also for configuration, management. Of your VMs, or just. Ad hoc commands that can run against. Those machines one, of the best things here with ansible is that ansible is agentless. So. You don't need to install anything, on your targets. Application. In management. Of those targets are happening. Using the SSH, keys, and, the. Good thing is also. That. Microsoft. Is, involved. In. Porting. The open SSH, to, Windows, as well you already have it now. But we are waiting for the GA of it so. For the future even with a PowerShell the future of remoting, is actually a SSH, not, we know Ram when. You work with the ansible you work with something called playbooks. You put all your tasks, in, a playbooks and you, run the playbook and you get your, infrastructure. So. To. Look at the examples, of how. To, work with the ansible, playbook, to create. A VM. Let. Me show. You here. First. The ansible. Playbook. That. I have so. You. Create a task. To. Create a V you have a task and then you create a VM. You, define a resource, group name for. It the. VM. Size couple, of more details the good thing again here we work with the SSH, keys, so we don't need to provide fasteners, we need we don't need to work. With secrets, that are visible and then you define the image that you will use in this case it's a boon, to machine once. When you have, that file. You. Can then and, in this case of it ansible you need to do a couple of pre steps you need to create, a. Resource. Group and you need to create a network, when. You want to deploy your, virtual. Machine one. Of the things that I really like with the ansible. Extension. In Visual, Studio code, is that if, you have a. Demo. File that contains, the task, open. In your Visual Studio code when. You right-click on, it you. Get a nice, options. Here, you. Can run a playbook in a docker container, they, will pull the container and then run it inside of it you can run it a local, ansible you, can send, the whole file to cloud shell and run, it in a cloud shell which is already pre-configured for, you, or you, can run it remotely over, SSH, so, for. Us. The. Best way to do it is to run, this playbook in a cloud shell so. It will automatically, connect. To your, cloud. Shell bash. Send. Playbook. To. Your cloud. Shell, and. Then start. Deployment, in. This case I'm repeating, deployment, so I don't expect any, changes. To happen if everything works right it, should just work, so. Let's, wait, a little. And, then we should get a final. Report, about. Changes. So. As they said okay, the task is create vm this is how, I'm named the named task and it says okay the, recap is changed, zero unreachable, zero, failed zero. As. I said all those templates, are idempotent. You can run them multiple times nothing will be destroyed if I didn't have it already, provision, we will just go through a couple of those steps -. Okay. So. Summary. For imperative. And hoc, cross platform scripting, use, Azure PowerShell and, azure CLI, for.
Deploying, Using, declarative, model, we have a couple of choices I'm templates. Terraform, and Sybil building blocks for, the whole infrastructure. Management for. VM configurations. Chef, puppet and Sybil DSC. Again. As a cloud shell within Visual Studio code the, best working environment. On Windows. 10. And other or. Mac, or Linux really, this is just amazing, so, infrastructure. Is code plus. Configuration. Is code for. The win that's. The way how you provision, your infrastructure. Thank. You very much for your attention. And. Don't, forget.
2018-10-04 20:36