I'm trying to do the tutorial but when I enter the command: func init loan-wizard, I become the following error: bash: func: command not found
Exercise - Create a function locally using Core Tools is out of date
Exercise - Create a function locally using Core Tools is out of date.
Create a local Azure Functions project:
- Step 3 says to install Node.js v14, but when you get to the end of the exercise, the output file gives this error. The solution given is that you need v18 or higher. I don't use Node.js outside of these modules, so I'm not sure if this is the best version to use, but I looked up the latest releases and saw that v18.19.0 was the most recent LTS and using that fixed the issue for me.
Create an HTTP-triggered function:
- Step 2 says to enter 10 for HTTP trigger, but it's now listed as 7.
Implement the simple-interest function:
- For step 1, v4 no longer uses index.js and instead uses {name}.js (simple-interest.js in this case) and can be found in the src/functions folder.
- Step 2 is also not valid code for v4. It matches the "handler:" section of the v4 template, with difference in how values are taken and return. I didn't follow the exact same logic flow as the example did, but for reference, here's the code that I used:
const { app } = require('@azure/functions');
app.http('simple-interest', {
methods: ['GET', 'POST'],
authLevel: 'anonymous',
handler: async (request, context) => {
//Try parsing query strings as nums
const principal = parseFloat(request.query.get('principal'));
const rate = parseFloat(request.query.get('rate'));
const term = parseFloat(request.query.get('term'));
//Output values to console for debugging
context.log(principal);
context.log(rate);
context.log(term);
//If any of the query strings aren't nums then return 400 error
if ([principal, rate, term].some(isNaN)) {
//Return 400 status
return {
status: 400,
body: "Please supply principal, rate, and term in the query string"
};
}
//Calculate the interest
const interest = principal * rate * term;
//Return 200 status
return { body: interest };
}
});
Run the function in Cloud Shell:
- For step 5, I believe the output should be "6300.000000000001", but I'm not 100% sure. That's the value that I got and the last step in unit 5 of the same module also says this same program should return that exact value.
I don't need any help with this issue, just wanted to post that the module needs to be updated and hopefully help the next person that comes across this.
Community Center Not monitored
2 answers
Sort by: Most helpful
-
Deleted
This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.
Comments have been turned off. Learn more
-