The Azure Resouce Group is a logical group of resources that includes virtual machines, databases, web applications, and storage accounts.
This resource group stores metadata about the resources that it contains. The location of the metadata is specified in the “location” part of the resource.
Let’s have a look at the following steps to get Azure resources from the resource group.
Install the latest version of PowerShell. PowerShell 7.0.6 LTS, PowerShell 7.1.3, or higher is recommended by Microsoft.
Check the PowerShell version with the following command:
$PSVersionTable.PSVersion
This yields the information below.
Next, set the Execution Policy
:
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
We can check the execution policy with the following command:
Get-ExecutionPolicy -List
This yields the description below.
Install the Az
module using this command:
Install-Module -Name Az -Scope CurrentUser -Repository PSGallery -Force
Log in to the account with the command below.
It will provide a link to open it in the browser and enter the code provided.
Connect-AzAccount -UseDeviceAuthentication
After a successful login, it will print Account
, SubscriptionName
, TenantId
, and Environment
.
Get Azure resources from a resource group using the following command:
Get-AzResource -ResourceGroupName demo
Get-AzResource
is the cmdlet provided by the Az
module to get a list of Azure resources in a resource group.ResourceGroupName
as a parameter, where we pass the resource group name for which we want to list all the resources under it.