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

Work around for kudu sync triggers issue #5

Merged
merged 1 commit into from
Feb 17, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion deploy/lib/createFunction.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ module.exports = {
const metaData = utils.getFunctionMetaData(functionName, this.provider.getParsedBindings(), this.serverless);

return this.provider.createZipObject(functionName, metaData.entryPoint, metaData.handlerPath, metaData.params)
.then(() => this.provider.createAndUploadZipFunctions());
.then(() => this.provider.createAndUploadZipFunctions())
.then(() => this.provider.syncTriggers());
}
};
3 changes: 2 additions & 1 deletion deploy/lib/createFunctions.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ module.exports = {
});

return BbPromise.all(createFunctionPromises)
.then(() => this.provider.createAndUploadZipFunctions());
.then(() => this.provider.createAndUploadZipFunctions())
.then(() => this.provider.syncTriggers());
}
};
31 changes: 31 additions & 0 deletions provider/azureProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,33 @@ return new BbPromise((resolve, reject) => {

}

syncTriggers () {
let options = {};
const requestUrl = ` https://management.azure.com/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.Web/sites/${functionAppName}/functions/synctriggers?api-version=2015-08-01`;
options = {
'host': 'management.azure.com',
'method': 'post',
'body': {},
'url': requestUrl,
'json': true,
'headers': {
'Authorization': constants.bearer + principalCredentials.tokenCache._entries[0].accessToken,
'Accept': 'application/json,*/*'
}
};

return new BbPromise((resolve, reject) => {
request(options, (err, res, body) => {
if (err) {
reject(err);
}
this.serverless.cli.log(`Syncing Triggers....Response statuscode: ${res.statusCode}`);
resolve(res);
});
});

}

cleanUpFunctionsBeforeDeploy (serverlessFunctions) {
const deleteFunctionPromises = [];

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

if (!fs.existsSync(functionsFolder)) {
fs.mkdirSync(functionsFolder);
}

if (!fs.existsSync(folderForJSFunction)) {
fs.mkdirSync(folderForJSFunction);
}
Expand Down