vscode-azurefunctions
vscode-azurefunctions copied to clipboard
Customize default request body when executing function
When clicking "Execute Function Now", the request body is set to { "name": "Azure" } by default.
There is sample.dat in function directory but it looks like it doesn't read it. I checked the src code. It looks like tryGetSampleData have to read it, but it doesn't.
Is it possible to customize this default value?
Currently it's not possible to customize the default value. However, this is a good idea and we'll see if we can include it in the next feature release.
There is sample.dat in function directory but it looks like it doesn't read it. I checked the src code. It looks like tryGetSampleData have to read it, but it doesn't.
Just to clarify, this function gets the sample data from the template provider. The templates themselves have sample files associated to them including a sample.dat. We never intended to let users provide custom sample.dat files.
I think we would need to spend some time to design this feature. For example, Execute Function Now... can also be used for remote triggers. In those cases, would it make sense to use a sample.dat or should this be exclusively for local projects?
@oleksandr-ivanov-ah Where would you expect the sample.dat to live in your project?
- Should it be in the root of the Functions project?
- Should it be in the individual folder of each Function trigger?
The issue with option 1 is that we wouldn't know which custom sample data to use for each trigger. I think we could structure the sample.dat to be a JSON file that lives in the root, and the keys would be the trigger names that should be used as the custom default request bodies.
Issue with option 2 is that not all function runtimes separate the triggers into folders. I think that we could still enable this scenario, but fall back to option 1 if either:
- There is no sample.dat in the function's folder
- Functions aren't structured in such a way that they are in individual folders
This feature request is now a candidate for our backlog. The community has 240 days to upvote the issue. If it receives 5 upvotes we will move it to our backlog. If not, we will close it. To learn more about how we handle feature requests, please see our documentation.
Happy Coding!
Ah, I was similarly confused by sample.dat and assumed it was an error when "Enter request body" did not grab data from it. (This codebase does seem to reference sample.dat but perhaps I'm not following how it's using it). Is there a reason to include the generated sample.dat file in the function if developers cant really use it themselves? (i.e. could it be excluded for now so that it feels less like a bug.. I edited that file so many times!)
This issue has become stale and is at risk of being closed. The community has 60 days to upvote the issue. If it receives 5 upvotes we will keep it open and take another look. If not, we will close it. To learn more about how we handle issues, please see our documentation.
Happy Coding!
@nturinski i would prefer to have sample.data in function app root folder. Like this:
I think json format is preferable: sample.json