예제 #1
0
 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 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_ManageAvailabilitySetNow
 }
예제 #2
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 armClient to work with
     ArmClient armClient = new ArmClient(new DefaultAzureCredential());
     // Next we get the AvailabilitySet resource client from the armClient
     // The method takes in a ResourceIdentifier but we can use the implicit cast from string
     AvailabilitySet availabilitySet = armClient.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
 }