In Azure, every resource must be assigned to a resource group. In some cases, you may want to set a specific resource group as the default for all new Azure resources.
This can be done with PowerShell. This blog post will show you how to set the Azure default resource group with PowerShell.
Azure AZ PowerShell Module
The Azure AZ PowerShell Module is a module that allows you to manage Azure resources from the PowerShell command line. With this module, you can create and manage Azure resources, including Azure virtual machines, Azure Storage accounts, and Azure SQL Database instances. You can also use the Azure AZ PowerShell Module to manage your Azure subscription settings, such as your Azure subscription name and Azure subscription id.
To install the AZ PowerShell module run
Install-Module -Name Az -AllowClobber -Repository psgallery -Force
After installing the module, you can log in to Azure using PowerShell with the following cmdlet.
Set Default Resource Group
set-azdefault -ResourceGroupName bicep
Let’s go ahead and create a storage account without specifying the resource group parameter.
The cmdlet below creates a storage account, and AZ PowerShell is smart enough to check that a default resource group is set and doesn’t require it.
New-AzStorageAccount -Name 'ntweekly7676' -Location 'southeastasia' -SkuName 'Standard_RAGRS' -Kind 'StorageV2'
For more Azure and Az PowerShell posts, visit the categories below.
Leave a Reply