public async Task ManageAvailabilitySetNow() { #region Snippet:Readme_ManageAvailabilitySetNow ResourceIdentifier resourceId = 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 AvailabilitySetResource resource client from the client // The method takes in a ResourceIdentifier but we can use the implicit cast from string AvailabilitySetResource availabilitySet = client.GetAvailabilitySetResource(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_ManageAvailabilitySetNow }
public async Task ManageAvailabilitySetPieces() { #region Snippet:Readme_ManageAvailabilitySetPieces string subscriptionId = "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"; string resourceGroupName = "workshop2021-rg"; string availabilitySetName = "ws2021availSet"; ResourceIdentifier resourceId = AvailabilitySetResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, availabilitySetName); // We construct a new client to work with ArmClient client = new ArmClient(new DefaultAzureCredential()); // Next we get the AvailabilitySetResource resource client from the client // The method takes in a ResourceIdentifier but we can use the implicit cast from string AvailabilitySetResource availabilitySet = client.GetAvailabilitySetResource(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 }