Azure Function App (Linux) Permission Denied

Kai Sor 50 Reputation points
2023-08-29T06:15:41.5633333+00:00

Hello all,

I have a Linux Function App (consumption plan) running selenium in headless chromium. However, when I try to run the function, I receive this error

An error occurred trying to start process '/home/site/wwwroot/chromedriver' with working directory '/'. Permission denied at System.Diagnostics.Process.ForkAndExecProcess(ProcessStartInfo startInfo, String resolvedFilename, String[] argv, String[] envp, String cwd, Boolean setCredentials, UInt32 userId, UInt32 groupId, UInt32[] groups, Int32& stdinFd, Int32& stdoutFd, Int32& stderrFd, Boolean usesTerminal, Boolean throwOnNoExec) at System.Diagnostics.Process.StartCore(ProcessStartInfo startInfo) at System.Diagnostics.Process.Start() at OpenQA.Selenium.DriverService.Start() at OpenQA.Selenium.Remote.DriverServiceCommandExecutor.Execute(Command commandToExecute) at OpenQA.Selenium.WebDriver.Execute(String driverCommandToExecute, Dictionary`2 parameters) at OpenQA.Selenium.WebDriver.StartSession(ICapabilities desiredCapabilities) at OpenQA.Selenium.WebDriver..ctor(ICommandExecutor executor, ICapabilities capabilities) at OpenQA.Selenium.Chromium.ChromiumDriver..ctor(ChromiumDriverService service, ChromiumOptions options, TimeSpan commandTimeout) at OpenQA.Selenium.Chrome.ChromeDriver..ctor(ChromeDriverService service, ChromeOptions options, TimeSpan commandTimeout) at OpenQA.Selenium.Chrome.ChromeDriver..ctor(String chromeDriverDirectory, ChromeOptions options, TimeSpan commandTimeout) at OpenQA.Selenium.Chrome.ChromeDriver..ctor(String chromeDriverDirectory, ChromeOptions options)

I don't think it's a user permission issue as I am the owner of the subscription. When I try to set SCM_DO_BUILD_DURING_DEPLOYMENT = true in Configuration, I get a different error message instead.

An error occurred trying to start process '/home/site/wwwroot/chromedriver' with working directory '/'. No such file or directory at System.Diagnostics.Process.ForkAndExecProcess(ProcessStartInfo startInfo, String resolvedFilename, String[] argv, String[] envp, String cwd, Boolean setCredentials, UInt32 userId, UInt32 groupId, UInt32[] groups, Int32& stdinFd, Int32& stdoutFd, Int32& stderrFd, Boolean usesTerminal, Boolean throwOnNoExec) at System.Diagnostics.Process.StartCore(ProcessStartInfo startInfo) at System.Diagnostics.Process.Start() at OpenQA.Selenium.DriverService.Start() at OpenQA.Selenium.Remote.DriverServiceCommandExecutor.Execute(Command commandToExecute) at OpenQA.Selenium.WebDriver.Execute(String driverCommandToExecute, Dictionary`2 parameters) at OpenQA.Selenium.WebDriver.StartSession(ICapabilities desiredCapabilities) at OpenQA.Selenium.WebDriver..ctor(ICommandExecutor executor, ICapabilities capabilities) at OpenQA.Selenium.Chromium.ChromiumDriver..ctor(ChromiumDriverService service, ChromiumOptions options, TimeSpan commandTimeout) at OpenQA.Selenium.Chrome.ChromeDriver..ctor(ChromeDriverService service, ChromeOptions options, TimeSpan commandTimeout) at OpenQA.Selenium.Chrome.ChromeDriver..ctor(String chromeDriverDirectory, ChromeOptions options, TimeSpan commandTimeout) at OpenQA.Selenium.Chrome.ChromeDriver..ctor(String chromeDriverDirectory, ChromeOptions options)

I've tried using both the windows version chromedriver.exe and the linux version chromedriver

Any help would be greatly appreciated!

Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
3,447 questions
Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
5,644 questions
{count} vote

Accepted answer
  1. navba-MSFT 4,760 Reputation points Microsoft Employee
    2023-09-01T09:57:25.12+00:00

    @Kai Sor Apologies for the late reply. Welcome to Microsoft Q&A Forum, Thank you for posting your query here!

    I understand that you are encountering a "Permission denied" error when trying to run a Linux Function App (consumption plan) that uses Selenium in headless Chromium. You have tried using both the Windows and Linux versions of Chromedriver, but the issue persists. You have also attempted to set SCM_DO_BUILD_DURING_DEPLOYMENT to true in Configuration, but this resulted in a different error message.

    I understand that you are the owner of the subscription.

    1. Ensure that the user running the Function App has the necessary permissions to execute the chromedriver process. You can check the permissions by running the following command in the console:

    ls -l /home/site/wwwroot/chromedriver

    This command will display the permissions for the chromedriver file. Ensure that the user running the Function App has execute permissions for the chromedriver file.

    1. If the user does not have the necessary permissions, you can grant them by running the following command in the console:

    chmod +x /home/site/wwwroot/chromedriver

    This command will grant execute permissions to the chromedriver file for all users.

    Also note that, On Azure function App windows this scenario may not be supported. see here.
    User's image

    However, it should work fine on linux (with custom image) as explained in below articles:

    This article talks about Deploy Azure function with Selenium as Azure Function and How to create a Selenium web scraper in Azure Functions.

    You can also follow this article which helps in installing chromium, chrome driver and selenium on top of the Azure Function base and creating Function using docker image.

    Also refer this article which talks about Executing WebDriver Tests in Chrome via Azure Functions Hosted on Linux Docker Container.

    Hope this helps. If you have any follow-up questions, please let me know. I would be happy to help.

    **
    Please do not forget to "Accept the answer” and “up-vote” wherever the information provided helps you, this can be beneficial to other community members.


0 additional answers

Sort by: Most helpful