Closed DennisSchouwenaars closed 7 months ago
Hi @DennisSchouwenaars, thanks for reporting this behavior. I will have a look at reproducing this and evaluate possible mitigations.
@DennisSchouwenaars, I have tried multiple combinations of Windows/Linux and I am not able to reproduce the issue as described.
However I can simulate conditions by creating a file lock during module execution and experience the different places that the module then fails to access the file.
I am currently thoroughly testing out logic that relieves the file lock in my simulation by storing the template content in-memory prior to deployment as you suggested above.
Describe the bug
When using a single custom bicep template file with multiple *.parameters.json files, having the "ParallelDeployMultipleTemplateParameterFiles" set to true. Trying to deploy a x amount of parameters files at once occasionally result in a "file in use" error message. We've seen this behavior having the throttle limit set to 5, 10 or 15. We use this option multiple times within our repo (and failures occur at different points depending on timing).
It seems the "Foreach-Object -Parallel -UseNewRunspace", locks the file at a certain time. And since the actual deployment file it uses for that given loop only exists once it gets locked at a certain point within the parallel loop (I assume the higher the throttle limit the more likely this behavior occurs). Suggested change would be to load the file in memory before the parallel loop or temp generate a temp copy of the file for the given job/run.
Steps to reproduce
Screenshots