Azure / Azure/bicep

add support for load file with variable/parameter replacement

Open
#10,112 4 comments 6 reactions 0 assignees View on GitHub
enhancement Needs: Upvote
Dominant language
Bicep
Stars
3.6k
Forks
830
Avg merge
1d 21m
Merged PRs (30d)
79

Description

We have lots of kql functions that we would like to deploy via bicep. loadTextContent() allows us to keep the functions in a file with crlfs as opposed to long lines in ARM. The only problem is often we have functions that reference other clusters/databases/tables that are variable. In those cases, we need to manually put them into a single string with concat or format of the variables/parameters.

Ask is to add a new loadTextContent (or add support for loadTextContent) that allows parameterization of tokens in the file.

**Example kql:**
`.create-or-alter function foo() {`
`cluster(${targetCluster}).database(${targetDB}).Bar`
`| take 10`
`}`

**Example bicep:**

`param targetCluster string`
`param targetDB string`

`var kql = loadTextContent('test.kql')`

**Current behavior:**
` "variables": {`
` "kql": ".create-or-alter function foo() {\r\n cluster(${targetCluster}).database(${targetDb}).Bar\r\n | take 10\r\n}"`
` },`

**Desired behavior (flag or new method to indicate tokens):**
` "variables": {`
` "kql": "[format('.create-or-alter function foo() {\r\n cluster({0}).database({1}).Bar\r\n | take 10\r\n}', parameters('targetCluster'), parameters('targetDb')]"`
` },`

Contributor guide

Open the contributing guide

Research direction

Start by tracing how loadTextContent() is handled and how its contents become ARM template output. Use the test.kql example and the requested targetCluster and targetDB parameters to compare current and desired behavior. Done means a defined flag or method produces parameterized output matching the desired format.

Written by the indexing model from the issue text.

Assessment

Tech stack
azure
Domain
cloud
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.