How to import data asset in R notebook with R function

Wei Zhang 40 Reputation points
2024-03-13T15:04:10.3533333+00:00

Hi everyone

When I followed the instructions in Interactive R development. I encountered several problems as follows:
https://learn.microsoft.com/en-us/azure/machine-learning/how-to-r-interactive-development?view=azureml-api-2

1. unable to load data file with R function (not python function)

In the section "Read tabular data from registered data assets or datastores", I created credential as described in steps 1-3. In step 4: I can also successfully load the data asset with Pandas.
pd <- import("pandas")
cc <- pd$read_csv(py$data_uri)
head(cc)

But, if I choose the R functions, I can not load the data:

df <- read.csv(py$data_uri)

The error message is
Warning message in file(file, "rt"): “cannot open file 'azureml://subscriptions/*****/resourcegroups/****/workspaces/****/datastores/****/paths/clean_street_key/*****.csv': No such file or directory” Error in file(file, "rt"): cannot open the connection

In my opinion, this message is irrational, because it recognized already my data file, and I can load it with Python function.

2. unable to use the filestore object

In the following code provided, a filestore object "azureml.fsspec$AzureMachineLearningFileSystem" required twice the uri : once uri, secondly <path>. But after filled in the information, it still can not read data. I doubt if something is wrong in the filestore?

fs <- azureml.fsspec$AzureMachineLearningFileSystem(uri, sep = "")

df <- with(fs$open("<path>)", "r") %as% f, {
 x <- as.character(f$read(), encoding = "utf-8")
 read.csv(textConnection(x), header = TRUE, sep = ",", stringsAsFactors = FALSE)
})
print(df)

Thanks

Azure Machine Learning
Azure Machine Learning
An Azure machine learning service for building and deploying models.
2,558 questions
Azure Blob Storage
Azure Blob Storage
An Azure service that stores unstructured data in the cloud as blobs.
2,425 questions
{count} votes