notes.dt.in.th
// source: https://github.com/Azure-Samples/functions-node-sas-token/blob/master/GetSasToken-Node/index.js
const azure = require('azure-storage')
const blobService = azure.createBlobService('<CONNECTION STRING>')
const startDate = new Date(Date.now() - 300e3)
const expiryDate = new Date(Date.now() + 3600e3)
const permissions =
  azure.BlobUtilities.SharedAccessPermissions.READ +
  azure.BlobUtilities.SharedAccessPermissions.WRITE
const container = 'bucket'
const blobName = 'meow.txt'
const sasToken = blobService.generateSharedAccessSignature(
  container,
  blobName,
  {
    AccessPolicy: {
      Permissions: permissions,
      Start: startDate,
      Expiry: expiryDate,
    },
  }
)
const url = blobService.getUrl(container, blobName, sasToken, true)

// https://serverfault.com/questions/939472/curl-and-azure-blob-with-sas-http-header-thats-mandatory-for-this-request-is
console.log(
  `curl -X PUT -H "x-ms-blob-type: BlockBlob" -H "Content-Type: text/plain" '${url}' --data-binary @-`
)