NOTE: Samples in this file apply only to packages that follow Azure SDK Design Guidelines. Names of such packages usually start with Azure
.
You can suppress the exception a service method throws when an error response is returned.
RequestContext context = new RequestContext { ErrorOptions = ErrorOptions.NoThrow };
You can add various types of policies for one request.
Add a policy to set the request header once per pipeline invocation (service call).
var context = new RequestContext();
context.AddPolicy(new AddHeaderPolicy("PerCallHeader", "Value"), HttpPipelinePosition.PerCall);
Add a policy to set the request header every time request is retried.
var context = new RequestContext();
context.AddPolicy(new AddHeaderPolicy("PerRetryHeader", "Value"), HttpPipelinePosition.PerRetry);
Add a policy to set the request header before the request is sent by the transport.
var context = new RequestContext();
context.AddPolicy(new AddHeaderPolicy("BeforeTransportHeader", "Value"), HttpPipelinePosition.BeforeTransport);
You can change the category of response by the returned status code. This can be used to treat error responses as success responses in logging and distributed tracing.
var context = new RequestContext();
context.AddClassifier(404, isError: false);