Closed todadot closed 11 months ago
Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @pjohari-ms @simorenoh @AbhinavTrips @bambriz.
hi @todadot, I'm not sure I fully understand what you're asking here - could you share a code snippet of what doesn't work? are you trying to initialize a client within a function?
Hi @todadot. Thank you for opening this issue and giving us the opportunity to assist. To help our team better understand your issue and the details of your scenario please provide a response to the question asked above or the information requested above. This will help us more accurately address your issue.
Hi @todadot, we're sending this friendly reminder because we haven't heard back from you in 7 days. We need more information about this issue to help address it. Please be sure to give us your input. If we don't hear back from you within 14 days of this comment the issue will be automatically closed. Thank you!
Describe the bug I am creating an azure function in python. On CosmosClient initialization (both from constructor with Endpoint and Key parameter, or from connection string) I receive the error below. Not able to connect to cosmos db.
To Reproduce Steps to reproduce the behavior:
Expected behavior Be able to connect to the database. It works form standalone python script, but does not work from the function app during HTTPTrigger
Screenshots If applicable, add screenshots to help explain your problem.
Additional context
[2023-10-27T16:38:06.050Z] Request URL: ...URL.... Request method: 'GET' Request headers: 'Cache-Control': 'no-cache' 'x-ms-version': 'REDACTED' 'x-ms-documentdb-query-iscontinuationexpected': 'REDACTED' 'x-ms-date': 'REDACTED' 'authorization': 'REDACTED' 'Accept': 'application/json' 'Content-Length': '0' 'User-Agent': 'azsdk-python-cosmos/4.5.1 Python/3.11.6 (Windows-10-10.0.19045-SP0)' No body was attached to the request [2023-10-27T16:38:29.436Z] Request URL: ...URL.... Request method: 'GET' Request headers: 'Cache-Control': 'no-cache' 'x-ms-version': 'REDACTED' 'x-ms-documentdb-query-iscontinuationexpected': 'REDACTED' 'x-ms-date': 'REDACTED' 'authorization': 'REDACTED' 'Accept': 'application/json' 'Content-Length': '0' 'User-Agent': 'azsdk-python-cosmos/4.5.1 Python/3.11.6 (Windows-10-10.0.19045-SP0)' No body was attached to the request [2023-10-27T16:38:57.014Z] Request URL: ...URL.... Request method: 'GET' Request headers: 'Cache-Control': 'no-cache' 'x-ms-version': 'REDACTED' 'x-ms-documentdb-query-iscontinuationexpected': 'REDACTED' 'x-ms-date': 'REDACTED' 'authorization': 'REDACTED' 'Accept': 'application/json' 'Content-Length': '0' 'User-Agent': 'azsdk-python-cosmos/4.5.1 Python/3.11.6 (Windows-10-10.0.19045-SP0)' No body was attached to the request [2023-10-27T16:39:22.204Z] Request URL: ...URL.... Request method: 'GET' Request headers: 'Cache-Control': 'no-cache' 'x-ms-version': 'REDACTED' 'x-ms-documentdb-query-iscontinuationexpected': 'REDACTED' 'x-ms-date': 'REDACTED' 'authorization': 'REDACTED' 'Accept': 'application/json' 'Content-Length': '0' 'User-Agent': 'azsdk-python-cosmos/4.5.1 Python/3.11.6 (Windows-10-10.0.19045-SP0)' No body was attached to the request [2023-10-27T16:39:45.156Z] Executed 'Functions.User' (Failed, Id=28bfdadc-8349-4b2f-9ea5-5b3d87fe87a4, Duration=99706ms) [2023-10-27T16:39:45.159Z] System.Private.CoreLib: Exception while executing function: Functions.User. System.Private.CoreLib: Result: Failure
Exception: ServiceRequestError: [SSL: UNEXPECTED_EOF_WHILE_READING] EOF occurred in violation of protocol (_ssl.c:1006) Stack: File "C:\Users\TOD\AppData\Roaming\npm\node_modules\azure-functions-core-tools\bin\workers\python\3.11/WINDOWS/X64\azure_functions_worker\dispatcher.py", line 479, in _handleinvocation_request call_result = await self._loop.run_in_executor( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\TOD\AppData\Local\Programs\Python\Python311\Lib\concurrent\futures\thread.py", line 58, in run result = self.fn(*self.args, self.kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\TOD\AppData\Roaming\npm\node_modules\azure-functions-core-tools\bin\workers\python\3.11/WINDOWS/X64\azure_functions_worker\dispatcher.py", line 752, in _run_sync_func return ExtensionManager.get_sync_invocation_wrapper(context, ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\TOD\AppData\Roaming\npm\node_modules\azure-functions-core-tools\bin\workers\python\3.11/WINDOWS/X64\azure_functions_worker\extension.py", line 215, in _raw_invocation_wrapper result = function(args) ^^^^^^^^^^^^^^^^ File "K:\My Drive\Projects\HumanDesign\Backend\HumanDesignBackend\function_app.py", line 22, in User Client = CosmosClient.from_connection_string(.... connections string ....) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "K:\My Drive\Projects\HumanDesign\Backend\HumanDesignBackend.venv\Lib\site-packages\azure\cosmos\cosmos_client.py", line 221, in from_connection_string return cls( ^^^^ File "K:\My Drive\Projects\HumanDesign\Backend\HumanDesignBackend.venv\Lib\site-packages\azure\cosmos\cosmos_client.py", line 190, in init
self.client_connection = CosmosClientConnection( ^^^^^^^^^^^^^^^^^^^^^^^ File "K:\My Drive\Projects\HumanDesign\Backend\HumanDesignBackend.venv\Lib\site-packages\azure\cosmos_cosmos_client_connection.py", line 210, in init database_account = self._global_endpoint_manager._GetDatabaseAccount(kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "K:\My Drive\Projects\HumanDesign\Backend\HumanDesignBackend.venv\Lib\site-packages\azure\cosmos_global_endpoint_manager.py", line 124, in _GetDatabaseAccount database_account = self._GetDatabaseAccountStub(self.DefaultEndpoint, kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "K:\My Drive\Projects\HumanDesign\Backend\HumanDesignBackend.venv\Lib\site-packages\azure\cosmos_global_endpoint_manager.py", line 147, in _GetDatabaseAccountStub return self.Client.GetDatabaseAccount(endpoint, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "K:\My Drive\Projects\HumanDesign\Backend\HumanDesignBackend.venv\Lib\site-packages\azure\cosmos_cosmos_client_connection.py", line 2122, in GetDatabaseAccount result, self.last_response_headers = self.Get("", request_params, headers, kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "K:\My Drive\Projects\HumanDesign\Backend\HumanDesignBackend.venv\Lib\site-packages\azure\cosmos_cosmos_client_connection.py", line 2316, in __Get return synchronized_request.SynchronizedRequest( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "K:\My Drive\Projects\HumanDesign\Backend\HumanDesignBackend.venv\Lib\site-packages\azure\cosmos_synchronized_request.py", line 206, in SynchronizedRequest return _retry_utility.Execute( ^^^^^^^^^^^^^^^^^^^^^^^ File "K:\My Drive\Projects\HumanDesign\Backend\HumanDesignBackend.venv\Lib\site-packages\azure\cosmos_retry_utility.py", line 83, in Execute
result = ExecuteFunction(function, global_endpoint_manager, *args, *kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "K:\My Drive\Projects\HumanDesign\Backend\HumanDesignBackend.venv\Lib\site-packages\azure\cosmos_retry_utility.py", line 143, in ExecuteFunction return function(args, kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^ File "K:\My Drive\Projects\HumanDesign\Backend\HumanDesignBackend.venv\Lib\site-packages\azure\cosmos_synchronized_request.py", line 131, in _Request response = _PipelineRunFunction( ^^^^^^^^^^^^^^^^^^^^^ File "K:\My Drive\Projects\HumanDesign\Backend\HumanDesignBackend.venv\Lib\site-packages\azure\cosmos_synchronized_request.py", line 172, in _PipelineRunFunction return pipeline_client._pipeline.run(request, kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "K:\My Drive\Projects\HumanDesign\Backend\HumanDesignBackend.venv\Lib\site-packages\azure\core\pipeline_base.py", line 230, in run
return first_node.send(pipeline_request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "K:\My Drive\Projects\HumanDesign\Backend\HumanDesignBackend.venv\Lib\site-packages\azure\core\pipeline_base.py", line 86, in send
response = self.next.send(request) ^^^^^^^^^^^^^^^^^^^^^^^ File "K:\My Drive\Projects\HumanDesign\Backend\HumanDesignBackend.venv\Lib\site-packages\azure\core\pipeline_base.py", line 86, in send
response = self.next.send(request) ^^^^^^^^^^^^^^^^^^^^^^^ File "K:\My Drive\Projects\HumanDesign\Backend\HumanDesignBackend.venv\Lib\site-packages\azure\core\pipeline_base.py", line 86, in send
response = self.next.send(request) ^^^^^^^^^^^^^^^^^^^^^^^ [Previous line repeated 1 more time] File "K:\My Drive\Projects\HumanDesign\Backend\HumanDesignBackend.venv\Lib\site-packages\azure\cosmos_retry_utility.py", line 214, in send
raise err File "K:\My Drive\Projects\HumanDesign\Backend\HumanDesignBackend.venv\Lib\site-packages\azure\cosmos_retry_utility.py", line 191, in send
response = self.next.send(request) ^^^^^^^^^^^^^^^^^^^^^^^ File "K:\My Drive\Projects\HumanDesign\Backend\HumanDesignBackend.venv\Lib\site-packages\azure\core\pipeline_base.py", line 86, in send
response = self.next.send(request) ^^^^^^^^^^^^^^^^^^^^^^^ File "K:\My Drive\Projects\HumanDesign\Backend\HumanDesignBackend.venv\Lib\site-packages\azure\core\pipeline_base.py", line 86, in send
response = self.next.send(request) ^^^^^^^^^^^^^^^^^^^^^^^ File "K:\My Drive\Projects\HumanDesign\Backend\HumanDesignBackend.venv\Lib\site-packages\azure\core\pipeline_base.py", line 86, in send
response = self.next.send(request) ^^^^^^^^^^^^^^^^^^^^^^^ [Previous line repeated 1 more time] File "K:\My Drive\Projects\HumanDesign\Backend\HumanDesignBackend.venv\Lib\site-packages\azure\core\pipeline_base.py", line 119, in send
self._sender.send(request.http_request, request.context.options), ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "K:\My Drive\Projects\HumanDesign\Backend\HumanDesignBackend.venv\Lib\site-packages\azure\core\pipeline\transport_requests_basic.py", line 381, in send raise error .