我们将很快记录这一点。与此同时,您需要做的是以下事情。您需要安装 nuget 包 Microsoft.Azure.AppService.ApiApps.Service。然后,创建一个委托处理程序,如下所示:
class InternalCredentialHandler : DelegatingHandler
{
protected override Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
{
Runtime.FromAppSettings(request).SignHttpRequest(request);
return base.SendAsync(request, cancellationToken);
}
}
然后,当您使用 HttpClient 或生成的客户端连接到另一个内部 API 时,只需传入委托处理程序即可。例如:
MySampleClient client = new MySampleClient(new DelegatingHandler[] { new InternalCredentialHandler() });
谢谢,莫希特
编辑:此文档现在可在https://azure.microsoft.com/documentation/articles/app-service-api-dotnet-consume-internal/