首页 > 解决方案 > Azure Static Web App + Azure Function + PuppeteerSharp 给出 UnauthorizedAccessException

问题描述

当我使用使用PuppeteerSharp的Azure 函数将我的Azure 静态 Web 应用程序部署到 Azure 时,我在Application Insights中看到以下错误:

Exception while executing function: ProductsGet Access to the path 'C:\Program Files (x86)\SiteExtensions\Functions\3.3.1\32bit\.local-chromium' is denied.

如果我在本地查看,有一个 'bin\Debug\netcoreapp3.1' 文件夹,其中有一个 '.local-chromium' 文件夹。

我试图更改“.local-chromium”文件夹所在的路径

var tempPath = Path.Combine(rootPath, "bin/.local-chromium");
var browserFetcher = new BrowserFetcher(new BrowserFetcherOptions
                {
                    Path = tempPath
                });
                await browserFetcher.DownloadAsync();
                await using var browser = await Puppeteer.LaunchAsync(
                    new LaunchOptions
                    {
                        Headless = true,
                        ExecutablePath = browserFetcher.RevisionInfo(BrowserFetcher.DefaultChromiumRevision).ExecutablePath
                    }
                );

但这不起作用。使用普通的Azure Functions,我可以使用Kudu查看文件夹结构。Azure 静态 Web 应用程序也可以做到这一点吗?

标签: azure-functionskudupuppeteer-sharpazure-static-web-app

解决方案


推荐阅读