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

Commit 2b8f388

Browse files
authored
Fix: Updating Persistent Storage Documentation (#283)
* Switched to R6 client * Replaced createContainer function
1 parent 8e39df1 commit 2b8f388

File tree

1 file changed

+23
-3
lines changed

1 file changed

+23
-3
lines changed

docs/72-persistent-storage.md

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,32 @@ If the job is not completed, getJobResult will return the state of your job. Oth
3535
Batch will automatically handle your output files when the user assigns a file pattern and storage container url.
3636

3737
```R
38+
doAzureParallel::setCredentials("credentials.json")
39+
# Using rAzureBatch directly for storage uploads
40+
config <- rjson::fromJSON(file = paste0("credentials.json"))
41+
42+
storageCredentials <- rAzureBatch::SharedKeyCredentials$new(
43+
name = config$sharedKey$storageAccount$name,
44+
key = config$sharedKey$storageAccount$key
45+
)
46+
47+
storageAccountName <- storageCredentials$name
48+
inputContainerName <- "datasets"
49+
50+
storageClient <- rAzureBatch::StorageServiceClient$new(
51+
authentication = storageCredentials,
52+
url = sprintf("https://%s.blob.%s",
53+
storageCredentials$name,
54+
config$sharedKey$storageAccount$endpointSuffix
55+
)
56+
)
57+
3858
# Pushing output files
3959
storageAccount <- "storageAccountName"
4060
outputFolder <- "outputs"
4161

42-
createContainer(outputFolder)
43-
writeToken <- rAzureBatch::createSasToken("w", "c", outputFolder)
62+
storageClient$containerOperations$createContainer(outputFolder)
63+
writeToken <- storageClient$generateSasToken("w", "c", outputFolder)
4464
containerUrl <- rAzureBatch::createBlobUrl(storageAccount = storageAccount,
4565
containerName = outputFolder,
4666
sasToken = writeToken)
@@ -67,7 +87,7 @@ Note: The foreach object always expects a value. We use NULL as a default value
6787

6888
```R
6989
# Bad practice
70-
writeToken <- rAzureBatch::createSasToken("w", "c", outputFolder)
90+
writeToken <- storageClient$generateSasToken("w", "c", outputFolder)
7191
containerUrl <- rAzureBatch::createBlobUrl(storageAccount = storageAccount,
7292
containerName = outputFolder,
7393
sasToken = writeToken)

0 commit comments

Comments
 (0)