如何从Azure数据湖读取R中的数据文件(存储账户)

agxfikkp  于 2023-01-28  发布在  其他
关注(0)|答案(1)|浏览(144)

我能够使用AzureAuth和AzureStor包通过服务主体身份验证从Azure数据湖(存储帐户)上传和下载Azure ML RStudio中的数据文件。
我想从Azure数据湖(存储帐户)读取Azure ML RStudio中的数据文件。

tmb3ates

tmb3ates1#

以下是Azure ML Rstudio中读取数据文件的代码片段:

# Install the AzureAuth and AzureStor packages
install.packages("AzureAuth")
install.packages("AzureStor")

# Load the AzureAuth and AzureStor packages
library(AzureAuth)
library(AzureStor)

# Authenticate with your Azure subscription using a service principal
azure_auth(tenant_id = "<your-tenant-id>",
           client_id = "<your-client-id>",
           client_secret = "<your-client-secret>")

# Connect to your Azure data lake (storage account)
azure_storage_account_name <- "<your-storage-account-name>"
azure_storage_account_key <- "<your-storage-account-key>"
azure_storage_account_container <- "<your-storage-account-container>"
azure_storage_account_file_path <- "<your-storage-account-file-path>"

azure_storage_account_connection <- AzureStor::az_storage_account(
  account_name = azure_storage_account_name,
  account_key = azure_storage_account_key
)

# Read the data file from Azure data lake (storage account)
data <- AzureStor::az_blob_download(
  connection = azure_storage_account_connection,
  container = azure_storage_account_container,
  file_path = azure_storage_account_file_path
)

相关问题