question

SampatVarun-0080 avatar image
4 Votes"
SampatVarun-0080 asked AxelVantWesteinde-1259 answered

Microsoft App Service Error: 'version `GLIBC_2.29' not found' while importing pyodbc for a Flask App

Hello,

I had an existing (and fully functioning) App Service (AS) running a Flask App until one day the web app service randomly broke. When I opened the logs for the AS, this is what I found:

58140-screenshot-2021-01-19-at-12214-pm.png

Here's the error message:

ImportError: /lib/x86_64-linux-gnu/libm.so.6: version `GLIBC_2.29' not found (required by /home/site/wwwroot/antenv/lib/python3.7/site-packages/pyodbc.cpython-37m-x86_64-linux-gnu.so)

A few important things:

  • The app runs locally without any errors

  • I have not made any changes to the configuration for the AS.

  • The app had been running just fine for almost 6 months (I had pyodbc in my requirements.txt)

  • I saw a few similar questions on Azure QnA but they were either too old or running a Windows VM or confusing.

I really hope to get some clarity on this topic ASAP. Please let me know if any more details are required!

Thank you in advance!

azure-webapps
· 3
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi @SampatVarun-0080,

Can you drop your requirements.txt? Also, if you look at the properties of your site, either through App Service vsix or https://resources.azure.com, what is linuxFxVersion, pythonVersion set to? What SKU is your app service plan?

Regards,
Ryan




0 Votes 0 ·

Hi Ryan,

According to https://resources.azure.com :

  • linuxFxVersion is PYTHON|3.7

  • pythonVersion is null

  • App service plan is a Premium V2 (P2v2: 1)

  • requirements.txt


Please let me know if you need anything else!

Thanks.


0 Votes 0 ·

@SampatVarun-0080 what query did you run on resources.azure.com to get this information?

0 Votes 0 ·
SampatVarun-0080 avatar image
1 Vote"
SampatVarun-0080 answered JasonFreeberg-3971 commented

So I figured it out.

All you have to do is add the following application setting to the app service:

  • SCM_DO_BUILD_DURING_DEPLOYMENT with value=true

It was rather simple, but I still don't understand why/how it worked.

· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

@SampatVarun-0080 It's because virtual environments are not portable between machines. If you create a virtual env on one machine and install your requirements, it's not guaranteed to run on another machine. SCM_DO_BUILD_DURING_DEPLOYMENT instructs App Service to create a virtual env and install your requirements on the runtime machine when you deploy.

More info: https://azure.github.io/AppService/2020/12/11/cicd-for-python-apps.html

1 Vote 1 ·

That's awesome @SampatVarun-0080! I spent some time today trying to see if I could repo your issue but wasn't able to. Deploying from the CLI using az webapp up or Visual Studio Code will set SCM_DO_BUILD_DURING_DEPLOYMENT to True automatically. I've looked at https://docs.microsoft.com/en-us/azure/app-service/configure-language-python and can tell it's certainly confusing. I'm thinking without this flag set to true, Kudu won't run the pip install -r requirements.txt but I need to verify.

Did you happen to deploy your app using zip?

EDIT: I've just confirmed that indeed SCM_DO_BUILD_DURING_DEPLOYMENT needs to be set to 1/True in order for your requirements.txt to run. This setting is enabled by default when using a CI/CD or az webapp up based deployments.

Regards,
Ryan





0 Votes 0 ·
akammerer avatar image
0 Votes"
akammerer answered

I am deploying my functionapp using the run as a package method. Therefore, I need to build the dependencies before. Make sure to build your dependencies on the appropriate Debian version (for v2 stretch, for v3 buster). This fixed it for me.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

ErfanNariman-5893 avatar image
2 Votes"
ErfanNariman-5893 answered Sweiss-6896 published

For those who use GitHub actions for their deployment, setting ubuntu version to 18.04 solved it for me:


jobs:
  build-and-deploy-to-Azure:
    runs-on: ubuntu-18.04
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

This finally worked for me, thanks Erfan.

1 Vote 1 ·
AniketKarajgikar-4428 avatar image
0 Votes"
AniketKarajgikar-4428 answered ryanchill commented

I faced similar error while running python azure function app which was deployed using CI/CD.
I added below line in ci pipeline yaml pipeline:
pip install wheel

and then function app started running fine.

Maybe this answer is out of context here, but I spent whole day to figure this out.

· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

If wheel is in your requirements.txt, then following yaml in your CI/CD pipeline should install it.

- name: Install dependencies
  run: pip install -r requirements.txt

0 Votes 0 ·
AxelVantWesteinde-1259 avatar image
0 Votes"
AxelVantWesteinde-1259 answered

The solutions listed above aren't working for me unfortunately...

Current configuration:
- linuxFxVersion is PYTHON|3.9
- pythonVersion is null
- App service plan is Consumption

Does anyone have any suggestions as to how to fix this problem? (Why don't the Azure Functions Linux instances have version 2.29 of GLIBC?)

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.