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

[Sample Issue] Workspace Purge

Open
#2,768 0 comments 0 reactions 1 assignee Claimed by @ArcturusZhang View on GitHub
customer-reported needs-triage 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/loganalytics/workspace-purge/purge?tabs=dotnet

### Library name and version

Azure.ResourceManager.OperationalInsights 1.1.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

The samples are assigning filter values using `BinaryData.FromString`, this usage is incorrect and causes serialisation errors. The code summary for the `Value` field on `OperationalInsightsWorkspacePurgeFilter` explains the usage correctly and `BinaryData.FromObjectAsJson` should be used in these examples.

### Expected behavior

Expected behaviour is that the code sample would work when replacing values and updating the filter.

### Actual behavior

Actual behaviour is that the code sample errors with a serialisation error due to incorrect usage.

### Reproduction Steps

Use the code snippet as is, with the example filter of
```
new()
{
Column = "_ResourceId",
Operator = "==",
Value = BinaryData.FromString("/subscriptions/12341234-1234-1234-1234-123412341234/resourceGroups/SomeResourceGroup/providers/microsoft.insights/components/AppInsightResource"),
}
```

This will result in the serialisation error `'/' is an invalid start of a value. LineNumber: 0 | BytePositionInLine: 0.`

### Environment

Windows 11
Visual Studio 2022
dotnet 6

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.