LogsIngestionClient.UploadAsync Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Overloads
UploadAsync(String, String, RequestContent, String, RequestContext) |
[Protocol Method] Ingestion API used to directly ingest data using Data Collection Rules
|
UploadAsync<T>(String, String, IEnumerable<T>, LogsUploadOptions, CancellationToken) |
Ingestion API used to directly ingest data using Data Collection Rules. |
UploadAsync(String, String, RequestContent, String, RequestContext)
- Source:
- LogsIngestionClient.cs
- Source:
- LogsIngestionClient.cs
[Protocol Method] Ingestion API used to directly ingest data using Data Collection Rules
- This protocol method allows explicit creation of the request and processing of the response for advanced scenarios.
public virtual System.Threading.Tasks.Task<Azure.Response> UploadAsync (string ruleId, string streamName, Azure.Core.RequestContent content, string contentEncoding = default, Azure.RequestContext context = default);
abstract member UploadAsync : string * string * Azure.Core.RequestContent * string * Azure.RequestContext -> System.Threading.Tasks.Task<Azure.Response>
override this.UploadAsync : string * string * Azure.Core.RequestContent * string * Azure.RequestContext -> System.Threading.Tasks.Task<Azure.Response>
Public Overridable Function UploadAsync (ruleId As String, streamName As String, content As RequestContent, Optional contentEncoding As String = Nothing, Optional context As RequestContext = Nothing) As Task(Of Response)
Parameters
- ruleId
- String
The immutable Id of the Data Collection Rule resource.
- streamName
- String
The streamDeclaration name as defined in the Data Collection Rule.
- content
- RequestContent
The content to send as the body of the request.
- contentEncoding
- String
If content is already gzipped, put "gzip". Default behavior is to gzip all input.
- context
- RequestContext
The request context, which can override default behaviors of the client pipeline on a per-call basis.
Returns
The response returned from the service.
Exceptions
ruleId
, streamName
or content
is null.
ruleId
or streamName
is an empty string, and was expected to be non-empty.
Service returned a non-success status code.
Examples
This sample shows how to call UploadAsync.
Uri endpoint = new Uri("<endpoint>");
TokenCredential credential = new DefaultAzureCredential();
LogsIngestionClient client = new LogsIngestionClient(endpoint, credential);
using RequestContent content = RequestContent.Create(new object[]
{
new object()
});
Response response = await client.UploadAsync("<ruleId>", "<streamName>", content);
Console.WriteLine(response.Status);
This sample shows how to call UploadAsync with all parameters and request content.
Uri endpoint = new Uri("<endpoint>");
TokenCredential credential = new DefaultAzureCredential();
LogsIngestionClient client = new LogsIngestionClient(endpoint, credential);
using RequestContent content = RequestContent.Create(new object[]
{
new object()
});
Response response = await client.UploadAsync("<ruleId>", "<streamName>", content, contentEncoding: "<contentEncoding>");
Console.WriteLine(response.Status);
Remarks
See error response code and error response message for more detail.
Applies to
UploadAsync<T>(String, String, IEnumerable<T>, LogsUploadOptions, CancellationToken)
- Source:
- LogsIngestionClient.cs
- Source:
- LogsIngestionClient.cs
Ingestion API used to directly ingest data using Data Collection Rules.
public virtual System.Threading.Tasks.Task<Azure.Response> UploadAsync<T> (string ruleId, string streamName, System.Collections.Generic.IEnumerable<T> logs, Azure.Monitor.Ingestion.LogsUploadOptions options = default, System.Threading.CancellationToken cancellationToken = default);
abstract member UploadAsync : string * string * seq<'T> * Azure.Monitor.Ingestion.LogsUploadOptions * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Azure.Response>
override this.UploadAsync : string * string * seq<'T> * Azure.Monitor.Ingestion.LogsUploadOptions * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Azure.Response>
Public Overridable Function UploadAsync(Of T) (ruleId As String, streamName As String, logs As IEnumerable(Of T), Optional options As LogsUploadOptions = Nothing, Optional cancellationToken As CancellationToken = Nothing) As Task(Of Response)
Type Parameters
- T
Parameters
- ruleId
- String
The immutable Id of the Data Collection Rule resource.
- streamName
- String
The streamDeclaration name as defined in the Data Collection Rule.
- logs
- IEnumerable<T>
The content to send as the body of the request. Details of the request body schema are in the Remarks section below.
- options
- LogsUploadOptions
The options model to configure the request to upload logs to Azure Monitor.
- cancellationToken
- CancellationToken
Returns
The response returned from the service.
Exceptions
ruleId
, streamName
or logs
is null.
ruleId
or streamName
is an empty string, and was expected to be non-empty.
Service returned a non-Success status code.
Examples
This sample shows how to call Upload with required parameters and request content.
var credential = new DefaultAzureCredential();
var endpoint = new Uri("<https://my-account-name.azure.com>");
var client = new LogsIngestionClient(endpoint, credential);
var data = new[] {
new {}
};
Response response = client.Upload("<ruleId>", "<streamName>", data);
Console.WriteLine(response.Status);
Remarks
See error response code and error response message for more detail.