Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/azure/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何将Azure DataLake Store gen 2文件共享与Azure DataRicks连接?_Azure_Azure Storage_Azure Databricks_Sas Token - Fatal编程技术网

如何将Azure DataLake Store gen 2文件共享与Azure DataRicks连接?

如何将Azure DataLake Store gen 2文件共享与Azure DataRicks连接?,azure,azure-storage,azure-databricks,sas-token,Azure,Azure Storage,Azure Databricks,Sas Token,我有一个Azure data lake storage gen 2帐户,启用了分层命名空间。我为帐户生成了一个SAS令牌,并将数据接收到文件共享(文件服务)中的一个文件夹中。现在我想通过Azure Databricks和python访问这些文件。然而,Azure Databricks似乎只能访问文件系统(在gen1中称为Blob容器),而不能访问文件共享。我还未能生成文件系统的SAS令牌 我希望有一个存储实例,它可以生成一个SAS令牌并提供给我的客户机,并使用python从azure DataR

我有一个Azure data lake storage gen 2帐户,启用了分层命名空间。我为帐户生成了一个SAS令牌,并将数据接收到文件共享(文件服务)中的一个文件夹中。现在我想通过Azure Databricks和python访问这些文件。然而,Azure Databricks似乎只能访问文件系统(在gen1中称为Blob容器),而不能访问文件共享。我还未能生成文件系统的SAS令牌

我希望有一个存储实例,它可以生成一个SAS令牌并提供给我的客户机,并使用python从azure DataRicks访问该令牌。如果是文件系统、文件共享、ADLS gen2或gen1,只要它能以某种方式工作就不重要了

我使用以下方法从databricks访问文件系统:

configs={“fs.azure.account.auth.type”:“OAuth”,
“fs.azure.account.oauth.provider.type”:“org.apache.hadoop.fs.azurebfs.oauth2.ClientCredsTokenProvider”,
“fs.azure.account.oauth2.client.id”:“我的客户机id”,
“fs.azure.account.oauth2.client.secret”:“my_client_secret”,
“fs.azure.account.oauth2.client.endpoint”:”https://login.microsoftonline.com/“+”我的租户\u id“+”/oauth2/token”,
“fs.azure.createRemoteFileSystemDuringInitialization”:“true”}
dbutils.fs.mount(source=“abfss://“+”我的文件系统“+”@“+”我的存储帐户“+”.dfs.core.windows.net/MyFolder”,
mount_point=“/mnt/my_mount”,
额外(配置=配置)
工作正常,但我无法使其访问文件共享。我有一个SAS令牌,其连接字符串如下:

连接\u字符串=(
“BlobEndpoint=https://.blob.core.windows.net/;'+
'队列端点=https://.queue.core.windows.net/;'+
'文件端点=https://.file.core.windows.net/;'+
“TableEndpoint=https://.table.core.windows.net/;'+
“SharedAccessSignature=sv=2018-03-28&ss=bfqt&srt=sco&sp=rwdlacup&se=2019-09-26T17:12:38Z&st=2019-08-26T09:12:38Z&spr=https&sig=”
)

我设法使用它将内容上传到文件共享,但不上传到文件系统。是否有任何类型的Azure存储可由SAS令牌和Azure Dataricks访问?

从Dataricks连接到Azure文件共享的步骤

from azure.storage.fileshare import ShareClient

share = ShareClient.from_connection_string(conn_str="<connection_string consists of FileEndpoint=myFileEndpoint(https://storageaccountname.file.core.windows.net/);SharedAccessSignature=sasToken>", share_name="<file share name that you want to create>")

share.create_share()
from azure.storage.fileshare import ShareFileClient
 
file_client = ShareFileClient.from_connection_string(conn_str="<connection_string consists of FileEndpoint=myFileEndpoint(https://storageaccountname.file.core.windows.net/);SharedAccessSignature=sasToken>", share_name="<your_fileshare_name>", file_path="my_file")
 
with open("./SampleSource.txt", "rb") as source_file:
    file_client.upload_file(source_file)
首先在DataRicks中使用pip安装安装Microsoft Azure Storage File Share client library for Python

安装后,创建一个存储帐户。然后,您可以从数据块创建文件共享

from azure.storage.fileshare import ShareClient

share = ShareClient.from_connection_string(conn_str="<connection_string consists of FileEndpoint=myFileEndpoint(https://storageaccountname.file.core.windows.net/);SharedAccessSignature=sasToken>", share_name="<file share name that you want to create>")

share.create_share()
from azure.storage.fileshare import ShareFileClient
 
file_client = ShareFileClient.from_connection_string(conn_str="<connection_string consists of FileEndpoint=myFileEndpoint(https://storageaccountname.file.core.windows.net/);SharedAccessSignature=sasToken>", share_name="<your_fileshare_name>", file_path="my_file")
 
with open("./SampleSource.txt", "rb") as source_file:
    file_client.upload_file(source_file)
从azure.storage.fileshare导入ShareClient
share=ShareClient.from_connection_string(conn_str=“”,share_name=“”)
share.create_share()
请将此用作进一步参考

通过DataRicks将文件上载到fileshare的代码

from azure.storage.fileshare import ShareClient

share = ShareClient.from_connection_string(conn_str="<connection_string consists of FileEndpoint=myFileEndpoint(https://storageaccountname.file.core.windows.net/);SharedAccessSignature=sasToken>", share_name="<file share name that you want to create>")

share.create_share()
from azure.storage.fileshare import ShareFileClient
 
file_client = ShareFileClient.from_connection_string(conn_str="<connection_string consists of FileEndpoint=myFileEndpoint(https://storageaccountname.file.core.windows.net/);SharedAccessSignature=sasToken>", share_name="<your_fileshare_name>", file_path="my_file")
 
with open("./SampleSource.txt", "rb") as source_file:
    file_client.upload_file(source_file)
从azure.storage.fileshare导入ShareFileClient
file\u client=ShareFileClient.from\u connection\u string(conn\u str=“”,share\u name=“”,file\u path=“my\u file”)
以open(“./SampleSource.txt”、“rb”)作为源文件:
文件\客户端。上传\文件(源\文件)
有关更多信息,请参阅此链接