CreateExportTask 搭配 AWS SDK或 使用 CLI - AWS SDK 程式碼範例

文件範例儲存庫中有更多 AWS SDK可用的範例。 AWS SDK GitHub

本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。

CreateExportTask 搭配 AWS SDK或 使用 CLI

下列程式碼範例示範如何使用 CreateExportTask

.NET
AWS SDK for .NET
注意

還有更多 。 GitHub尋找完整範例,並了解如何在 AWS 程式碼範例儲存庫中設定和執行。

using System; using System.Threading.Tasks; using Amazon.CloudWatchLogs; using Amazon.CloudWatchLogs.Model; /// <summary> /// Shows how to create an Export Task to export the contents of the Amazon /// CloudWatch Logs to the specified Amazon Simple Storage Service (Amazon S3) /// bucket. /// </summary> public class CreateExportTask { public static async Task Main() { // This client object will be associated with the same AWS Region // as the default user on this system. If you need to use a // different AWS Region, pass it as a parameter to the client // constructor. var client = new AmazonCloudWatchLogsClient(); string taskName = "export-task-example"; string logGroupName = "cloudwatchlogs-example-loggroup"; string destination = "amzn-s3-demo-bucket"; var fromTime = 1437584472382; var toTime = 1437584472833; var request = new CreateExportTaskRequest { From = fromTime, To = toTime, TaskName = taskName, LogGroupName = logGroupName, Destination = destination, }; var response = await client.CreateExportTaskAsync(request); if (response.HttpStatusCode == System.Net.HttpStatusCode.OK) { Console.WriteLine($"The task, {taskName} with ID: " + $"{response.TaskId} has been created successfully."); } } }
  • 如需API詳細資訊,請參閱 參考 CreateExportTask中的 。 AWS SDK for .NET API