How to make screenshot from Azure DevOps extension?

Dmitry Baranov 0 Reputation points
2025-05-16T07:53:29.54+00:00

I'm developing an Azure DevOps extension that requires screenshot functionality. While implementing this feature, I've encountered an issue with the Browser Screen Capture API, which works well in standard web applications but fails in my Azure DevOps extension.

When the Browser Screen Capture API is invoked within my extension, I receive the following error: "Screen capture failed: Failed to execute 'getDisplayMedia' on 'MediaDevices': Access to the feature 'display-capture' is disallowed by permissions policy."

I believe this occurs because the extension is integrated into Azure DevOps using an iframe, which restricts the use of the Browser Screen Capture API due to security policies. Is there a way to configure these restrictions to allow screen capture functionality?

Alternatively, would it be possible to leverage the Test & Feedback browser extension for this screenshot capability?

Azure DevOps
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Michele Ariis 760 Reputation points MVP
    2025-05-16T09:06:00.0066667+00:00

    Hi, The getDisplayMedia() method fails inside an Azure DevOps extension because the code runs within one or more sandboxed iframes that inherit restrictive headers and attributes (Permissions-Policy and sandbox) which block display-capture; for screen capture to work, every level (including the top document and all nested iframes) must explicitly allow display-capture, but in Azure DevOps Services you cannot modify these headers or iframe attributes as they are controlled by Microsoft's frontend, so the only practical solution is to open a top-level pop-up window where you can safely call getDisplayMedia(), or rely on a separate browser extension, or use built-in tools like Test & Feedback or Test Plans, while the only exception is in on-prem Azure DevOps Server where you could manually patch the iframe markup, although this is unsupported and requires maintenance after every update.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.