Example #1
0
 public async Task ManageAvailabilitySetPieces()
 {
     #region Snippet:Readme_ManageAvailabilitySetPieces
     string subscriptionId = "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee";
     string resourceGroupName = "workshop2021-rg";
     string availabilitySetName = "ws2021availSet";
     ResourceIdentifier resourceId = AvailabilitySet.CreateResourceIdentifier(subscriptionId, resourceGroupName, availabilitySetName);
     // We construct a new client to work with
     ArmClient client = new ArmClient(new DefaultAzureCredential());
     // Next we get the AvailabilitySet resource client from the client
     // The method takes in a ResourceIdentifier but we can use the implicit cast from string
     AvailabilitySet availabilitySet = client.GetAvailabilitySet(resourceId);
     // At this point availabilitySet.Data will be null and trying to access it will throw
     // If we want to retrieve the objects data we can simply call get
     availabilitySet = await availabilitySet.GetAsync();
     // we now have the data representing the availabilitySet
     Console.WriteLine(availabilitySet.Data.Name);
     #endregion Snippet:Readme_ManageAvailabilitySetPieces
 }