[Storage] Support SAS Connection String - storage-queue#4372
[Storage] Support SAS Connection String - storage-queue#4372HarshaNalluru merged 26 commits intoAzure:feature/storagefrom
Conversation
…ing supports both
| connectionString.search("DefaultEndpointsProtocol=") !== -1 && | ||
| connectionString.search("AccountKey=") !== -1 | ||
| ) { | ||
| const matchCredentials = connectionString.match( |
There was a problem hiding this comment.
const matchCredentials = connectionString.match [](start = 4, length = 47)
May not related to this CR about SAS connection string. But seems this kind of connection string cannot be successfully parsed:
DefaultEndpointsProtocol=https;
BlobEndpoint=[http://www.mydomain.com](http://www.mydomain.com);
AccountName=storagesample;
AccountKey=<account-key>
There was a problem hiding this comment.
I'm under the impression that connection string can only be of the following type.
DefaultEndpointsProtocol=[http|https];
AccountName=myAccountName;
AccountKey=myAccountKey;
EndpointSuffix=mySuffix;
And this is what the portal provides from what I know.
Keeping this in mind, we had the logic of parsing the connection strings.
There was a problem hiding this comment.
We can definitely add support to cover a wider range of connection strings.
You want me to do it in the same PR or create a new issue for it?
There was a problem hiding this comment.
Both fine to me. Just what you prefer : )
|
|
||
| let newMessage = "New Message"; | ||
| let messageIdClient = new MessageIdClient( | ||
| getSASConnectionStringFromEnvironment(), |
There was a problem hiding this comment.
getSASConnectionStringFromEnvironment [](start = 6, length = 37)
Can we generate a SAS connection string dynamically using storage account & key in Node.js runtime?
Account Name + Account Key => SAS
So we can reuse current account_name and account_key environment variable, instead of importing a new environment variable.
SAS aims for a short term period access, and can be oudated when storage key is rotated. Also a SAS has a valid period, after that, SAS will be outdated.
In browser runtime, we can use the environment variable account_name with account_sas to generate the SAS connection string too.
There was a problem hiding this comment.
Sure, we can do that. I'll update.
| } | ||
|
|
||
| return connectionString; | ||
| } |
There was a problem hiding this comment.
Can we generate a SAS connection string dynamically using storage account & key in Node.js runtime?
Account Name + Account Key => SAS
So we can reuse current account_name and account_key environment variable, instead of importing a new REQUIRED environment variable.
SAS aims for a short term period access, and can be oudated when storage key is rotated. Also a SAS has a valid period, after that, SAS will be outdated.
In browser runtime, we can reuse existing environment variables account_name with account_sas to generate the SAS connection string too.
XiaoningLiu
left a comment
There was a problem hiding this comment.
Looks good. My major concern is about the new introduced REQUIRED environment variable for SAS connection string. Basically we can generate a SAS connection string based on existing environment variabless like account name and account key in node.js runtime, or account_name and account_sas in browsers.
bterlson
left a comment
There was a problem hiding this comment.
Looks good though I agree with removing the new environment variable if possible (if it isn't, let me know).
| ACCOUNT_KEY=<storage-account-key> | ||
| ACCOUNT_SAS=<shared-access-signature> No newline at end of file | ||
| ACCOUNT_SAS=<shared-access-signature> | ||
| STORAGE_CONNECTION_STRING=<storage-account-connection-string> |
There was a problem hiding this comment.
Where does this get referred?
There was a problem hiding this comment.
sample.env is just a file to show how the environment(or .env file) should look like.
STORAGE_CONNECTION_STRING environment variable is being used in some of the tests where we test the connection string static methods and constructors. [Unrelated to this PR]
Adds a new environment variable - "STORAGE_SAS_CONNECTION_STRING"
Storage service provides two types of connection strings, one with the accountname and key and the other one SAS conn. string with SAS string and endpoints.
This PR adds the SAS connection string support to the existing connection string static methods and constructors.
Handled SAS connection string in the recorder and added tests and recordings accordingly.
Changes in this PR
https://github.com/Azure/azure-sdk-for-js/pull/4372/files?file-filters%5B%5D=.env&file-filters%5B%5D=.ts
https://github.com/Azure/azure-sdk-for-js/pull/4372/files?file-filters%5B%5D=.js&file-filters%5B%5D=.json