Skip to content

Commit a7e714c

Browse files
committed
Queues can be configued separatly with SPN from harvest azblob
So we have the ability to have an harvest connection with connections string and queues with azure SPN
1 parent 4c41da0 commit a7e714c

File tree

2 files changed

+22
-12
lines changed

2 files changed

+22
-12
lines changed

config/cdConfig.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,9 @@ module.exports = {
140140
attenuation: {
141141
ttl: 3000
142142
},
143-
spnAuth: config.get('CRAWLER_HARVESTS_QUEUE_SPN_AUTH'),
144-
account: cd_azblob.account
143+
spnAuth: config.get('CRAWLER_QUEUE_AZURE_SPN_AUTH') || cd_azblob.spnAuth,
144+
account: config.get('CRAWLER_QUEUE_AZURE_ACCOUNT_NAME') || cd_azblob.account,
145+
isSpnAuth: config.get('CRAWLER_QUEUE_AZURE_IS_SPN_AUTH') || false
145146
},
146147
appVersion: config.get('APP_VERSION'),
147148
buildsha: config.get('BUILD_SHA')

ghcrawler/providers/queuing/storageQueueManager.js

+19-10
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,28 @@ class StorageQueueManager {
1818
retryPolicyType: StorageRetryPolicyType.EXPONENTIAL
1919
}
2020
}
21+
22+
const { account, spnAuth, isSpnAuth } = options
23+
if (isSpnAuth) {
24+
const authParsed = JSON.parse(spnAuth)
25+
this.client = new QueueServiceClient(
26+
`https://${account}.queue.core.windows.net`,
27+
new ClientSecretCredential(authParsed.tenantId, authParsed.clientId, authParsed.clientSecret),
28+
pipelineOptions
29+
)
30+
return
31+
}
32+
2133
if (connectionString) {
2234
this.client = QueueServiceClient.fromConnectionString(connectionString, pipelineOptions)
23-
} else {
24-
const { account, spnAuth } = options
25-
let credential
26-
if (spnAuth) {
27-
const authParsed = JSON.parse(spnAuth)
28-
credential = new ClientSecretCredential(authParsed.tenantId, authParsed.clientId, authParsed.clientSecret)
29-
} else {
30-
credential = new DefaultAzureCredential()
31-
}
32-
this.client = new QueueServiceClient(`https://${account}.queue.core.windows.net`, credential, pipelineOptions)
35+
return
3336
}
37+
38+
this.client = new QueueServiceClient(
39+
`https://${account}.queue.core.windows.net`,
40+
new DefaultAzureCredential(),
41+
pipelineOptions
42+
)
3443
}
3544

3645
createQueueClient(name, formatter, options) {

0 commit comments

Comments
 (0)