Azure PowerShell Tutorial

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments

I've been teaching myself powershell, primarily because I'm an azure user and I find the Gui is somewhat lacking for various tasks I require.

Powershell... is the same deal.

I'm actually a little bit amazed at the complete disconnect microsoft has when designing these tools.

You want to do what? oh... you can't use the Gui for that, you need to use Powershell. Oh but this other thing you're trying to do, that doesn't exist in powershell, you have to use the API.

What do you mean you don't have all 3 interfaces completely memorized?

👍︎︎ 10 👤︎︎ u/Lanko 📅︎︎ Nov 26 2019 🗫︎ replies
Captions
when it comes to task automation and operations management scripting language like PowerShell is an amazing tool in hands of any administrator today I will show you introduction into Azure PowerShell a powerful tool for management of our resources stay tuned [Music] so let's start with partial what is partial it's a scripting language delivered by Microsoft to allow you for easy task automation and configuration management it's a comment line shell interface where you run a simple commands and control your environment and with recent introduction of partial core you can also run it on Mac OS or Linux because it was made cross-platform in August 2016 each task in partial is executed by something called command let's each common led contains something called verb this verb describes what action will be taken for instance gate process retrieves a list of processes drawn path joins and multiple strings into singular one and connect PowerShell session you can probably figure this out on your own because a well-designed comment let will tell you what if they will do without you needing to check for documentation and of course all those common let's our permit tries to ensure that you can actually write anything that you need by simply using parameters and what is a sure partial in this case it's a set of common lies that microsoft delivered to allow you to manage your other resources directly from the powershell the common scenarios for this are pretty much the same as for CLI since day to day operations like automation of repetitive tasks scheduling deployments DevOps scenarios maybe you're just learning then partial is also great because of a dot all the intellisense and all the documentation that is behind it and last but not least achieving things that are hard otherwise and what I mean here is that usually you want to create multiple resources at the same time or maybe interconnect those resources together on the runtime and because some of their property we'll be created dynamically partial is great for those kind of scenarios and what are the basics of course when you will go to Google and you will start searching for stuff around argent partial you will find both Arthur Aaron and AZ modules and for you to understand its author Aaron which is shorthand for Asha Resource Management is the old modules and the new modules are called AZ there are no different modules it's just the renamed version of the modules from some version so moving forward the new modules are recommended and the installation is very simple simply run two commands and you ready to go so what happens if you found other Aram scripts on the internet or some blogs or you already have some old modules can you upgrade yes you can because there's a compatibility comment light which allows you to install the new modules but still run that old other Aram scripts effectively so you simply run enable other Ihram Aaliyah's and your old comments will be analyzed for the new ones so you can simply run it without any hiccups so what are the demos for today first of all I will show you how to install it how simple the installation is then I'm gonna show you the simple commands I'm gonna log into Azure I'm gonna give you overview of the comments and gonna be listing and querying resources I'm gonna show you how to pipe the parameters and outputs in partial for some more advanced scenarios then we're gonna do a simple demo where I will create a resource group and virtual machines using partial and lastly I will show you some tools including PowerShell in a cloud shell so let's move forward so this is a simple virtual machine that I created measure to show you the installation of partial you simply need to open windows hit on PowerShell run it as administrator and you need to run the command so let's open at full screen and paste the command and now just simply import those modules after importing is completed you can start typing connect AZ and as you see I hit control space and it filled it in that means everything seems to be working just fine and this is how simple the installation goes so let's go to the portal for a second first of all notice what kind of research group that I have I have five research groups and I'll have only very few resources like my storage accounts and the virtual machine that we just used for this demo and this is what we're going to be working with today so let's go to partial this is the normal windows partial window that every one of us has on our machines so in order to connect to a sure you need to run a simple command called connect and when you will start typing like Khan you can already press control space to get intellisense so control space and as you see you get all possible options and the control connect a easy account is the one that we want you press Enter you type - and again you can hit control space to get all the parameters available to this connect AZ account fortunately Connect AZ account doesn't require any so I can just press escape and hit control and actually enter and now I need to login of course so Adam mark truck IO I need to select my account because I have to under same ID and I need to provide a password once I'm logged in successfully you will see my account information my subscription name and my environment now he successfully connected to other using our account first of all you always can confirm what kind of account you are kunti working on I type in get AZ and this is the keyword every single comment right after the verb will have AZ prefix so you know like new AZ get AC select AZ everything with an azure modules is followed by this prefix so to get the current session it up get a Zeke on and let's see what kind of options do we have and the one we want is get a Z context using this command you can see what kind of environment you are logged in right now and one of the important things about partial and CLI in general is that all the comments are working on a single subscription at the time so if you're working with very with many subscriptions remember to run a comment at first that is called select a Z sub description and provide a subscription name and type your subscription name in my case that would be Visual Studio Enterprise and PN this will make sure that this is the current subscription that you're invoking all the commands on this is especially important if you're creating resource groups because you don't want to create them on incorrect subscription so what next first of all let's try to list the resource groups that we just seen to do that you need to type get so get means return a Z as always the prefix and Reis let's see what kind of options we have enters a resource group here hit enter and as you see those are all the resource groups that we have on the subscription what can you do with this first of all you can do a lot but to do a lot you need to actually start using something called pipes this is a pipe this allows you to grab the output of the command into another command and in power so this is a very powerful feature to get a lot of advanced features and for instance what you can do is type format table and instead of that list you're gonna get the table you can do of course format list this will return almost the same stuff you can do format wide which is like a simpler version of what it is seen but what is interesting is that you can also type for instance export export CSV to export your outputs from the previous command directly into CSV this is one of very good ways to do operations and auditing what is also cool is that you can do out grid view which will simply make a pop up on your screen that you can actually start selecting an amazing stuff about this is if you add additional parameter called pass-through it will allow you to grab this output to the screen and notice that when I do do it now and I select let's say free subscriptions as free resource groups and hit OK on the bottom notice that I got free subscriptions and snell put this way you can make interactive sessions for users to run using partial very easily and automate your other based on your needs what else can you do well as you can imagine when you run resource groups you are provided with a lot of information maybe you don't want all of those information for the next school comments to do that you just again pipe and type select and in select of course control space will see what is the result from the previous command and allow you to select what kind of cones do you want so I want resource group name and maybe a location so this is like an SQL query when you do it you get a subset of the previous response with only the columns that you want you can also do filtering to do filter you just type where object filtering is a bit more complicated because you need to provide an expression function which goes like this dollar underscore is the current object dot what kind of property we are filtering on let's say we're filtering on location and what kind of filter do we want let's say dash equals and what do we want to be equals to let's say North Europe and simply run it and as you see we got only resource groups from North Europe and of course piping allows you to pipe everything together so you can use again select resource resource group name and location and filter and select at the same time very powerful feature a lot of stuff that you can do with it so take a full advantage of it remember for brevity in you can also do moved line so just type this and it's a tick sign again tick sign and you can remove the line scripting to get them more consistent and more easy to read from the perspective of the maintenance now that we know how partial works we can actually go and start creating a real demo in this time I'm gonna create a research group and in that research group I'm gonna create a virtual machine so let's do that so first of all to create a new research group who need the type verb new and followed by a Z for the modules grist for the research group find a new eysie research group command type - control space name same gonna call it am demo - control space location space and control space to get the list of the regions so in my case that will be north europe and hit enter this will create an AM demo research group in north Europe location now that I have my location I can use that to create a new virtual machine so of course new NZ VM control space as you see there's a comment like that so I'm gonna use it space - and what do we need to provide I know we need to provide a research group name that's gonna be am demo - what else do we need to provide a location so again space control space I want this also to be north Europe again space - control space and what I need to provide is a name the name is here I'm gonna call it VM demo and - control space I know that also need to provide an image send image control space and as I see a list of available images like boom - LTS if everything will work here we can already create this virtual machine so let's try that as you see it's said that I didn't provide everything and that was intended because what I need also to provide is a CC supply values for the following parameters credential I didn't provide credentials for this VM so I need to do that so I'm gonna called a.m. demo admin and provide any kind of password and hit enter that's actually very good in partial that whenever you don't supply all the parameters it will ask you for all the missing required parameters and as you see it's currently creating a virtual machine in order for me so let's wait for that and it's done as you see creating virtual machine using partial is very easy we can of course go back to the portal to confirm it's there so we can open our resource groups panel see our new am demo resource group and see the VM demo that we just created that was super simple and it just required us to comments we can of course clear the screen and continue working of course besides Windows PowerShell you have more options when it comes to tooling first of all you can use PowerShell ISE integrated shell environment which first of all gives you a text editor the so multi-tab experience where you can create multiple scripts save them load them shell comment on the bottom and the list of available resources and of course as you see you get also intelligence here or just by typing here connect AZ and as you see as soon as it recognizes the comments it will also give you the intellisense experience and you can do much more powerful scripts here because it's a full script environment you just press ctrl s and everything is saved besides ISC you can also use Visual Studio code so in Visual Studio code you'll get a similar experience as soon as your file is of ps1 extension or on the bottom you have selected language for partial you can also start using PowerShell commands and you also will get intelligence connect AZ right that's amazing I prefer Visual Studio code from all of the tools that I'm using I'm using it the most but it's up to preference whatever you like to use and of course when it comes to partial you can do a lot of stuff and what kind of stuff let's do a demo where we gonna create a 10 storage accounts at the same time very easily very fast so first of all we need a variable called RG which will contain a resource group name for us 10 schools gonna be am demo we're gonna make a for each loop in which we're gonna eat right for 10 times and that's actually double dot and open brackets so from one to ten we're gonna create a new storage account that means we find the slope we need to type new AZ storage account and of course - rhesus group name we need to provide this dollar RG - we need to provide it a name and that's gonna be a.m. demo storage and then dollar E so this will append the iteration number so it's going to be aimed mo storage one a m-- demo storage two three four up to ten and next we need to provide an SKU named control space in our case that's going to be standard al RS because those are the fastest wants to be created again - we need to provide also location and that's going to be for us control space to get the list of locations and I want north Europe actually I wanted North Europe here North Europe and not to wait for each storage account to be created in a loop you can also add - a stop parameter which means they will run in the background if you want to make it nicer you stick signs to break a line again here again here again here again here this looks much better and you simply select everything press f8 and run the script and everything runs in parallel this is how easy it is to run PowerShell commands in parallel in order and if we go back to portal and start refreshing in just couple of seconds we're gonna start seeing our storage accounts being created so let's wait for a second as you see within just minutes we roll the script that created ten storage accounts identical configuration very easily very fast this is how powerful their script is and the very last demo that I have for you to take is cloud shell cloud shell allows you to run PowerShell in a cloud directly from your browser and you can do it but twofold you can either press this button to open a cloud shell window let me do that you can actually scroll it up a little bit and it requires you to mount the storage this is because as you can imagine when running those comments some temporary files must be created and to do so you need to have a storage to mount the storage to the cloud shell you need to click show Advanced Options select the resource group where your storage will be residing you can for instance select am demo that we just created you can use existing storage account or you can create a new one I'm gonna call it AM demo store one and I'm gonna copy that same here this will create a new storage account for the purpose of the cloud shell only after this is created we can simply run the comments so let's skip ahead so the clouds initialize but the first thing you'll notice this is not actually PowerShell it's CII and to change the partials simply hit this button and click partial confirm and it will switch cloud shell to run PowerShell of course we can increase the fund if you want to get large one and we can run the partial commands very first thing that you will notice that you don't have to run connect AC account because this inherits your session from the browser so simply typing now get AC resource source root presenter and you get resource group without any login in it's not ideal experience as it's not as good as in Visual Studio code or ice see or even partial common line but if you don't want to install anything you're maybe working remotely cloud soul is amazing alternative that allows you to run partial very easily and of course couple things to notice you can also run it it by using shell calm to get a full screen session of the CLI and partial as well in the cloud shell and here of course it's still picking up as a soul so it's logging you into Azure without you running any comments and you can simply start writing comments like usual so get NZ resource group and you get all the resource group you can type alas to excel local storage and Qadir demo to create folders if you need or what's amazing you can type code doubt to get the local editor that looks like a Visual Studio code and allowing you to write scripts in a browser directly here and run them from the cloud shell this is how great it is quick recommendation you shall utter come for demos quick scripts quick demos may be quick auditing but usually I recommend you to great fool that experience that Visual Studio gives your ISC because it gets more intelligence more natural feel integration of kit so it's much better in the long run this is a good for very quick stuff or training even there is so much more than you can do with PowerShell parallel processing extensions integration of dotnet operation management tasks automation process automation integrating with other other services like other functions or other automation pretty much the possibilities are endless it's up to you to integrate cover your scenarios and ultimate pretty much anything you are doing for your daily operations that's it for today here the thumbs up leave a comment subscribe if you want to see more and see you next time [Music]
Info
Channel: Adam Marczak - Azure for Everyone
Views: 43,170
Rating: 4.9632607 out of 5
Keywords: Azure, PowerShell, CliudShell, Command Line Interface, Scripting, DevOps, Operations, Automation
Id: LbGNQVbb_VI
Channel Id: undefined
Length: 22min 46sec (1366 seconds)
Published: Tue Nov 26 2019
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.