Azure / Azure/PSRule.Rules.Azure

[FEATURE] Improve performance of Bicep expansion with json-rpc

Open
#3,877 0 comments 0 reactions 1 assignee Claimed by @polatengin View on GitHub
feature: pre-flight-expansion
Dominant language
PowerShell
Stars
447
Forks
109
Avg merge
2d 19h
Merged PRs (30d)
23

Description

### Your suggestion

Currently PSRule wraps the Bicep CLI for expanding each Bicep module/ parameter file. For large repositories like AVM, this could take a lot of time for a full test and complex module dependencies.

A large contributor to this is the cold start of Bicep for each file.

To improve this let's add support for using the JSON-RPC that has been added to the CLI.

Intended behaviour:

- If feature is enabled, and expansion of Bicep is enabled start the Bicep JSON-RPC server.
- Any expansion requests are expanded by the JSON-RPC server.
- JSON-RPC server is terminates after PSRule runs.

Initially this should be a feature flagged code path that will opt-in to the new model (e.g. configuration `AZURE_BICEP_JSON_RPC=true`) disabled by default, which will be flipped in a future release.

## Considerations

- If the, an older version of the Bicep CLI is used that doesn't support the minimum version or JSON-RPC, error but revert to the old expansion method.
- The minimum supported version for JSON-RPC should be hard coded and will be bumped when the minimum contract changes.

### Alternatives

n/a

### Additional context

- https://learn.microsoft.com/en-us/azure/azure-resource-manager/bicep/bicep-cli-jsonrpc

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.