I am trying to use Azure Functions with Python with a consumption plan to scrape a web page using Selenium with Firefox. For the way it is going to be used, it is much more practical (and cheaper) to use a consumption plan, which means I can NOT use a Docker container.
So far I have been able to successfully include and path the binary files for Firefox along with the geckodriver
binary file. I am getting the following error:
1571952497758 mozrunner::runner INFO Running command: "/home/site/wwwroot/SharedCode/bin/firefox/firefox" "-marionette" "--headless" "-foreground" "-no-remote" "-profile" "/tmp/rust_mozprofileFyNhwV"
XPCOMGlueLoad error for file /home/site/wwwroot/SharedCode/bin/firefox/libmozgtk.so:
libgtk-3.so.0: cannot open shared object file: No such file or directory
Couldn't load XPCOM.
I was under the impression that Firefox/Selenium did not need GTK if is running in headless mode (it is):
webdriver_options = selenium.webdriver.firefox.options.Options()
webdriver_options.binary_location = str( (pathlib.Path(__file__).parent / "../bin/firefox/firefox").resolve() )
webdriver_options.add_argument("--headless")
webdriver = selenium.webdriver.Firefox(executable_path=str( (pathlib.Path(__file__).parent / "../bin/geckodriver").resolve() ), firefox_options=webdriver_options)
This can be remedied just by installing GTK3. Is there any way to install packages with apt-get
on an Azure Functions App without Docker?
You will not be able to run Selenium on Azure Functions. It runs in an App Service container which is a secure environment that has the limitation of not supporting GDI or installing packages as this would make it serverfull and not serverless. Because of this apt-get is unsupported without the use of a custom image.
Recommendations would be to move out of a consumption plan or to a low tier BS-series virtual machine.
This link at the bottom shows selenium as unsupported.
https://github.com/projectkudu/kudu/wiki/Azure-Web-App-sandbox#unsupported-frameworks
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With