Skip to content
This repository has been archived by the owner on Oct 12, 2023. It is now read-only.

Commit

Permalink
Fixed resource file samples (#33)
Browse files Browse the repository at this point in the history
  • Loading branch information
brnleehng authored Jun 26, 2017
1 parent 3f5dc8f commit d8bcd6f
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions samples/sas_resource_files_example.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,42 +7,42 @@ storageAccountName <- "mystorageaccount"
inputContainerName <- "datasets"

# Generate a sas token with the createSasToken function
writeSasToken <- createSasToken(permission = "w", path = "c", inputContainerName)
readSasToken <- createSasToken(permission = "r", path = "c", inputContainerName)
writeSasToken <- rAzureBatch::createSasToken(permission = "w", sr = "c", inputContainerName)
readSasToken <- rAzureBatch::createSasToken(permission = "r", sr = "c", inputContainerName)

# Upload blobs with a write sasToken
uploadBlob(inputContainerName,
rAzureBatch::uploadBlob(inputContainerName,
fileDirectory = "1989.csv",
sasToken = writeSasToken,
accountName = storageAccountName)

uploadBlob(inputContainerName,
rAzureBatch::uploadBlob(inputContainerName,
fileDirectory = "1990.csv",
sasToken = writeSasToken,
accountName = storageAccountName)

csvFileUrl1 <- createBlobUrl(storageAccountName = storageAccountName,
csvFileUrl1 <- rAzureBatch::createBlobUrl(storageAccount = storageAccountName,
containerName = inputContainerName,
sasToken = readSasToken,
fileName = "1989.csv")

csvFileUrl2 <- createBlobUrl(storageAccountName = storageAccountName,
csvFileUrl2 <- rAzureBatch::createBlobUrl(storageAccount = storageAccountName,
containerName = inputContainerName,
sasToken = readSasToken,
fileName = "1990.csv")

azure_files = list(
createResourceFile(url = csvFileUrl1, fileName = "1989.csv"),
createResourceFile(url = csvFileUrl2, fileName = "1990.csv")
rAzureBatch::createResourceFile(url = csvFileUrl1, fileName = "1989.csv"),
rAzureBatch::createResourceFile(url = csvFileUrl2, fileName = "1990.csv")
)

cluster <- makeCluster("cluster_settings.json", resourceFiles = azure_files)
cluster <- doAzureParallel::makeCluster("cluster_settings.json", resourceFiles = azure_files)

registerDoAzureParallel(cluster)

# To get access to your azure resource files, user needs to use the special
# environment variable to get the directory
listFiles <- foreach(i = 1989:1990, .combine='c') %dopar% {
listFiles <- foreach(i = 1989:1990, .combine = 'c') %dopar% {
fileDirectory <- paste0(Sys.getenv("AZ_BATCH_NODE_STARTUP_DIR"), "/wd")
return(list.files(fileDirectory))
}
Expand Down

0 comments on commit d8bcd6f

Please sign in to comment.