-
Notifications
You must be signed in to change notification settings - Fork 13
/
index.js
39 lines (35 loc) · 1.2 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
const df = require('durable-functions')
var storage = require('azure-storage')
module.exports = async (context) => {
// `input` here is retrieved from the Orchestrator function `callActivity` input parameter
var input = context.bindings.input;
// create the table service for Blob Storage
var tableService = storage.createTableService(
process.env['AzureWebJobsStorage']
)
// create the table if it doesn't exist already.
tableService.createTableIfNotExists('Repositories', error => {
if (error) {
console.error(error)
return
}
// creates a batch of operation to be executed
var batch = new storage.TableBatch()
for (var i = 0; i < input.length; i++) {
var repository = input[i]
// Creates an operation to add the repository to Table Storage
batch.insertOrReplaceEntity({
PartitionKey: { _: 'Default' },
RowKey: { _: repository.id.toString() },
OpenedIssues: { _: repository.openedIssues },
RepositoryName: { _: repository.name }
})
}
// execute the batch of operations
tableService.executeBatch('Repositories', batch, error => {
if (error) {
console.error(error)
}
})
})
}