playwright-dotnet: Azure Function .Net Core 3.1 - Failed to launch chromium because executable doesn't exist

I published a simple example to Azure Function (Windows) and I got the error:

Failed to launch chromium because executable doesn’t exist at C:\local\LocalAppData\ms-playwright\chromium-833159\chrome-win\chrome.exe Try re-installing the browsers running playwright-cli.exe install in windows or playwright-cli install in MacOS or Linux. Note: pass debug: "pw:api" to LaunchAsync to capture Playwright logs.

Any idea how to fix this? Thank you!

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 15 (4 by maintainers)

Most upvoted comments

I don’t think it’s possible with Azure Functions. Use VM.

While we’re working on getting the scenario documented and working, you can use a docker container: https://docs.microsoft.com/en-us/azure/azure-functions/functions-create-function-linux-custom-image?tabs=bash%2Cportal&pivots=programming-language-csharp

as long as you have ran playwright install it should work.

But this is something we’re working on.

I’d second this. I keep getting a message complaining that it can’t find the playwright driver in the bin folder, despite it being there. I use Linux on deployed and WSL/Windows locally and get the same message everywhere, but my unit test project doesn’t seem to have a problem finding and using playwright

copying the .playwright folder in the \bin\Debug\net6.0\bin folder did the trick for me. The output folder structure of an azure function is different. Currently Microsoft.PlayWright.targets indicates it will only copy to the standard build output folder, which is understandable. I have added the following to my .csproj:

  <Target Name="PlaywrightCopyAfterBuild" AfterTargets="Build">
    <ItemGroup>
      <_BuildCopyItems Include="$(OutDir).playwright\**" />
    </ItemGroup>
    <Message Text="[Fix] Copying files to the nested bin folder of the azure function... $(OutDir)bin" Importance="high"/>
    <Copy SourceFiles="@(_BuildCopyItems)" DestinationFiles="@(_BuildCopyItems->'$(OutDir)bin\.playwright\%(RecursiveDir)%(Filename)%(Extension)')"/>
  </Target>