다음을 통해 공유


LogsIngestionClient.Upload Method

Definition

Overloads

Upload(String, String, RequestContent, String, RequestContext)

[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.
Upload<T>(String, String, IEnumerable<T>, LogsUploadOptions, CancellationToken)

Ingestion API used to directly ingest data using Data Collection Rules.

Upload(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 Azure.Response Upload (string ruleId, string streamName, Azure.Core.RequestContent content, string contentEncoding = default, Azure.RequestContext context = default);
abstract member Upload : string * string * Azure.Core.RequestContent * string * Azure.RequestContext -> Azure.Response
override this.Upload : string * string * Azure.Core.RequestContent * string * Azure.RequestContext -> Azure.Response
Public Overridable Function Upload (ruleId As String, streamName As String, content As RequestContent, Optional contentEncoding As String = Nothing, Optional context As RequestContext = Nothing) As 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 Upload.

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 = client.Upload("<ruleId>", "<streamName>", content);

Console.WriteLine(response.Status);

This sample shows how to call Upload 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 = client.Upload("<ruleId>", "<streamName>", content, contentEncoding: "<contentEncoding>");

Console.WriteLine(response.Status);

Remarks

See error response code and error response message for more detail.

Applies to

Upload<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 Azure.Response Upload<T> (string ruleId, string streamName, System.Collections.Generic.IEnumerable<T> logs, Azure.Monitor.Ingestion.LogsUploadOptions options = default, System.Threading.CancellationToken cancellationToken = default);
abstract member Upload : string * string * seq<'T> * Azure.Monitor.Ingestion.LogsUploadOptions * System.Threading.CancellationToken -> Azure.Response
override this.Upload : string * string * seq<'T> * Azure.Monitor.Ingestion.LogsUploadOptions * System.Threading.CancellationToken -> Azure.Response
Public Overridable Function Upload(Of T) (ruleId As String, streamName As String, logs As IEnumerable(Of T), Optional options As LogsUploadOptions = Nothing, Optional cancellationToken As CancellationToken = Nothing) As 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.

Applies to