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