Yituo
Yituo

Reputation: 1566

Azure Resource Manager Template: Is there a way to get all resourceId/resourceName of a resource type under a Resource Group?

I wonder if there is a way to get all resources of a particular type under a resource group?

Upvotes: 0

Views: 241

Answers (2)

4c74356b41
4c74356b41

Reputation: 72151

you can use resourceId() function for that for a single resource:

"[resourceId('otherResourceGroup', 'Microsoft.Storage/storageAccounts', 'examplestorage')]"

https://learn.microsoft.com/en-us/azure/azure-resource-manager/resource-group-template-functions-resource#resourceid

this is not possible for ALL the resources in the resource group unless you know their names beforehand and use resourceId function for each one individually

or you could use external scripts, like the other answer suggests

Upvotes: 1

Stanley Gong
Stanley Gong

Reputation: 12153

Yes, the easiest way to do it is using powershell , try the command below :

Get-AzResource -ResourceGroupName <resource group name>| where {$_.ResourceType -eq <resource type>}  |select Name , ResourceId 

Result for demo : enter image description here

Hope it helps .

Upvotes: 1

Related Questions