Skip to content
This repository was archived by the owner on Dec 9, 2024. It is now read-only.

Commit 27e39f0

Browse files
authored
Merge pull request #5 from pragnagopa/dev
Work around for kudu sync triggers issue
2 parents 87bf175 + 1d41a9e commit 27e39f0

File tree

3 files changed

+35
-2
lines changed

3 files changed

+35
-2
lines changed

deploy/lib/createFunction.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ module.exports = {
88
const metaData = utils.getFunctionMetaData(functionName, this.provider.getParsedBindings(), this.serverless);
99

1010
return this.provider.createZipObject(functionName, metaData.entryPoint, metaData.handlerPath, metaData.params)
11-
.then(() => this.provider.createAndUploadZipFunctions());
11+
.then(() => this.provider.createAndUploadZipFunctions())
12+
.then(() => this.provider.syncTriggers());
1213
}
1314
};

deploy/lib/createFunctions.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ module.exports = {
1414
});
1515

1616
return BbPromise.all(createFunctionPromises)
17-
.then(() => this.provider.createAndUploadZipFunctions());
17+
.then(() => this.provider.createAndUploadZipFunctions())
18+
.then(() => this.provider.syncTriggers());
1819
}
1920
};

provider/azureProvider.js

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -473,6 +473,33 @@ return new BbPromise((resolve, reject) => {
473473

474474
}
475475

476+
syncTriggers () {
477+
let options = {};
478+
const requestUrl = ` https://management.azure.com/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.Web/sites/${functionAppName}/functions/synctriggers?api-version=2015-08-01`;
479+
options = {
480+
'host': 'management.azure.com',
481+
'method': 'post',
482+
'body': {},
483+
'url': requestUrl,
484+
'json': true,
485+
'headers': {
486+
'Authorization': constants.bearer + principalCredentials.tokenCache._entries[0].accessToken,
487+
'Accept': 'application/json,*/*'
488+
}
489+
};
490+
491+
return new BbPromise((resolve, reject) => {
492+
request(options, (err, res, body) => {
493+
if (err) {
494+
reject(err);
495+
}
496+
this.serverless.cli.log(`Syncing Triggers....Response statuscode: ${res.statusCode}`);
497+
resolve(res);
498+
});
499+
});
500+
501+
}
502+
476503
cleanUpFunctionsBeforeDeploy (serverlessFunctions) {
477504
const deleteFunctionPromises = [];
478505

@@ -516,6 +543,10 @@ return new BbPromise((resolve, reject) => {
516543
const folderForJSFunction = path.join(functionsFolder, functionName);
517544
const handlerPath = path.join(this.serverless.config.servicePath, filePath);
518545

546+
if (!fs.existsSync(functionsFolder)) {
547+
fs.mkdirSync(functionsFolder);
548+
}
549+
519550
if (!fs.existsSync(folderForJSFunction)) {
520551
fs.mkdirSync(folderForJSFunction);
521552
}

0 commit comments

Comments
 (0)