DeidentificationClient.DeidentifyAsync 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
DeidentifyAsync(DeidentificationContent, CancellationToken) |
De-identify text. |
DeidentifyAsync(RequestContent, RequestContext) |
[Protocol Method] De-identify text.
|
DeidentifyAsync(DeidentificationContent, CancellationToken)
- Source:
- DeidentificationClient.cs
De-identify text.
public virtual System.Threading.Tasks.Task<Azure.Response<Azure.Health.Deidentification.DeidentificationResult>> DeidentifyAsync (Azure.Health.Deidentification.DeidentificationContent body, System.Threading.CancellationToken cancellationToken = default);
abstract member DeidentifyAsync : Azure.Health.Deidentification.DeidentificationContent * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Azure.Response<Azure.Health.Deidentification.DeidentificationResult>>
override this.DeidentifyAsync : Azure.Health.Deidentification.DeidentificationContent * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Azure.Response<Azure.Health.Deidentification.DeidentificationResult>>
Public Overridable Function DeidentifyAsync (body As DeidentificationContent, Optional cancellationToken As CancellationToken = Nothing) As Task(Of Response(Of DeidentificationResult))
Parameters
Request body for de-identification operation.
- cancellationToken
- CancellationToken
The cancellation token to use.
Returns
Exceptions
body
is null.
Examples
This sample shows how to call DeidentifyAsync.
Uri endpoint = new Uri("<https://my-service.azure.com>");
TokenCredential credential = new DefaultAzureCredential();
DeidentificationClient client = new DeidentificationClient(endpoint, credential);
DeidentificationContent body = new DeidentificationContent("<inputText>");
Response<DeidentificationResult> response = await client.DeidentifyAsync(body);
This sample shows how to call DeidentifyAsync with all parameters.
Uri endpoint = new Uri("<https://my-service.azure.com>");
TokenCredential credential = new DefaultAzureCredential();
DeidentificationClient client = new DeidentificationClient(endpoint, credential);
DeidentificationContent body = new DeidentificationContent("<inputText>")
{
Operation = OperationType.Redact,
DataType = DocumentDataType.Plaintext,
RedactionFormat = "<redactionFormat>",
};
Response<DeidentificationResult> response = await client.DeidentifyAsync(body);
Remarks
A remote procedure call (RPC) operation.
Applies to
DeidentifyAsync(RequestContent, RequestContext)
- Source:
- DeidentificationClient.cs
[Protocol Method] De-identify text.
- This protocol method allows explicit creation of the request and processing of the response for advanced scenarios.
- Please try the simpler DeidentifyAsync(DeidentificationContent, CancellationToken) convenience overload with strongly typed models first.
public virtual System.Threading.Tasks.Task<Azure.Response> DeidentifyAsync (Azure.Core.RequestContent content, Azure.RequestContext context = default);
abstract member DeidentifyAsync : Azure.Core.RequestContent * Azure.RequestContext -> System.Threading.Tasks.Task<Azure.Response>
override this.DeidentifyAsync : Azure.Core.RequestContent * Azure.RequestContext -> System.Threading.Tasks.Task<Azure.Response>
Public Overridable Function DeidentifyAsync (content As RequestContent, Optional context As RequestContext = Nothing) As Task(Of Response)
Parameters
- content
- RequestContent
The content to send as the body of the request.
- 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
content
is null.
Service returned a non-success status code.
Examples
This sample shows how to call DeidentifyAsync and parse the result.
Uri endpoint = new Uri("<https://my-service.azure.com>");
TokenCredential credential = new DefaultAzureCredential();
DeidentificationClient client = new DeidentificationClient(endpoint, credential);
using RequestContent content = RequestContent.Create(new
{
inputText = "<inputText>",
});
Response response = await client.DeidentifyAsync(content);
JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
Console.WriteLine(result.ToString());
This sample shows how to call DeidentifyAsync with all request content and parse the result.
Uri endpoint = new Uri("<https://my-service.azure.com>");
TokenCredential credential = new DefaultAzureCredential();
DeidentificationClient client = new DeidentificationClient(endpoint, credential);
using RequestContent content = RequestContent.Create(new
{
inputText = "<inputText>",
operation = "Redact",
dataType = "Plaintext",
redactionFormat = "<redactionFormat>",
});
Response response = await client.DeidentifyAsync(content);
JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
Console.WriteLine(result.GetProperty("outputText").ToString());
Console.WriteLine(result.GetProperty("taggerResult").GetProperty("entities")[0].GetProperty("category").ToString());
Console.WriteLine(result.GetProperty("taggerResult").GetProperty("entities")[0].GetProperty("offset").GetProperty("utf8").ToString());
Console.WriteLine(result.GetProperty("taggerResult").GetProperty("entities")[0].GetProperty("offset").GetProperty("utf16").ToString());
Console.WriteLine(result.GetProperty("taggerResult").GetProperty("entities")[0].GetProperty("offset").GetProperty("codePoint").ToString());
Console.WriteLine(result.GetProperty("taggerResult").GetProperty("entities")[0].GetProperty("length").GetProperty("utf8").ToString());
Console.WriteLine(result.GetProperty("taggerResult").GetProperty("entities")[0].GetProperty("length").GetProperty("utf16").ToString());
Console.WriteLine(result.GetProperty("taggerResult").GetProperty("entities")[0].GetProperty("length").GetProperty("codePoint").ToString());
Console.WriteLine(result.GetProperty("taggerResult").GetProperty("entities")[0].GetProperty("text").ToString());
Console.WriteLine(result.GetProperty("taggerResult").GetProperty("entities")[0].GetProperty("confidenceScore").ToString());
Console.WriteLine(result.GetProperty("taggerResult").GetProperty("path").ToString());
Console.WriteLine(result.GetProperty("taggerResult").GetProperty("etag").ToString());
Applies to
Azure SDK for .NET