LanceMcCarthy / Action-AzureBlobUpload

A GitHub action to upload files to Azure Blob storage, compatible with all Actions runner operating systems.
MIT License
15 stars 4 forks source link

Possibility to use SAS token instead of connection string #418

Open jprecuch opened 5 months ago

jprecuch commented 5 months ago

Hi, Would it be maybe possible to introduce possibility to use SAS Token instead of connection string?

Azure cli supports this

az storage blob upload --account-name $ACCOUNT --container-name $CONTAINER --type block --file delete-me --sas-token $SAS
LanceMcCarthy commented 5 months ago

@jprecuch This action uses the javascript SDK (rather than the CLI tooling), but I'm pretty confident there's got to be an overload to use that instead.

Let me research it and get back to you.

LanceMcCarthy commented 5 months ago

It looks like this is definitely possible, can you confirm what type of SAS token it will be? There are three

I'm expecting it will be account or user, so something like this could probably be implemented quickly

const sasToken = $secret.sasToken;
const blobServiceUri = `https://${secret.accountName}.blob.core.windows.net`;

const blobServiceClient = new BlobServiceClient(
  `${blobServiceUri}?${sasToken}`,
  null
);
LanceMcCarthy commented 5 months ago

Hi @jprecuch Just wanted to follow up to see if you know which kind of SAS you need to use (see my last reply). If I implement this, I would like to start with the same kind you're using, then build up from there.