Skip to content

Commit 9f3903d

Browse files
authored
Merge pull request #307248 from mumian/1022-jsonrpc-format
add jsonrpc format
2 parents f33cf3a + 45e564a commit 9f3903d

2 files changed

Lines changed: 61 additions & 24 deletions

File tree

articles/azure-resource-manager/bicep/bicep-cli.md

Lines changed: 60 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
title: Bicep CLI commands
33
description: Learn about the commands that you can use in the Bicep CLI. These commands include building JSON Azure Resource Manager templates from Bicep.
44
ms.topic: reference
5-
ms.date: 09/09/2025
5+
ms.date: 10/22/2025
66
ms.custom: devx-track-azurecli, devx-track-bicep, devx-track-arm-template
77
---
88

@@ -285,30 +285,67 @@ For example:
285285
Content-Length: 72\r\n\r\n{"jsonrpc": "2.0", "id": 0, "method": "bicep/version", "params": {}}\r\n\r\n
286286
```
287287

288-
The following message shows an example for Bicep version.
288+
The following methods are available through the JSON-RPC interface:
289289

290-
* The input:
290+
* **bicep/format**
291291

292-
```json
293-
{
294-
"jsonrpc": "2.0",
295-
"id": 0,
296-
"method": "bicep/version",
297-
"params": {}
298-
}
299-
```
292+
Formats a Bicep file.
293+
294+
* The request:
300295

301-
* The output:
302-
303-
```json
304-
{
305-
"jsonrpc": "2.0",
306-
"id": 0,
307-
"result": {
308-
"version": "0.24.211"
296+
```json
297+
{
298+
"jsonrpc": "2.0",
299+
"id": 1,
300+
"method": "bicep/format",
301+
"params": {
302+
"path": "/path/to/file.bicep"
303+
}
309304
}
310-
}
311-
```
305+
```
306+
307+
* The response:
308+
309+
```json
310+
{
311+
"jsonrpc": "2.0",
312+
"id": 1,
313+
"result": {
314+
"success": true,
315+
"diagnostics": [],
316+
"contents": "param foo string\n\nresource storage 'Microsoft.Storage/storageAccounts@2025-01-01' = {\n name: 'mystorageaccount'\n location: 'East US'\n}\n"
317+
}
318+
}
319+
```
320+
321+
On success, `"success": true` is returned, with contents holding the formatted Bicep source. On failure, `"success": false` with `diagnostics` describing the failure.
322+
323+
* **bicep/version**
324+
325+
Returns the version of the Bicep CLI.
326+
327+
* The request:
328+
329+
```json
330+
{
331+
"jsonrpc": "2.0",
332+
"id": 0,
333+
"method": "bicep/version",
334+
"params": {}
335+
}
336+
```
337+
338+
* The response:
339+
340+
```json
341+
{
342+
"jsonrpc": "2.0",
343+
"id": 0,
344+
"result": {
345+
"version": "0.24.211"
346+
}
347+
}
348+
```
312349

313350
For the available methods & request/response bodies, see [`ICliJsonRpcProtocol.cs`](https://github.com/Azure/bicep/blob/main/src/Bicep.Cli/Rpc/ICliJsonRpcProtocol.cs).
314351
For an example establishing a JSONRPC connection and interacting with Bicep files programmatically using Node, see [`jsonrpc.test.ts`](https://github.com/Azure/bicep/blob/main/src/Bicep.Cli.E2eTests/src/local/jsonrpc.test.ts).
@@ -331,7 +368,7 @@ N/A
331368

332369
---
333370

334-
To connect to a named pipe on OSX/Linux :
371+
To connect to a named pipe on OSX/Linux:
335372

336373
# [Bicep CLI](#tab/bicep-cli)
337374

@@ -345,7 +382,7 @@ N/A
345382

346383
---
347384

348-
To connect to a named pipe on Windows :
385+
To connect to a named pipe on Windows:
349386

350387
# [Bicep CLI](#tab/bicep-cli)
351388

articles/azure-resource-manager/bicep/toc.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -621,7 +621,7 @@ items:
621621
href: /azure/templates/
622622
- name: Bicep CLI
623623
href: bicep-cli.md
624-
displayName: build,decompile,install,list-versions,list versions,upgrade,version,module,registry
624+
displayName: build,decompile,decompile-params, format,generate-params,install,jsonrpc,lint,list-versions,list versions,publish,restore,upgrade,version,module,registry
625625
- name: Azure CLI
626626
href: /cli/azure/resource
627627
- name: Azure PowerShell

0 commit comments

Comments
 (0)