1

I have written some Python code for an azure function and everything works fine when I execute it locally in VS code through Azure Functions Core Tools. The code calls a REST API.

When I deploy it to azure it fails with the following error, any idea on how to debug this?

Result: Failure Exception: SSLError: HTTPSConnectionPool(host='api.myurl.net', port=443): Max retries exceeded with url: /payments/123456 (Caused by SSLError(SSLError(1, '[SSL: TLSV1_ALERT_PROTOCOL_VERSION] tlsv1 alert protocol version (_ssl.c:1125)'))) Stack: File "/azure-functions-host/workers/python/3.8/LINUX/X64/azure_functions_worker/dispatcher.py", line 355, in _handle__invocation_request call_result = await self._loop.run_in_executor( File "/usr/local/lib/python3.8/concurrent/futures/thread.py", line 57, in run result = self.fn(*self.args, **self.kwargs) File "/azure-functions-host/workers/python/3.8/LINUX/X64/azure_functions_worker/dispatcher.py", line 542, in __run_sync_func return func(**params) File "/home/site/wwwroot/HttpTrigger1/__init__.py", line 15, in main status, body, headers = client.get('/payments/234368493',raw=True) File "/home/site/wwwroot/.python_packages/lib/site-packages/quickpay_api_client/api.py", line 80, in perform response = self.fulfill(method, url, File "/home/site/wwwroot/.python_packages/lib/site-packages/quickpay_api_client/api.py", line 44, in fulfill return getattr(self.session, method)(*args, **kwargs) File "/home/site/wwwroot/.python_packages/lib/site-packages/requests/sessions.py", line 555, in get return self.request('GET', url, **kwargs) File "/home/site/wwwroot/.python_packages/lib/site-packages/requests/sessions.py", line 542, in request resp = self.send(prep, **send_kwargs) File "/home/site/wwwroot/.python_packages/lib/site-packages/requests/sessions.py", line 655, in send r = adapter.send(request, **kwargs) File "/home/site/wwwroot/.python_packages/lib/site-packages/requests/adapters.py", line 514, in send raise SSLError(e, request=request)
5
  • You can enclose your error logs or code snippets with " ``` " quotations for better visibility. Just a tip. Commented Mar 2, 2021 at 20:22
  • I already did that :-) Commented Mar 2, 2021 at 21:17
  • When you add " ``` " you should add the code section on the new line, not right next to the quotation mark on the same line. But this actually looks better since the code snippet formatting will take the text to be a single line and long rather than new line for each different stack trace. So you're is better. Commented Mar 2, 2021 at 21:53
  • 1
    ahh, better now? Commented Mar 2, 2021 at 22:22
  • Much better. :-) Commented Mar 2, 2021 at 22:22

2 Answers 2

1

The problem was in the code of one of the installed python modules. The module used the poolmanager and I suspect the problem was in that. I rewrote the code and now it's working.

Sign up to request clarification or add additional context in comments.

Comments

0

Your problem is caused by your certificate is not trusted, you can try to use the following ways to solve it.

1. You can refer to SSLError (bad handshake) when using Azure CLI to get the trusted certificate, you can get the trusted certificate by the URL mentioned by the error message in a browser.

2. You can try to disable certificate verification, please refer to SSL handshake error with some Azure CLI commands:

set ADAL_PYTHON_SSL_NO_VERIFY=1
set AZURE_CLI_DISABLE_CONNECTION_VERIFICATION=1

2 Comments

So just for my understanding. My Python code makes a REST call to api.quickpay,net but the certificate is not trusted by my Azure Function? That makes no sense since its not a selfsigned certrificate.
How can I set these environment variable upon the start of my Azure Function made in Python? I have a company proxy that I cannot disable. When the Azure Function Host starts on my local laptop I need a way to run these 2 commands for the Host environment but I don't know how.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.