elastic / elastic/beats

Fork sdk/resourcemanager/consumption/armconsumption package to address SDK problems

Open
#37,151 1 comment 0 reactions 1 assignee Claimed by @zmoog View on GitHub
Team:Cloud-Monitoring
Dominant language
Go
Stars
12.7k
Forks
5k
Avg merge
2d 2h
Merged PRs (30d)
364

Description

This issues keeps track of the changes to the fork of https://github.com/Azure/azure-sdk-for-go/ needed to address a couple of problems with the generated clients.

The fork is available at https://github.com/elastic/azure-sdk-for-go/ and contains fixes to two problems:

- Date range query does not work on MCA accounts
- Query parameters are not URL encoded in the 'next link' value

## Problems
### Date range query does not work on MCA accounts

According to the MS [docs](https://learn.microsoft.com/en-us/azure/cost-management-billing/costs/manage-automation#get-usage-details-for-a-scope-during-specific-date-range), modern customers with a Microsoft Customer Agreement (MCA) must use the `StartDate` and `EndDate` query parameters to get the usage details for a specific date range.

#### Root cause

Unfortunately, the [API spec](https://github.com/Azure/azure-rest-api-specs/blob/main/specification/consumption/resource-manager/Microsoft.Consumption/stable/2023-11-01/consumption.json#L106-L147) does include these query parameters, so we are manually adding them to the generated client.

If we don't add the query parameters, MCA users will get (many more)
usage details items outside the intended time range.

#### Solutions or workaround

We [added](https://github.com/Azure/azure-sdk-for-go/commit/2678471bd61f999dc00ae3cc7739d2bf9f1c2987) the `StartDate` and `EndDate` query parameters to the generated SDK.

### Query parameters are not URL encoded in the 'next link' value

#### Root cause

When there are more than 1000 usage details items, the Consumption SDK paginates the response. Each response page contains a 'next link' to the following page.

The `$filter` query parameters contain a date range expression like the following:

```text
properties/usageStart eq '2023-11-16' and properties/usageEnd eq '2023-11-16'
```

Unfortunately, the Azure service adds the query parameters value to the 'next link' without encoding them. Since one of the parameters, `$filter` contains space, it breaks the URL, causing the following parameters to get lost.

#### Solutions or workaround

We added a [small patch](https://github.com/Azure/azure-sdk-for-go/commit/2c5e6af954e25067c056e791f4571b48d3f72433) to our fork that URL encodes the next link value and avoids the 400 error.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.