-
Notifications
You must be signed in to change notification settings - Fork 32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Upgrade Azure Storage SDK to a modern version #629
Changes from all commits
4a2eba6
0d00eaf
13bfce9
7003187
305b882
a6a56ec
e12ba67
73c02a3
bebef96
dad4e0d
b038b72
b437f9c
6766b84
4c41da0
a7e714c
51c4b3e
3354e53
5d6eca2
edc8bb2
4b67c4a
19aa5cd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,14 +2,47 @@ | |
// SPDX-License-Identifier: MIT | ||
|
||
const AttenuatedQueue = require('./attenuatedQueue') | ||
const AzureStorage = require('azure-storage') | ||
const { QueueServiceClient, StorageRetryPolicyType } = require('@azure/storage-queue') | ||
const Request = require('../../lib/request') | ||
const StorageQueue = require('./storageQueue') | ||
const { DefaultAzureCredential, ClientSecretCredential } = require('@azure/identity') | ||
|
||
class StorageQueueManager { | ||
constructor(connectionString) { | ||
const retryOperations = new AzureStorage.ExponentialRetryPolicyFilter() | ||
this.client = AzureStorage.createQueueService(connectionString).withFilter(retryOperations) | ||
constructor(connectionString, options) { | ||
const pipelineOptions = { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I like the use of |
||
retryOptions: { | ||
maxTries: 3, | ||
retryDelayInMs: 1000, | ||
maxRetryDelayInMs: 120 * 1000, | ||
tryTimeoutInMs: 30000, | ||
retryPolicyType: StorageRetryPolicyType.EXPONENTIAL | ||
} | ||
} | ||
|
||
const { account, spnAuth, isSpnAuth } = options | ||
if (isSpnAuth) { | ||
options.logger.info('using service principal credentials in storageQueueManager') | ||
const authParsed = JSON.parse(spnAuth) | ||
this.client = new QueueServiceClient( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a nice update here for maintaining the old approach and setting up a more flexible long term approach. |
||
`https://${account}.queue.core.windows.net`, | ||
new ClientSecretCredential(authParsed.tenantId, authParsed.clientId, authParsed.clientSecret), | ||
pipelineOptions | ||
) | ||
return | ||
} | ||
|
||
if (connectionString) { | ||
options.logger.info('using connection string in storageQueueManager') | ||
this.client = QueueServiceClient.fromConnectionString(connectionString, pipelineOptions) | ||
return | ||
} | ||
|
||
options.logger.info('using default credentials in storageQueueManager') | ||
this.client = new QueueServiceClient( | ||
`https://${account}.queue.core.windows.net`, | ||
new DefaultAzureCredential(), | ||
pipelineOptions | ||
) | ||
} | ||
|
||
createQueueClient(name, formatter, options) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be updated to '1.1' as we are changing the file format for the deadletter here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ljones140 we can merge this as is and discuss on the version upgrade during our regular sync?