Azure / Azure/azure-rest-api-specs-examples

TenantResource.GetReservationOrders() not working for hybrid benefit reservation

Open
#3,309 0 comments 0 reactions 1 assignee Claimed by @live1206 View on GitHub
customer-reported question
Dominant language
No language data
Stars
40
Forks
23
Avg merge
23h 36m
Merged PRs (30d)
172

Description

### Link to sample

https://learn.microsoft.com/en-us/rest/api/reserved-vm-instances/reservation/list?tabs=dotnet

### Library name and version

Azure.ResourceManager.Reservations (1.3.0)

### Language of the Sample

- [X] C#/.NET
- [ ] Java
- [ ] JavaScript/TypedScript
- [ ] Python
- [ ] Golang
- [ ] Other - Please specify in Issue details field

### Sample Issue Type

- [X] Sample not working
- [ ] Sample missing
- [ ] Do not understand sample

### Issue details

1) Outer loop -> GetReservationOrders: App gets all reservation orders, does some filtering
````
var orderCollection = tenantResource.GetReservationOrders().GetAllAsync();
await foreach (ReservationOrderResource orderResource in orderCollection)
{
.......
}
````
=> working as expected.
2) Then, Inner loop: For all ReservationOrders returned , app gets all ReservationDetails
````
var reservationDetailCollection = orderResource.GetReservationDetails();
await foreach (ReservationDetailResource reservationDetailResource in reservationDetailCollection.GetAllAsync())
{
.......
}
````
=> working as expected for all ReservationOrders EXCEPT reservation is a Hybrid Benefit reservation. In this case an exception is thrown

### Expected behavior

GetReservationDetails() working for all types of reservation

### Actual behavior

If a reservation order is a hybrid benefit reservation an exception is thrown:

````
"Exception":"System.ArgumentException: Value cannot be an empty string. (Parameter 'resourceId')
at Azure.Core.Argument.AssertNotNullOrEmpty(String value, String name)
at Azure.Core.ResourceIdentifier..ctor(String resourceId)
at Azure.ResourceManager.Reservations.Models.ReservationProperties.DeserializeReservationProperties(JsonElement element)
at Azure.ResourceManager.Reservations.ReservationDetailData.DeserializeReservationDetailData(JsonElement element)
at Azure.ResourceManager.Reservations.ReservationDetailCollection.b__7_2(JsonElement e)
at Azure.Core.PageableHelpers.PageableImplementation`1.GetAsyncEnumerator(CancellationToken cancellationToken)+MoveNext()
at Azure.Core.PageableHelpers.PageableImplementation`1.GetAsyncEnumerator(CancellationToken cancellationToken)+System.Threading.Tasks.Sources.IValueTaskSource.GetResult()
at .... await foreach from inner loop above
````

** Note**: For all other reservations (78) everything works as expected => looks like deserializing this type of reservation fails

### Reproduction Steps

For obvious reasons i cannot share credentials for TenantResource here..
But problem can be reproduced by using example code and only change:
``Guid reservationOrderId = Guid.Parse("276e7ae4-84d0-4da6-ab4b-d6b94f3557da");``
with a reservation order Guid that references a hybrid benefit reservation resource.

### Environment

Linux Container on AKS
.NET Core 6.0 LTS
Visual Studio CE 2022, 17.6.5

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.