Пример #1
0
        public async Task ListAllResourceGroups()
        {
            #region Snippet:Managing_Resource_Groups_ListAllResourceGroup
            // First, initialize the ArmClient and get the default subscription
            ArmClient    armClient    = new ArmClient(new DefaultAzureCredential());
            Subscription subscription = await armClient.GetDefaultSubscriptionAsync();

            // Now we get a ResourceGroup collection for that subscription
            ResourceGroupCollection rgCollection = subscription.GetResourceGroups();
            // With GetAllAsync(), we can get a list of the resources in the collection
            await foreach (ResourceGroup rg in rgCollection.GetAllAsync())
            {
                Console.WriteLine(rg.Data.Name);
            }
            #endregion Snippet:Managing_Resource_Groups_ListAllResourceGroup
        }