Azure.Bicep.RpcClient
0.42.1
Prefix Reserved
dotnet add package Azure.Bicep.RpcClient --version 0.42.1
NuGet\Install-Package Azure.Bicep.RpcClient -Version 0.42.1
<PackageReference Include="Azure.Bicep.RpcClient" Version="0.42.1" />
<PackageVersion Include="Azure.Bicep.RpcClient" Version="0.42.1" />
<PackageReference Include="Azure.Bicep.RpcClient" />
paket add Azure.Bicep.RpcClient --version 0.42.1
#r "nuget: Azure.Bicep.RpcClient, 0.42.1"
#:package Azure.Bicep.RpcClient@0.42.1
#addin nuget:?package=Azure.Bicep.RpcClient&version=0.42.1
#tool nuget:?package=Azure.Bicep.RpcClient&version=0.42.1
Azure Bicep RPC Client
A .NET library for programmatically interacting with the Bicep CLI via JSON-RPC.
Note: While this package is publicly available on nuget.org, it is not officially supported. Breaking changes may be introduced at any time.
Getting started
Install the package
dotnet add package Azure.Bicep.RpcClient
Initialize the client
The BicepClientFactory handles downloading the Bicep CLI (if needed) and establishing a JSON-RPC
connection. By default, binaries are cached under ~/.bicep/bin.
using Bicep.RpcClient;
var factory = new BicepClientFactory();
// Download (or reuse) the latest Bicep CLI and connect
using var bicep = await factory.Initialize(BicepClientConfiguration.Default);
Pin a specific Bicep version
using var bicep = await factory.Initialize(new() {
BicepVersion = "0.38.5"
});
Use an existing Bicep installation
using var bicep = await factory.Initialize(new() {
ExistingCliPath = "/usr/local/bin/bicep"
});
Available operations
All methods are async, accept an optional CancellationToken, and communicate with the Bicep CLI
over JSON-RPC.
Compile
Compiles a .bicep file into an ARM template JSON string.
var result = await bicep.Compile(new("./main.bicep"));
if (result.Success)
{
// result.Contents contains the ARM template JSON
Console.WriteLine(result.Contents);
}
CompileParams
Compiles a .bicepparam file into ARM deployment parameters. You can optionally override parameter
values.
var result = await bicep.CompileParams(new(
"./main.bicepparam",
new Dictionary<string, JsonNode>()));
if (result.Success)
{
Console.WriteLine(result.Parameters); // ARM parameters JSON
Console.WriteLine(result.Template); // ARM template JSON (if resolvable)
// result.TemplateSpecId is set when the params file references a template spec
}
Format
Formats a Bicep file according to the standard Bicep formatting rules. Requires Bicep CLI 0.37.1 or later.
var result = await bicep.Format(new("./main.bicep"));
File.WriteAllText("./main.bicep", result.Contents);
GetMetadata
Retrieves parameters, outputs, exports, and file-level metadata from a Bicep file.
var result = await bicep.GetMetadata(new("./main.bicep"));
foreach (var param in result.Parameters)
{
Console.WriteLine($"param {param.Name}: {param.Type?.Name} — {param.Description}");
}
foreach (var output in result.Outputs)
{
Console.WriteLine($"output {output.Name}: {output.Type?.Name}");
}
foreach (var export in result.Exports)
{
Console.WriteLine($"@export() {export.Kind} {export.Name}");
}
foreach (var meta in result.Metadata)
{
Console.WriteLine($"metadata {meta.Name} = '{meta.Value}'");
}
GetFileReferences
Returns all file paths referenced by a Bicep file — modules, loaded files, and the file itself.
var result = await bicep.GetFileReferences(
new("./main.bicep"));
foreach (var path in result.FilePaths)
{
Console.WriteLine(path);
}
GetDeploymentGraph
Returns the resource dependency graph for a Bicep file, useful for visualization.
var result = await bicep.GetDeploymentGraph(
new("./main.bicep"));
foreach (var node in result.Nodes)
{
var existing = node.IsExisting ? " (existing)" : "";
Console.WriteLine($" {node.Name}: {node.Type}{existing}");
}
foreach (var edge in result.Edges)
{
Console.WriteLine($" {edge.Source} -> {edge.Target}");
}
GetSnapshot
Generates a snapshot of a .bicepparam file with Azure deployment context.
Requires Bicep CLI 0.36.1 or later.
var result = await bicep.GetSnapshot(new(
"./main.bicepparam",
new(
TenantId: null,
SubscriptionId: "00000000-0000-0000-0000-000000000000",
ResourceGroup: "my-rg",
Location: "eastus",
DeploymentName: "my-deployment"),
ExternalInputs: null));
Console.WriteLine(result.Snapshot);
GetVersion
Returns the version of the connected Bicep CLI. The result is cached for subsequent calls.
var version = await bicep.GetVersion();
Console.WriteLine($"Bicep CLI version: {version}");
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
| .NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- System.Collections.Immutable (>= 10.0.5)
- System.Text.Json (>= 10.0.3)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.