1

您好我正在尝试通过执行从表存储帐户查询数据的 python 脚本来开始 Azure ML 算法。我用这个来做:

entities_Azure=table_session.query_entities(table_name=table_name, 
                                                filter="PartitionKey eq '" + partitionKey + "'",
                                                select='PartitionKey,RowKey,Timestamp,value',
                                                next_partition_key = next_pk,
                                                next_row_key = next_rk, top=1000)  

我在调用这段代码所在的函数时传入所需的变量,并通过在 Azure ML 中包含一个 zip 文件来包含该函数。

我认为错误是由于查询时间过长或类似的原因造成的,但它必须花费很长时间,因为我可能需要查询大量数据......我查看了这个 SO post Windows Azure Storage Table connection超时这是我认为关于达到这些查询的指定阈值的类似问题,但我不知道如何避免它。程序的运行时间只有大约 1.5 分钟才超时..

关于为什么会发生这种情况以及我如何解决它的任何想法?

编辑:

根据Peter Pan - MSFT的建议,我运行了一个更具体的查询:

entities_Azure=table_service.query_entities(table_name='#######',select='PartitionKey,RowKey,Timestamp,value', next_partition_key = None, next_row_key = None, top=2)

这返回了以下错误日志:

Error 0085: The following error occurred during script evaluation, please view the output log for more information:  
---------- Start of error message from Python interpreter ----------  
data:text/plain,Caught exception while executing function: Traceback (most recent call last):    

File "C:\server\invokepy.py", line 169, in 
batch odfs = mod.azureml_main(*idfs)    

File "C:\temp\azuremod.py", line 61, in 
azureml_main entities_Azure=table_service.query_entities(table_name='######',select='PartitionKey,RowKey,Timestamp,value', next_partition_key = None, next_row_key = None, top=2)    

File "./Script Bundle\azure\storage\table\tableservice.py", line 421, in query_entities
 response = self._perform_request(request)    

File "./Script Bundle\azure\storage\storageclient.py", line 171, in _perform_request
 resp = self._filter(request)    

File "./Script Bundle\azure\storage\table\tableservice.py", line 664, in _perform_request_worker
 return self._httpclient.perform_request(request)    

File "./Script Bundle\azure\storage\_http\httpclient.py", line 181, in perform_request
 self.send_request_body(connection, request.body)    

File "./Script Bundle\azure\storage\_http\httpclient.py", line 145, in send_request_body
 connection.send(None)    

File "./Script Bundle\azure\storage\_http\requestsclient.py", line 81, in send
 self.response = self.session.request(self.method, self.uri, data=request_body, headers=self.headers, timeout=self.timeout)    

File "C:\pyhome\lib\site-packages\requests\sessions.py", line 456, in request
 resp = self.send(prep, **send_kwargs)    

File "C:\pyhome\lib\site-packages\requests\sessions.py", line 559, in send
 r = adapter.send(request, **kwargs)    

File "C:\pyhome\lib\site-packages\requests\adapters.py", line 382, in send
 raise SSLError(e, request=request) 

SSLError: The write operation timed out    
---------- End of error message from Python  interpreter 
---------- Start time: UTC 11/18/2015 11:39:32 End time: UTC 11/18/2015 11:40:53

希望这能给情况带来更多的洞察力!

4

2 回答 2

1

我试图用我自己生成的数据填充表存储,并希望通过像您这样的查询来重现您的问题,但失败了。

我发现 REST API 的表存储查询超时问题(用于 python 包装的 REST API 的 azure storage sdk)。表服务 REST API的页面(https://msdn.microsoft.com/en-us/library/azure/dd894042.aspx)“查询超时和分页”说:

针对表服务的查询一次最多可以返回 1,000 个项目,并且最多可以执行 5 秒。如果结果集包含超过 1,000 个项目,如果查询未在 5 秒内完成,或者如果查询跨越分区边界,则响应包括为开发人员提供继续令牌的标头,以便在结果集中的下一项。可能会为查询表操作或查询实体操作返回继续令牌标头。

请注意,分配给调度和处理查询的请求的总时间为 30 秒,其中包括用于查询执行的 5 秒。

查询可能不返回任何结果,但仍会返回延续标头。

我认为这个问题是由达到这些 sepcified 阈值引起的。

Reader另外,我在Azure ML Studio 的实验中使用了模块Data Input and Output并设置了数据源,Azure Table以成功快速地读取 1000 个实体。

在此处输入图像描述

在此处输入图像描述

对于这种场景,我建议您可以使用指定的查询过滤器来查询您的表存储,例如以下:

entities_Azure=table_session.query_entities(table_name=table_name,
      filter="PartitionKey eq '" + partitionKey + "' and Rowkey eq '" + rowkey + "'",
      select='PartitionKey,RowKey,Timestamp,value',
      next_partition_key = next_pk,
      next_row_key = next_rk, top=1000) 

我们可以使用此代码来判断问题是连接问题还是阈值问题。

任何问题,请随时告诉我。

于 2015-11-18T07:39:58.297 回答
0

我在 Azure ML 实验中的访问 Azure 博客存储中遇到了一个非常相似的问题。当我第一次发布时,我没有意识到它们很相似。然而,随着调试和帮助的继续,它变得非常清楚。

底线:azure.storage.*通过 HTTPS/SSL 访问时会发生 SSLError with Timeout 。如果您更改“TableService”的创建以强制使用 HTTP ( protocol='http'),超时错误将停止。

table_service = TableService(account_name='myaccount', account_key='mykey',protocol='http')

完整的分析可以在上面的 StackOverflow 帖子中找到。但是,我看到了这一点,觉得我应该在这里直接提及它以帮助搜索。该修复适用于 azure.storage.table、a​​zure.storage.blob、azure.storage.page 和 azure.storage.queue。

PS。是的,我知道使用 HTTP 并不是最佳选择,但是,您在 Azure中运行所有内容。当您离开 Azure ML(或 Azure 应用服务)时,您可以切换回 HTTPS。

于 2016-02-11T16:17:22.940 回答