{"id":78205,"date":"2016-05-25T00:01:42","date_gmt":"2016-05-25T07:01:42","guid":{"rendered":"https:\/\/blogs.technet.microsoft.com\/heyscriptingguy\/?p=78205"},"modified":"2019-02-18T09:10:45","modified_gmt":"2019-02-18T16:10:45","slug":"work-with-the-azurerm-cmdlets-part-3","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/scripting\/work-with-the-azurerm-cmdlets-part-3\/","title":{"rendered":"Work with the Azure Resource Manager cmdlets \u2013 Part 3"},"content":{"rendered":"<p><strong>Summary<\/strong>: Create and access resource groups with the AzureRM cmdlets.<\/p>\n<p>This blog post is part of a series about how to work with the Azure Resource Manager cmdlets. To get the most out of this series, read the posts in order.<\/p>\n<ul>\n<li><a href=\"https:\/\/blogs.technet.microsoft.com\/heyscriptingguy\/2016\/05\/23\/work-with-the-azurerm-cmdlets-part-1\/\">Work with the Azure Resource Manager cmdlets \u2013 Part 1<\/a><\/li>\n<li><a href=\"https:\/\/blogs.technet.microsoft.com\/heyscriptingguy\/2016\/05\/24\/work-with-the-azurerm-cmdlets-part-2\/\">Work with the Azure Resource Manager cmdlets \u2013 Part 2<\/a><\/li>\n<li>Work with the Azure Resource Manager cmdlets \u2013 Part 3<\/li>\n<li><a href=\"https:\/\/blogs.technet.microsoft.com\/heyscriptingguy\/2016\/05\/26\/work-with-the-azure-resource-manager-cmdlets-part-4\/\">Work with the Azure Resource Manager cmdlets \u2013 Part 4<\/a><\/li>\n<li><a href=\"https:\/\/blogs.technet.microsoft.com\/heyscriptingguy\/2016\/05\/27\/work-with-the-azure-resource-manager-cmdlets-part-5\/\">Work with the Azure Resource Manager cmdlets \u2013 Part 5<\/a><\/li>\n<\/ul>\n<p>After you finish this series, move on to the next two series to learn more about the Azure Resource Manager cmdlets.<\/p>\n<ul>\n<li><a href=\"https:\/\/blogs.technet.microsoft.com\/heyscriptingguy\/2016\/05\/30\/retrieve-azure-resource-manager-virtual-machine-properties-by-using-powershell-part-1\/\">Retrieve Azure Resource Manager virtual machine properties by using PowerShell<\/a><\/li>\n<li><a href=\"https:\/\/blogs.technet.microsoft.com\/heyscriptingguy\/2016\/06\/06\/create-azure-resource-manager-virtual-machines-by-using-powershell-part-1\/\">Create Azure Resource Manager virtual machines by using PowerShell<\/a><\/li>\n<\/ul>\n<p><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/q-for-powertip.jpg\" alt=\"Hey, Scripting Guy! Question\" \/>\u00a0I\u2019m happily sitting here logged into Azure with the AzureRM cmdlets and would like to start with resource groups.\u00a0 Could you show me where to start?<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/a-for-powertip.jpg\" alt=\"Hey, Scripting Guy! Answer\" \/>\u00a0Honorary Scripting Guy, Sean Kearney, is here again. Yesterday we discovered how to automate authentication to Azure Resource Manager. Today we\u2019re going to start to make this useful by creating resource groups.<\/p>\n<p>A resource group is one of the most important pieces in Resource Manager. It\u2019s the entity that ties a group of virtual machines, network structure, and various resources together as a management group. This allows you to assign resources to a user or group or\u00a0to delegate responsibility.<\/p>\n<p>Resource groups are the most basic way to\u00a0have your development, production and quality assurance environments all on the same subscription with unique users or groups managing them. Because Resource Manager supports Role-Based Access Control (RBAC), you can give the development team Full Access to their environment in a subscription by assigning them Full Access to their resource group.<\/p>\n<p>Pretty cool eh?<\/p>\n<p>Before we do this in PowerShell, let\u2019s see how to do this in Azure in general.<\/p>\n<p>I am now presently signed\u00a0in to the Azure portal. I would like to create a new resource group.<\/p>\n<p>First, I need to select <strong>New<\/strong> to start the wizard from the Azure Portal. This will open the following screen. I find it easiest on a new subscription to just type <em>resource<\/em> in the search pane and let Azure do all the work for me.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/1-HSG-052516.png\"><img decoding=\"async\" class=\"alignnone size-full wp-image-78207\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/1-HSG-052516.png\" alt=\"Screenshot of search for resource group.\" width=\"579\" height=\"210\" \/><\/a><\/p>\n<p>As you can see, it\u2019s prompting me with <em>Resource group<\/em> as an option. When I can click <em>Resource group<\/em>, the following pane expands to the right.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/2-HSG-052516.png\"><img decoding=\"async\" class=\"alignnone size-full wp-image-78215\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/2-HSG-052516.png\" alt=\"Screenshot that shows results that are scoped to items that match \u201cresource group.\u201d\" width=\"549\" height=\"164\" \/><\/a><\/p>\n<p>From here, I click <strong>Resource group<\/strong> to start the wizard.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/3-HSG-052516.png\"><img decoding=\"async\" class=\"alignnone size-full wp-image-78225\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/3-HSG-052516.png\" alt=\"Screenshot of the start of the resource group wizard.\" width=\"583\" height=\"309\" \/><\/a><\/p>\n<p>The wizard prompts for three key pieces to create a resource group.<\/p>\n<ul>\n<li>Name<\/li>\n<li>Subscription (The wizard will populate with your currently selected one.)<\/li>\n<li>Location (East US, Canada Central, Japan East, and so on)<\/li>\n<\/ul>\n<p>Select <strong>Create<\/strong> to begin to create the resource group.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/4-HSG-052516.png\"><img decoding=\"async\" class=\"alignnone size-full wp-image-78235\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/4-HSG-052516.png\" alt=\"Screenshot of the resource group wizard where you add a name, subscription, and location.\" width=\"346\" height=\"395\" \/><\/a><\/p>\n<p>A lovely little notification lets you know that things are happening in the background.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/5-HSG-052516.png\"><img decoding=\"async\" class=\"alignnone size-full wp-image-78237\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/5-HSG-052516.png\" alt=\"Screenshot that shows that has a message that says that a resource group was created.\" width=\"418\" height=\"168\" \/><\/a><\/p>\n<p>So, after all, not a difficult process. But, I prefer to use PowerShell\u00a0so that I can\u00a0do all of this in bulk.<\/p>\n<p>To create a resource group with the AzureRM cmdlets, we need to authenticate (as we showed you in <a href=\"https:\/\/blogs.technet.microsoft.com\/heyscriptingguy\/2016\/05\/24\/work-with-the-azurerm-cmdlets-part-2\/\" target=\"_blank\">Part 2<\/a>) and then provide the same information to the <strong>New-AzureRMResourceGroup<\/strong> cmdlet.<\/p>\n<p>The nice part is that the cmdlet only really needs the name and the location because it will obtain the subscription from the Azure-RMAccount Object.<\/p>\n<p style=\"padding-left: 30px\"><code>$Name=\u2019HSG-AzureRG\u2019<\/code><\/p>\n<p style=\"padding-left: 30px\"><code>$Location=\u2019East US\u2019<\/code><\/p>\n<p style=\"padding-left: 30px\"><code>New-AzureRMResourceGroup \u2013Name $Name \u2013location $Location<\/code><\/p>\n<p>Yup, three little lines instead of a bunch of mouse clicks. Check things tomorrow when we see how to create our storage account.<\/p>\n<p>I invite you to follow the Scripting Guys on <a href=\"http:\/\/bit.ly\/scriptingguystwitter\" target=\"_blank\">Twitter<\/a> and <a href=\"http:\/\/bit.ly\/scriptingguysfacebook\" target=\"_blank\">Facebook<\/a>. If you have any questions, send email to them at <a href=\"mailto:scripter@microsoft.com\" target=\"_blank\">scripter@microsoft.com<\/a>, or post your questions on the <a href=\"http:\/\/bit.ly\/scriptingforum\" target=\"_blank\">Official Scripting Guys Forum<\/a>. See you tomorrow.<\/p>\n<p>Until then always remember that with Great PowerShell comes Great Responsibility.<\/p>\n<p><strong>Sean Kearney<\/strong>\nHonorary Scripting Guy\nCloud and Datacenter Management MVP<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Summary: Create and access resource groups with the AzureRM cmdlets. This blog post is part of a series about how to work with the Azure Resource Manager cmdlets. To get the most out of this series, read the posts in order. Work with the Azure Resource Manager cmdlets \u2013 Part 1 Work with the Azure [&hellip;]<\/p>\n","protected":false},"author":596,"featured_media":87096,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[568,641],"tags":[56,154,45],"class_list":["post-78205","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-hey-scripting-guy","category-windows-powershell","tag-guest-blogger","tag-sean-kearney","tag-windows-powershell"],"acf":[],"blog_post_summary":"<p>Summary: Create and access resource groups with the AzureRM cmdlets. This blog post is part of a series about how to work with the Azure Resource Manager cmdlets. To get the most out of this series, read the posts in order. Work with the Azure Resource Manager cmdlets \u2013 Part 1 Work with the Azure [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/78205","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/users\/596"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/comments?post=78205"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/78205\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/media\/87096"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/media?parent=78205"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/categories?post=78205"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/tags?post=78205"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}