public async Task UpdateAvailabilitySet() { #region Snippet:Managing_Availability_Set_UpdateAnAvailabilitySet // 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); // availabilitySet is an AvailabilitySet instance created above AvailabilitySetUpdate update = new AvailabilitySetUpdate() { PlatformFaultDomainCount = 3 }; AvailabilitySet updatedAvailabilitySet = await availabilitySet.UpdateAsync(update); #endregion Snippet:Managing_Availability_Set_UpdateAnAvailabilitySet }
public async Task AddTagToAvailabilitySet() { #region Snippet:Managing_Availability_Set_AddTagAvailabilitySet // 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(); string rgName = "myRgName"; ResourceGroup resourceGroup = await rgContainer.GetAsync(rgName); AvailabilitySetContainer availabilitySetContainer = resourceGroup.GetAvailabilitySets(); string availabilitySetName = "myAvailabilitySet"; AvailabilitySet availabilitySet = await availabilitySetContainer.GetAsync(availabilitySetName); // add a tag on this availabilitySet AvailabilitySet updatedAvailabilitySet = await availabilitySet.AddTagAsync("key", "value"); #endregion Snippet:Managing_Availability_Set_AddTagAvailabilitySet }
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 }