JavaScript 应用程序的源映射支持Source map support for JavaScript applications

Application Insights 支持将源映射上传到你自己的存储帐户 Blob 容器。Application Insights supports the uploading of source maps to your own Storage Account Blob Container. 源映射可用于取消缩小在端到端事务详细信息页上找到的调用堆栈。Source maps can be used to unminify call stacks found on the end to end transaction details page. JavaScript SDKNode.js SDK 发送的任何异常都可以通过源映射来取消缩小。Any exception sent by the JavaScript SDK or the Node.js SDK can be unminified with source maps.

通过与存储帐户链接来取消缩小调用堆栈

新建存储帐户和 Blob 容器Create a new storage account and Blob container

如果已有存储帐户或 blob 容器,则可以跳过此步骤。If you already have an existing storage account or blob container, you can skip this step.

  1. 新建存储帐户Create a new storage account
  2. 在存储帐户中创建 Blob 容器Create a blob container inside your storage account. 请务必将“公共访问级别”设置为 Private,以确保你的源映射不可公开访问。Be sure to set the "Public access level" to Private, to ensure that your source maps are not publicly accessible.

容器访问级别必须设置为“专用”Your container access level must be set to Private

使用源映射存储帐户配置 Application Insights 资源Configure your Application Insights resource with a Source Map storage account

从“端到端事务详细信息”页From the end-to-end transaction details page

可以在“端到端事务详细信息”选项卡中单击“取消缩小”,在资源未配置的情况下,它会显示配置提示。From the end-to-end transaction details tab, you can click on Unminify and it will display a prompt to configure if your resource is unconfigured.

  1. 在门户中,查看已缩小异常的详细信息。In the Portal, view the details of an exception that is minified.
  2. 单击“取消缩小”Click on Unminify
  3. 如果资源尚未配置,则会显示一条消息,提示你进行配置。If your resource has not been configured, a message will appear, prompting you to configure.

从“属性”页From the properties page

如果要配置或更改已链接到 Application Insights 资源的存储帐户或 Blob 容器,可以通过查看 Application Insights 资源的“属性”选项卡来完成此操作。If you would like to configure or change the storage account or Blob container that is linked to your Application Insights Resource, you can do it by viewing the Application Insights resource's Properties tab.

  1. 导航到 Application Insights 资源的“属性”选项卡。Navigate to the Properties tab of your Application Insights resource.
  2. 单击“更改源映射 blob 容器”。Click on Change source map blob container.
  3. 选择与源映射容器不同的 Blob 容器。Select a different Blob container as your source maps container.
  4. 单击 ApplyClick Apply.

通过导航到“属性”边栏选项卡,重新配置所选的 Azure Blob 容器Reconfigure your selected Azure Blob Container by navigating to the Properties Blade

故障排除Troubleshooting

Blob 容器中所需的基于角色的访问控制 (RBAC) 设置Required role-based access control (RBAC) settings on your Blob container

门户上使用此功能的任何用户都必须至少作为存储 Blob 数据读取者分配给 Blob 容器。Any user on the Portal using this feature must be at least assigned as a Storage Blob Data Reader to your Blob container. 你必须将此角色分配给要通过此功能使用源映射的任何其他人。You must assign this role to anyone else that will be using the source maps through this feature.

备注

此角色可能尚未自动分配给你或你的团队,具体取决于容器的创建方式。Depending on how the container was created, this may not have been automatically assigned to you or your team.

找不到源映射Source map not found

  1. 验证相应的源映射是否已上传到正确的 blob 容器Verify that the corresponding source map is uploaded to the correct blob container
  2. 验证源映射文件是否以它映射到的 JavaScript 文件命名,并以 .map 为后缀。Verify that the source map file is named after the JavaScript file it maps to, suffixed with .map.
    • 例如,/static/js/main.4e2ca5fa.chunk.js 将搜索名为 main.4e2ca5fa.chunk.js.map 的 Blob。For example, /static/js/main.4e2ca5fa.chunk.js will search for the blob named main.4e2ca5fa.chunk.js.map
  3. 检查浏览器的控制台,看是否记录了任何错误。Check your browser's console to see if any errors are being logged. 在任何支持票证中包含此错误信息。Include this in any support ticket.