-
Notifications
You must be signed in to change notification settings - Fork 34
Upgrade Azure Storage SDK to a modern version #629
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
Merged
Merged
Changes from 11 commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
4a2eba6
Upgrade Azure Storage SDK to a modern version
RomanIakovlev 0d00eaf
Add back AzureStorageDocStore.count method
RomanIakovlev 13bfce9
Tweak async error handling, apply prettier
RomanIakovlev 7003187
Fix code style issues
RomanIakovlev 305b882
Fix code style issues
RomanIakovlev a6a56ec
Fix code style issues
RomanIakovlev e12ba67
Add support for separate service principal credentials for blobs and …
RomanIakovlev 73c02a3
Add missing config values
RomanIakovlev bebef96
Add more logging around queue message parsing
RomanIakovlev dad4e0d
Decode Azure queue message before parsing
RomanIakovlev b038b72
Fix the parameter passing in storage queue updateMessage call
RomanIakovlev b437f9c
Fix code review comments
RomanIakovlev 6766b84
Ensure messageId is included into message receipt
RomanIakovlev 4c41da0
Add safe XML+HTML codecs to storage queue
RomanIakovlev a7e714c
Queues can be configued separatly with SPN from harvest azblob
ljones140 51c4b3e
Merge pull request #633 from clearlydefined/seperate-crawler-queue-fr…
RomanIakovlev 3354e53
Merge branch 'master' into roman/azure_sdk
qtomlinson 5d6eca2
name is not set anymore, options.container is the new place for this
ljones140 edc8bb2
Fix integer here was breaking dead letter queue writing
ljones140 4b67c4a
single quotes
ljones140 19aa5cd
Modify ordered auth selection in azureBlobFactory and azureQueueStore
RomanIakovlev File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,14 +2,35 @@ | |
| // 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 = { | ||
|
Collaborator
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 | ||
| } | ||
| } | ||
| if (connectionString) { | ||
| this.client = QueueServiceClient.fromConnectionString(connectionString, pipelineOptions) | ||
| } else { | ||
| const { account, spnAuth } = options | ||
| let credential | ||
| if (spnAuth) { | ||
| const authParsed = JSON.parse(spnAuth) | ||
| credential = new ClientSecretCredential(authParsed.tenantId, authParsed.clientId, authParsed.clientSecret) | ||
| } else { | ||
| credential = new DefaultAzureCredential() | ||
| } | ||
| this.client = new QueueServiceClient(`https://${account}.queue.core.windows.net`, credential, pipelineOptions) | ||
| } | ||
| } | ||
|
|
||
| createQueueClient(name, formatter, options) { | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,15 +1,51 @@ | ||
| // Copyright (c) Microsoft Corporation. All rights reserved. | ||
| // SPDX-License-Identifier: MIT | ||
|
|
||
| const AzureStorage = require('azure-storage') | ||
| // @ts-check | ||
| const { BlobServiceClient, StorageRetryPolicyType } = require('@azure/storage-blob') | ||
| const AzureStorageDocStore = require('./storageDocStore') | ||
| const { DefaultAzureCredential, ClientSecretCredential } = require('@azure/identity') | ||
|
|
||
| /** | ||
| * @param {object} options | ||
| * @param {string} options.account | ||
| * @param {string} options.connection | ||
| * @param {string} options.container | ||
| * @param {object} options.logger | ||
| * @param {object} options.spnAuth | ||
| */ | ||
| module.exports = options => { | ||
| options.logger.info('creating azure storage store') | ||
| const { account, key, connection, container } = options | ||
| const retryOperations = new AzureStorage.ExponentialRetryPolicyFilter() | ||
| const blobService = connection | ||
| ? AzureStorage.createBlobService(connection).withFilter(retryOperations) | ||
| : AzureStorage.createBlobService(account, key).withFilter(retryOperations) | ||
| return new AzureStorageDocStore(blobService, container, options) | ||
| const { account, connection, container, spnAuth } = options | ||
|
|
||
| const pipelineOptions = { | ||
| retryOptions: { | ||
| maxTries: 3, | ||
| retryDelayInMs: 1000, | ||
| maxRetryDelayInMs: 120 * 1000, | ||
| tryTimeoutInMs: 30000, | ||
| retryPolicyType: StorageRetryPolicyType.EXPONENTIAL | ||
| } | ||
| } | ||
|
|
||
| let blobServiceClient | ||
| if (connection) { | ||
| options.logger.info('using connection string') | ||
| blobServiceClient = BlobServiceClient.fromConnectionString(connection, pipelineOptions) | ||
| } else { | ||
| let credential | ||
| if (spnAuth) { | ||
| const authParsed = JSON.parse(spnAuth) | ||
| credential = new ClientSecretCredential(authParsed.tenantId, authParsed.clientId, authParsed.clientSecret) | ||
| options.logger.info('using service principal credentials') | ||
| } else { | ||
| credential = new DefaultAzureCredential() | ||
| options.logger.info('using default credentials') | ||
| } | ||
| blobServiceClient = new BlobServiceClient(`https://${account}.blob.core.windows.net`, credential, pipelineOptions) | ||
| } | ||
|
|
||
| const containerClient = blobServiceClient.getContainerClient(container) | ||
|
|
||
| return new AzureStorageDocStore(containerClient, options) | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.