You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -140,6 +140,99 @@ To install a specific version:
140
140
az bicep install --version v0.3.255
141
141
```
142
142
143
+
## jsonrpc
144
+
145
+
The `jsonrpc` command enables running the Bicep CLI with a JSON-RPC interface, allowing for programmatic interaction with structured output and avoiding cold-start delays when compiling multiple files. This setup also supports building libraries to interact with Bicep files programmatically in non-.NET languages.
146
+
147
+
The wire format for sending and receiving input/output is header-delimited, using the following structure, where `\r` and `\n` represent carriage return and line feed characters:
148
+
149
+
```
150
+
Content-Length: <length>\r\n\r\n<message>\r\n\r\n
151
+
```
152
+
153
+
*`<length>` is the length of the `<message>` string, including the trailing `\r\n\r\n`.
The following message shows an example for Bicep version.
163
+
164
+
* The input:
165
+
166
+
```json
167
+
{
168
+
"jsonrpc": "2.0",
169
+
"id": 0,
170
+
"method": "bicep/version",
171
+
"params": {}
172
+
}
173
+
```
174
+
175
+
* The output:
176
+
177
+
```json
178
+
{
179
+
"jsonrpc": "2.0",
180
+
"id": 0,
181
+
"result": {
182
+
"version": "0.24.211"
183
+
}
184
+
}
185
+
```
186
+
187
+
For the available methods & request/response bodies, see [`ICliJsonRpcProtocol.cs`](../../src/Bicep.Cli/Rpc/ICliJsonRpcProtocol.cs).
188
+
For an example establinging a JSONRPC connection and interacting with Bicep files programmatically using Node, see [`jsonrpc.test.ts`](../../src/Bicep.Cli.E2eTests/src/jsonrpc.test.ts).
189
+
190
+
### Usage for named pipe
191
+
192
+
Use the following syntax to connect to an existing named pipe as a JSONRPC client.
193
+
194
+
```bicep cli
195
+
bicep jsonrpc --pipe <named_pipe>`
196
+
```
197
+
198
+
`<named_pipe>` is an existing named pipe to connect the JSONRPC client to.
For more examples, see [C#](https://github.com/Azure/bicep/blob/096c32f9d5c42bfb85dff550f72f3fe16f8142c7/src/Bicep.Cli.IntegrationTests/JsonRpcCommandTests.cs#L24-L50) and [node.js](https://github.com/anthony-c-martin/bicep-node/blob/4769e402f2d2c1da8d27df86cb3d62677e7a7456/src/utils/jsonrpc.ts#L117-L151).
213
+
214
+
### Usage for TCP socket
215
+
216
+
Use the following syntax to connect to an existing TCP socket as a JSONRPC client.
217
+
218
+
```bicep cli
219
+
bicep jsonrpc --socket <tcp_socket>
220
+
```
221
+
222
+
`<tcp_socket>` is a a socket number to connect the JSONRPC client to.
223
+
224
+
To connect to a TCP socket
225
+
226
+
`bicep jsonrpc --socket 12345`
227
+
228
+
### Usage for stdin and stdout
229
+
230
+
Use the following syntax to run the JSONRPC interface using stdin & stdout for messages.
231
+
232
+
```bicep cli
233
+
bicep jsonrpc --stdio
234
+
```
235
+
143
236
## lint
144
237
145
238
The `lint` command returns the errors and the [linter rule](./linter.md) violations of a Bicep file.
0 commit comments