Created
September 7, 2017 19:28
-
-
Save codingoutloud/151976063b1e9367369f1505f6cca66e to your computer and use it in GitHub Desktop.
Code for an Azure Function that sometimes returns failure (on purposes, 75% of the time, useful for testing)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = function (context, req) { | |
if (Math.random() > 0.75) { | |
context.log('Azure Function "Fail75" is randomly (25%) returning 200 OK.'); | |
context.res = { | |
body: "Randomly (25%) returning 200 OK." | |
} | |
} | |
else { | |
context.log('Azure Function "Fail75" is randomly (75%) returning 500 as a transient error.'); | |
context.res = { | |
status: 500, // something transient | |
body: "Randomly (75%) returning 500 as a transient error." | |
}; | |
} | |
context.done(); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment