bicep icon indicating copy to clipboard operation
bicep copied to clipboard

Print/stdout statement for debugging

Open ljunquera opened this issue 1 year ago • 1 comments

It would be helpful to me in getting up to speed on bicep and debugging if there were a print or stdout statement, like this request on stackoverflow. In one areas I wanted to see if a managed identity exists and print the id if it did. That's pretty simple and may not seem like a necessity but as I get into loops it would help to see what I'm getting back and if I need any additional formatting (e.g. does the output I get match the input formatting I need for the next call).

A simple example might be using "existing" to get a managed identity and seeing if it actually worked.

Describe the solution you'd like Simply print the output to the console when I'm running it in VS Code and I expect when it's in GitHub Actions that it would do the same.

ljunquera avatar Aug 10 '22 10:08 ljunquera

This would greatly assist in debugging issues with nested objects.

sylvainsf avatar Aug 13 '22 22:08 sylvainsf

It's a little tricky because the bicep/ARM template is processed entirely server-side, where most programming languages are processed client-side. I wonder if in the short term, in the deployment outputs we could emit all the requested "stdout" statements, even if there was an error in the deployment. In the longer term, we will be able to run the deployments engine locally, so this ask would get easier.

There is also a question of when should that stdout statement be processed. There is not a top->bottom execution order for bicep processing, it is based on the execution graph which is determined by the dependencies between resources.

alex-frankel avatar Aug 17 '22 16:08 alex-frankel

Thanks for all the context! I wonder if some inspect directive could be passed on a line basis and it all could be handed back to print out at the end collated by line vs by execution time so it avoids the end user needing to understand the execution order? Kind of like azure cli spits out the json at the end of whatever you've done.

sylvainsf avatar Aug 17 '22 16:08 sylvainsf

This would be incredibly valuable.

tasdflkjweio avatar Jun 19 '23 20:06 tasdflkjweio