Services or capabilities described in AWS documentation might vary by Region. To see the differences applicable to the AWS European Sovereign Cloud Region, see the AWS European Sovereign Cloud User Guide.Use CancelExportTask with an AWS SDK
The following code example shows how to use CancelExportTask.
- .NET
-
- SDK for .NET
-
using System;
using System.Threading.Tasks;
using Amazon.CloudWatchLogs;
using Amazon.CloudWatchLogs.Model;
/// <summary>
/// Shows how to cancel an Amazon CloudWatch Logs export task.
/// </summary>
public class CancelExportTask
{
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 taskId = "exampleTaskId";
var request = new CancelExportTaskRequest
{
TaskId = taskId,
};
var response = await client.CancelExportTaskAsync(request);
if (response.HttpStatusCode == System.Net.HttpStatusCode.OK)
{
Console.WriteLine($"{taskId} successfully canceled.");
}
else
{
Console.WriteLine($"{taskId} could not be canceled.");
}
}
}
For a complete list of AWS SDK developer guides and code examples, see
Using CloudWatch Logs with an AWS SDK.
This topic also includes information about getting started and details about previous SDK versions.