How to List clusters by subscription ID using .NET?

127 views Asked by At

New to Azure SDK for .NET, can someone help in providing on how to list all clusters in a subscription using subscription ID only. I am trying to bypass using Resource Group to save time.

Previously we could use ContainerServiceClient but the package Microsoft.Azure.Management.ContainerService has been deprecated and I couldn't find an appropriate example using latest package versions

1

There are 1 answers

0
RithwikBojja On

I do agree @Mudit Balooja that using Azure.ResourceManager.Resources we can get clusters as below:

using Azure.Identity;
using Azure.ResourceManager;
using Azure.ResourceManager.ContainerService;
using Azure.ResourceManager.Resources;


ArmClient rithwik_client = new ArmClient(new DefaultAzureCredential());

SubscriptionResource rithwik_subscription = await rithwik_client.GetDefaultSubscriptionAsync();
Console.WriteLine(rithwik_subscription.GetContainerServiceManagedClusters());

Output:

enter image description here