[英]Account storage files azure, error connection-azure.core.exceptions.ServiceRequestError
I have an app that connects to account storage files in azure. I am using Python to connect account storage resource.我有一个应用程序连接到 azure 中的帐户存储文件。我正在使用 Python 连接帐户存储资源。 One of the functions I use is 'create_directory()' from class 'from azure.storage.fileshare import (ShareDirectoryClient)'.
我使用的功能之一是来自 class 的“create_directory()”“来自 azure.storage.fileshare import (ShareDirectoryClient)”。 Occasionally, Appears log:
偶尔,出现日志:
Azure.core.exceptions.ServiceRequestError: (<urllib3.connection.HTTPSConnection object at 'object_resurce', 'Connection to 'name_of_the_account_storage_resurce'.file.core.windows.net timed out. (connect timeout=20)')
the func:功能:
def create_dir(self,dir_name:str):
"""
This function will create a new directory in the storage account
Args:
-----
share_name (str): The share client name of storage account.
dir_name (str): The name of the created directory .
"""
#check if the directory is exists in account storage
if(self.dir_exists(dir_name)==False):
# Create a DirectoryClient from a connection string
self.dir_client =
ShareDirectoryClient.from_connection_string(
conn_str=self.connection_string,
share_name=self.share,
directory_path=dir_name)
self.dir_client.create_directory(timeout=60)
How can I fix it?我该如何解决?
Tried to add timeout between connection tries, but didn't fix it试图在连接尝试之间添加超时,但没有修复
I tried in my environment and successfully created directory in the azure file share.我在我的环境中尝试并成功地在 azure 文件共享中创建了目录。
Code:代码:
from azure.storage.fileshare import ShareDirectoryClient
connection_string="< Connection string >"
share_name="fileshare1"
dir_name="directory1"
dir_client = ShareDirectoryClient.from_connection_string(connection_string, share_name, dir_name)
print("Creating directory:", share_name + "/" + dir_name)
dir_client.create_directory()
print("Directory created!!!")
Console:安慰:
Portal:门户网站:
Reference: Develop for Azure Files with Python |参考: Develop for Azure Files with Python | Microsoft Learn
微软学习
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.