Skip to content

Commit

Permalink
Scripts: move blob container name to a variable, rather than hardcodi…
Browse files Browse the repository at this point in the history
…ng to 'content' (#802)
  • Loading branch information
Gordonby authored Jul 31, 2020
1 parent 245b96a commit cbea0ba
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
3 changes: 2 additions & 1 deletion scripts/generate.bat
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
set management_endpoint="< service name >.management.azure-api.net"
set access_token="SharedAccessSignature ..."
set storage_connection_string="DefaultEndpointsProtocol=..."
set container="content"
set data_file="./data.json"
set media_folder="./media"

node ./generate %management_endpoint% %access_token% %data_file%
node ./upload %storage_connection_string% %media_folder%
node ./upload %storage_connection_string% %media_folder% %container%
4 changes: 3 additions & 1 deletion scripts/generate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
export management_endpoint="< service name >.management.azure-api.net"
export access_token="SharedAccessSignature ..."
export storage_connection_string="DefaultEndpointsProtocol=..."
export container="content"
export data_file="./data.json"
export media_folder="./media"


# make sure to double quote the $access_token variable so it handles the space correctly
node ./generate $management_endpoint "$access_token" $data_file
node ./upload $storage_connection_string $media_folder
node ./upload $storage_connection_string $media_folder $container
6 changes: 3 additions & 3 deletions scripts/upload.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const path = require("path");
const storage = require("azure-storage");
const connectionString = process.argv[2];
const mediaPath = process.argv[3];

const container = process.argv[4];

function listFilesInDirectory(dir) {
const results = [];
Expand All @@ -24,7 +24,7 @@ function listFilesInDirectory(dir) {

async function upload(fileName, blobName) {
return new Promise((resolve, reject) => {
blobService.createBlockBlobFromLocalFile("content", blobName, fileName, function (error, result, response) {
blobService.createBlockBlobFromLocalFile(container, blobName, fileName, function (error, result, response) {
if (!error) {
resolve();
}
Expand Down Expand Up @@ -54,4 +54,4 @@ uploadFiles()
})
.catch(error => {
console.log(error);
})
})

0 comments on commit cbea0ba

Please sign in to comment.