Skip to content

Instantly share code, notes, and snippets.

@codingoutloud
Created September 7, 2017 19:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save codingoutloud/151976063b1e9367369f1505f6cca66e to your computer and use it in GitHub Desktop.
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)
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