Access Azure blob storage from R notebook

我的梦境 提交于 2020-04-16 06:13:05

问题


in python this is how I would access a csv from Azure blobs

storage_account_name = "testname"
storage_account_access_key = "..."
file_location = "wasb://example@testname.blob.core.windows.net/testfile.csv"

spark.conf.set(
  "fs.azure.account.key."+storage_account_name+".blob.core.windows.net",
  storage_account_access_key)

df = spark.read.format('csv').load(file_location, header = True, inferSchema = True)

How can I do this in R? I cannot find any documentation...


回答1:


The AzureStor package provides an R interface to Azure storage, including files, blobs and ADLSgen2.

endp <- storage_endpoint("https://acctname.blob.core.windows.net", key="access_key")
cont <- storage_container(endp, "mycontainer")
storage_download(cont, "myblob.csv", "local_filename.csv")

Note that this will download to a file in local storage. From there, you can ingest into Spark using standard Sparklyr methods.

Disclaimer: I'm the author of AzureStor.



来源:https://stackoverflow.com/questions/54851723/access-azure-blob-storage-from-r-notebook

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!