9

I'm trying to debug my first Bicep template.

How can I just write a variable or parameter value to standard output?

Something like:

var hello = 'hello world!'
write-host(hello)
Ken White
  • 123,280
  • 14
  • 225
  • 444
Nathan
  • 6,095
  • 2
  • 35
  • 61

2 Answers2

7

The best is to use module outputs which you can read from Portal. Module deployments are separate deployments visible in the "Deployments" section of resource group / subscription / etc. Even if the top-level deployment will fail, outputs from modules inside that were successful can be read, alongside parameters they took.

Remember, that bicep is a declarative language, not imperative, so the file is not being processed sequentially.

Miq
  • 3,931
  • 2
  • 18
  • 32
  • 2
    Thanks, I will give that a shot as a work-around - though I won't mark it as accepted, as it's not really what I was looking for... while I'm enjoying most things about Bicep so far, this strikes me as quite a severe limitation: enabling users to see the evaluated result of an expression at runtime (easily and without jumping through hoops) should be a thing. – Nathan Jun 14 '21 at 08:13
  • place an issue on the bicep github. as for the answer - it's simple - you cannot do that now. I've provided you a best workaround. – Miq Jun 14 '21 at 08:40
  • I agree with Nathan. – lcj Aug 10 '22 at 10:06
  • 1
    I put in a feature request https://github.com/Azure/bicep/issues/7924 – lcj Aug 10 '22 at 10:23
2

I created some simple hello world type templates early on in Bicep's history for this type of question https://github.com/Azure/bicep/tree/main/src/Bicep.Core.Samples/Files/user_submitted/000/01-hello-world .

The've been moved around and are harder to find, but still helpful.

Christopher G. Lewis
  • 4,777
  • 1
  • 27
  • 46