如何在Azure Blob中上传大字符串? [英] How to upload a large string in an Azure Blob?
问题描述
现在,我试图弄清楚如何使用Azure,现在在将数据存储到存储帐户中时遇到了问题.我有三个字符串,想要将每个字符串存储在单独的Blob中.使用前两个代码,我的代码可以正常工作,但是第三个代码会导致重试,并以超时结束.我的代码在Azure函数中运行.
Right now I'm trying to figure out how to work with Azure, and now I'm stuck in a problem while storing my data in the storage account. I have three strings and want to store each of them in a separate blob. With the first two, my code works fine, but the third one causes some retries and ends with a timeout. My code is running within an Azure function.
这是一个最小的示例:
from azure.storage.blob import BlobClient
blob_client = BlobClient.from_connection_string(
conn_str. = '<STORAGE_ACCOUNT_CONNECTION_STRING>',
container_name = '<CONTAINER_NAME>',
blob_name. = '<NAME_OF_BLOB>',
)
dic_blob_props = blob_client.upload_blob(
data = '<INFORMATION_THAT_SHOULD_GO_TO_THE_BLOB>',
blob_type = "BlockBlob",
overwrite = True,
)
对于前两个字符串,一切正常,但第三个失败.字符串的长度如下:
The for the first two strings everything works fine but the third fails. The strings have the following length:
len(s_1) = 1246209
len(s_2) = 8794086
len(s_3) = 24518001
最有可能是因为第三个字符串太长,但是必须有一种保存它的方法,对吗?我已经尝试通过 timeout = 600
在 .upload_blob
方法中设置超时时间,但是这完全没有改变结果,也没有改变直到新尝试的时间.写完了.
Most likely it is because the third string is too long, but there must be a way to save it, right?
I have already tried to set the timeout time within the .upload_blob
method by timeout=600
, but this has not changed the result at all, nor the time until a new attempt to write is made.
错误是:
Exception: ServiceResponseError: ('Connection aborted.', timeout('The write operation timed out'))
如果您对问题有任何想法,请告诉我:-)
If you have any ideas on the problem pleast let me know :-)
推荐答案
就我而言,在将功能部署到云中后,问题消失了.似乎在使用Visual Studio代码进行调试时出现问题.
In my case, the problem disappeared after I deployed the function in the cloud. It seems that there was a problem debugging with Visual Studio code.
这篇关于如何在Azure Blob中上传大字符串?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!