Beispiel #1
0
        public async Task GettingSpecificSubscriptionAsync()
        {
            #region Snippet:Hello_World_Async_SpecificSubscription
            string    subscriptionId             = "your-subscription-id";
            ArmClient client                     = new ArmClient(new DefaultAzureCredential());
            SubscriptionCollection subscriptions = client.GetSubscriptions();
            SubscriptionResource   subscription  = await subscriptions.GetAsync(subscriptionId);

            Console.WriteLine(subscription.Id);
            #endregion Snippet:Hello_World_Async_SpecificSubscription
        }
Beispiel #2
0
 public async Task ManageAvailabilitySetOld()
 {
     #region Snippet:Readme_ManageAvailabilitySetOld
     ResourceIdentifier id = new ResourceIdentifier("/subscriptions/aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee/resourceGroups/workshop2021-rg/providers/Microsoft.Compute/availabilitySets/ws2021availSet");
     // We construct a new client to work with
     ArmClient client = new ArmClient(new DefaultAzureCredential());
     // Next we get the collection of subscriptions
     SubscriptionCollection subscriptions = client.GetSubscriptions();
     // Next we get the specific subscription this resource belongs to
     Subscription subscription = await subscriptions.GetAsync(id.SubscriptionId);
     // Next we get the collection of resource groups that belong to that subscription
     ResourceGroupCollection resourceGroups = subscription.GetResourceGroups();
     // Next we get the specific resource group this resource belongs to
     ResourceGroup resourceGroup = await resourceGroups.GetAsync(id.ResourceGroupName);
     // Next we get the collection of availability sets that belong to that resource group
     AvailabilitySetCollection availabilitySets = resourceGroup.GetAvailabilitySets();
     // Finally we get the resource itself
     // Note: for this last step in this example, Azure.ResourceManager.Compute is needed
     AvailabilitySet availabilitySet = await availabilitySets.GetAsync(id.Name);
     #endregion Snippet:Readme_ManageAvailabilitySetOld
 }