你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn

LogsIngestionClient.Upload 方法

定义

重载

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

[协议方法]用于使用数据收集规则直接引入数据的引入 API

  • 协议方法 允许显式创建请求并处理高级方案的响应。
Upload<T>(String, String, IEnumerable<T>, LogsUploadOptions, CancellationToken)

用于使用数据收集规则直接引入数据的引入 API。

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

Source:
LogsIngestionClient.cs
Source:
LogsIngestionClient.cs

[协议方法]用于使用数据收集规则直接引入数据的引入 API

  • 协议方法 允许显式创建请求并处理高级方案的响应。
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

参数

ruleId
String

数据收集规则资源的不可变 ID。

streamName
String

数据收集规则中定义的 streamDeclaration 名称。

content
RequestContent

要作为请求正文发送的内容。

contentEncoding
String

如果内容已 gzipped,则输入“gzip”。 默认行为是对所有输入进行 gzip。

context
RequestContext

请求上下文,可以基于每个调用替代客户端管道的默认行为。

返回

从服务返回的响应。

例外

ruleIdstreamNamecontent 为 null。

ruleIdstreamName 是空字符串,预期为非空。

服务返回了非成功状态代码。

示例

此示例演示如何调用 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);

此示例演示如何使用所有参数和请求内容调用 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, contentEncoding: "<contentEncoding>");

Console.WriteLine(response.Status);

注解

有关更多详细信息,请参阅错误响应代码和错误响应消息。

适用于

Upload<T>(String, String, IEnumerable<T>, LogsUploadOptions, CancellationToken)

Source:
LogsIngestionClient.cs
Source:
LogsIngestionClient.cs

用于使用数据收集规则直接引入数据的引入 API。

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

类型参数

T

参数

ruleId
String

数据收集规则资源的不可变 ID。

streamName
String

数据收集规则中定义的 streamDeclaration 名称。

logs
IEnumerable<T>

要作为请求正文发送的内容。 请求正文架构的详细信息,请参阅下面的“备注”部分。

options
LogsUploadOptions

用于配置将日志上传到 Azure Monitor 的请求的选项模型。

cancellationToken
CancellationToken

返回

从服务返回的响应。

例外

ruleIdstreamNamelogs 为 null。

ruleIdstreamName 是空字符串,预期为非空。

服务返回了非成功状态代码。

示例

此示例演示如何使用所需的参数和请求内容调用 Upload。

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);

注解

有关更多详细信息,请参阅错误响应代码和错误响应消息。

适用于