Exemple #1
0
        public async Task DeleteAvailabilitySet()
        {
            #region Snippet:Managing_Availability_Set_DeleteAnAvailabilitySet
            // First, initialize the ArmClient and get the default subscription
            ArmClient armClient = new ArmClient(new DefaultAzureCredential());
            // Now we get a ResourceGroup container for that subscription
            Subscription           subscription = armClient.DefaultSubscription;
            ResourceGroupContainer rgContainer  = subscription.GetResourceGroups();

            // With the container, we can create a new resource group with an specific name
            string        rgName        = "myRgName";
            ResourceGroup resourceGroup = await rgContainer.GetAsync(rgName);

            AvailabilitySetContainer availabilitySetContainer = resourceGroup.GetAvailabilitySets();
            string          availabilitySetName = "myAvailabilitySet";
            AvailabilitySet availabilitySet     = await availabilitySetContainer.GetAsync(availabilitySetName);

            // delete the availability set
            await availabilitySet.DeleteAsync();

            #endregion Snippet:Managing_Availability_Set_DeleteAnAvailabilitySet
        }