Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Azure Resource Manager - Get all the resources of a resource group

Yesterday, I was using this line of code with the version 1.5.0-preview of Microsoft.Azure.Management.ResourceManager :

var listResources = 
ResourceManagementClient.ResourceGroups.ListResources(resourceGroup.Name);

Today, I have updated to version 1.6.0-preview but the fonction doesn't seem to be available anymore. Is there another way to get the list of the resources contained in a resource group ?

like image 867
Elodie Avatar asked May 03 '17 10:05

Elodie


People also ask

How do I check all resources in Azure?

The All resources screen in the Azure portal includes a link to open a Resource Graph query that is scoped to the current filtered view. To run a Resource Graph query: Select Open query. In Azure Resource Graph Explorer, select Run query to see the results.

Can Azure resources access resources in other resource groups?

A resource can connect to resources in other resource groups. This scenario is common when the two resources are related but don't share the same lifecycle. For example, you can have a web app that connects to a database in a different resource group.

Do resources inherit resource Group tags?

Inherit tags Resources don't inherit the tags you apply to a resource group or a subscription.

How to see all resources assigned under a resource group in azure?

Summary : Use the Azure Resource Manager cmdlets to show resources that are assigned under a resource group. I looked at the console for Azure Resource Manager and can see all the resources for a particular resource group.

How do I lock resources in Azure Resource Manager?

To prevent a resource group and its resources from being deleted, use az lock create. To get the locks for a resource group, use az lock list. For more information, see Lock resources with Azure Resource Manager. You can apply tags to resource groups and resources to logically organize your assets.

What is Azure Resource Manager?

Azure Resource Manager enables you to repeatedly deploy your app and have confidence your resources are deployed in a consistent state. You define the infrastructure and dependencies for your app in a single declarative template. This template is flexible enough to use for all of your environments such as test, staging or production.

How do I deploy resources in azure?

You can deploy Azure resources by using Azure CLI, or by deploying an Azure Resource Manager (ARM) template or Bicep file. The following example creates a storage account. The name you provide for the storage account must be unique across Azure. To deploy an ARM template or Bicep file, use az deployment group create.


Video Answer


1 Answers

Now the SDK is still preview version. In the 1.6.0 preview version. It should use following code.

   var listResources = resourceManagementClient.Resources.ListByResourceGroup("ResourceGroup Name");

But it still can't work correctly on my side because the API-Version is api-version=2017-05-10. I catch the request with fiddler.

enter image description here

The code you mentioned that use API-version

var listResources = 
ResourceManagementClient.ResourceGroups.ListResources(resourceGroup.Name);

enter image description here

Note : Please still use 1.5.0-preview instead of 1.6.0-preview currently if you want get group resource, or give your feedback to azure sdk team . Or you can use REST API directly

like image 101
Tom Sun - MSFT Avatar answered Oct 07 '22 19:10

Tom Sun - MSFT