调用 Web API 的 Web API:移到生产环境A web API that calls web APIs: Move to production

获取调用 Web API 的令牌后,将应用程序移动到生产环境时,需要考虑以下事项。After you've acquired a token to call web APIs, here are some things to consider when moving your application to production.

启用日志记录Enable logging

为了帮助对调试和身份验证失败进行故障排除,Microsoft 身份验证库提供了内置的日志记录支持。To help in debugging and authentication failure troubleshooting scenarios, the Microsoft Authentication Library provides built-in logging support. 以下文章介绍了如何对每个库进行日志记录:Logging is each library is covered in the following articles:

一些数据收集建议如下:Here are some suggestions for data collection:

  • 用户在有问题时可能会寻求帮助。Users might ask for help when they have problems. 最佳做法是捕获日志并将其临时存储。A best practice is to capture and temporarily store logs. 提供一个供用户上传日志的位置。Provide a location where users can upload the logs. MSAL 提供日志记录扩展来捕获有关身份验证的详细信息。MSAL provides logging extensions to capture detailed information about authentication.

  • 如果遥测可用,请通过 MSAL 启用它,以收集有关用户如何登录应用的数据。If telemetry is available, enable it through MSAL to gather data about how users sign in to your app.

验证你的集成Validate your integration

按照 Microsoft 标识平台集成清单测试你的集成。Test your integration by following the Microsoft identity platform integration checklist.

后续步骤Next steps

既然你已了解了如何从自己的 Web API 调用 Web API 的基础知识,你可能会对下一个教程感兴趣,它介绍了用于构建调用 Web API 的受保护 Web API 的代码。Now that you know the basics of how to call web APIs from your own web API, you might be interested in the following tutorial, which describes the code that's used to build a protected web API that calls web APIs.

示例Sample 平台Platform 说明Description
active-directory-aspnetcore-webapi-tutorial-v2 第 1 章active-directory-aspnetcore-webapi-tutorial-v2 chapter 1 ASP.NET Core Web API、桌面 (WPF)ASP.NET Core web API, Desktop (WPF) ASP.NET Core Web API 会调用你使用 Microsoft 标识平台从 WPF 应用程序调用的 Microsoft Graph。ASP.NET Core web API calls Microsoft Graph, which you call from a WPF application by using the Microsoft identity platform.