EasmClient.GetTaskAsync 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
GetTaskAsync(String, RequestContext) |
[Protocol Method] Retrieve a task by taskId.
|
GetTaskAsync(String, CancellationToken) |
Retrieve a task by taskId. |
GetTaskAsync(String, RequestContext)
- Source:
- EasmClient.cs
[Protocol Method] Retrieve a task by taskId.
- This protocol method allows explicit creation of the request and processing of the response for advanced scenarios.
- Please try the simpler GetTaskAsync(String, CancellationToken) convenience overload with strongly typed models first.
public virtual System.Threading.Tasks.Task<Azure.Response> GetTaskAsync (string taskId, Azure.RequestContext context);
abstract member GetTaskAsync : string * Azure.RequestContext -> System.Threading.Tasks.Task<Azure.Response>
override this.GetTaskAsync : string * Azure.RequestContext -> System.Threading.Tasks.Task<Azure.Response>
Public Overridable Function GetTaskAsync (taskId As String, context As RequestContext) As Task(Of Response)
Parameters
- taskId
- String
The unique identifier of the task.
- 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
taskId
is null.
taskId
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 GetTaskAsync and parse the result.
Uri endpoint = new Uri("<https://my-service.azure.com>");
TokenCredential credential = new DefaultAzureCredential();
EasmClient client = new EasmClient(endpoint, credential);
Response response = await client.GetTaskAsync("<taskId>", null);
JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
Console.WriteLine(result.GetProperty("id").ToString());
This sample shows how to call GetTaskAsync with all parameters and parse the result.
Uri endpoint = new Uri("<https://my-service.azure.com>");
TokenCredential credential = new DefaultAzureCredential();
EasmClient client = new EasmClient(endpoint, credential);
Response response = await client.GetTaskAsync("<taskId>", null);
JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
Console.WriteLine(result.GetProperty("id").ToString());
Console.WriteLine(result.GetProperty("startedAt").ToString());
Console.WriteLine(result.GetProperty("completedAt").ToString());
Console.WriteLine(result.GetProperty("lastPolledAt").ToString());
Console.WriteLine(result.GetProperty("state").ToString());
Console.WriteLine(result.GetProperty("phase").ToString());
Console.WriteLine(result.GetProperty("reason").ToString());
Console.WriteLine(result.GetProperty("metadata").GetProperty("<key>").ToString());
Applies to
GetTaskAsync(String, CancellationToken)
- Source:
- EasmClient.cs
Retrieve a task by taskId.
public virtual System.Threading.Tasks.Task<Azure.Response<Azure.Analytics.Defender.Easm.TaskResource>> GetTaskAsync (string taskId, System.Threading.CancellationToken cancellationToken = default);
abstract member GetTaskAsync : string * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Azure.Response<Azure.Analytics.Defender.Easm.TaskResource>>
override this.GetTaskAsync : string * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Azure.Response<Azure.Analytics.Defender.Easm.TaskResource>>
Public Overridable Function GetTaskAsync (taskId As String, Optional cancellationToken As CancellationToken = Nothing) As Task(Of Response(Of TaskResource))
Parameters
- taskId
- String
The unique identifier of the task.
- cancellationToken
- CancellationToken
The cancellation token to use.
Returns
Exceptions
taskId
is null.
taskId
is an empty string, and was expected to be non-empty.
Examples
This sample shows how to call GetTaskAsync.
Uri endpoint = new Uri("<https://my-service.azure.com>");
TokenCredential credential = new DefaultAzureCredential();
EasmClient client = new EasmClient(endpoint, credential);
Response<TaskResource> response = await client.GetTaskAsync("<taskId>");
This sample shows how to call GetTaskAsync with all parameters.
Uri endpoint = new Uri("<https://my-service.azure.com>");
TokenCredential credential = new DefaultAzureCredential();
EasmClient client = new EasmClient(endpoint, credential);
Response<TaskResource> response = await client.GetTaskAsync("<taskId>");
Applies to
Azure SDK for .NET