Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create Extendable Bicep Params File Article #14865

Merged
merged 7 commits into from
Aug 26, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/experimental-features.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Requires `extensibility` to be enabled. If enabled, users are able to fetch the
The provider definitions also support aliasing via `bicepconfig.json` similar to [`moduleAliases`](https://learn.microsoft.com/azure/azure-resource-manager/bicep/bicep-config-modules#aliases-for-modules). For example `provider 'br/public:[email protected]' as az`.

### `extendableParamFiles`
Enables the ability to extend bicepparam files from other bicepparam files.
Enables the ability to extend bicepparam files from other bicepparam files. For more information, see [Extendable Bicep Params Files](./experimental/extendable-param-files.md).

### `extensibility`
Allows Bicep to use a provider model to deploy non-ARM resources. Currently, we support Kubernetes provider ([Bicep extensibility Kubernetes provider](https://learn.microsoft.com/en-us/azure/azure-resource-manager/bicep/bicep-extensibility-kubernetes-provider)) and Microsoft Graph provider ([Bicep templates for Microsoft Graph](https://aka.ms/graphbicep)).
Expand Down
63 changes: 63 additions & 0 deletions docs/experimental/extendable-param-files.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# Using the Extendable Bicep Parameters Feature (Experimental!)
stephaniezyen marked this conversation as resolved.
Show resolved Hide resolved

## What is it?

Extendable Bicep Parameter Files is a feature that allows you to extend `.bicepparam` files from another `.bicepparam` file in order to reuse parameters across multiple deployments.
stephaniezyen marked this conversation as resolved.
Show resolved Hide resolved

When using extendable bicep parameter files, you will have a `base.bicepparam` file that can be used by multiple `.bicep` and `.bicepparam` files.
stephaniezyen marked this conversation as resolved.
Show resolved Hide resolved

The `base.bicepparam` file will link to a `shared.bicepparam` file, which will refer to a `main.bicep` file and your `base.bicepparam file`. In this case, you will be able to reuse and refer to this `base.bicepparam` file multiple times.
stephaniezyen marked this conversation as resolved.
Show resolved Hide resolved

## Using
stephaniezyen marked this conversation as resolved.
Show resolved Hide resolved

`main.bicep` This is your main bicep file, which will define your parameters for deployment.

```bicep
param foo string
stephaniezyen marked this conversation as resolved.
Show resolved Hide resolved
param foo string
stephaniezyen marked this conversation as resolved.
Show resolved Hide resolved
```

`base.bicepparam` This is your base bicepparam file, which can be reused by multiple shared.bicepparam files and in multiple deployments.

```bicep
using none

param foo = 'foo'
param bar = 'bar'
```

`shared.bicepparam` This is your shared bicepparam file, which will refer to one main.bicep file and one base.bicepparam file. Any parameter definition in this file will override all previous definitions.
stephaniezyen marked this conversation as resolved.
Show resolved Hide resolved
stephaniezyen marked this conversation as resolved.
Show resolved Hide resolved

```bicep
using 'main.bicep'

extends 'base.bicepparam'

param foo = 'bar'
param baz = foo
stephaniezyen marked this conversation as resolved.
Show resolved Hide resolved
```

Compiled json output
stephaniezyen marked this conversation as resolved.
Show resolved Hide resolved

```bicep
{
foo: 'bar'
bar: 'bar'
baz: 'bar'
}
```

**Note**: As `foo` is defined in both `base.bicepparam` and `shared.bicepparam` files, any parameter definitions in the **`shared.bicepparam`** file will override the definitions of the parameter in **both** the `main.bicep` and `base.bicepparam` files.
stephaniezyen marked this conversation as resolved.
Show resolved Hide resolved

alex-frankel marked this conversation as resolved.
Show resolved Hide resolved
## Limitations

We do not have support for:

* variables
* import/export function
* Multiple extends statements
* Ability to merge (union) parameters of type object and array
stephaniezyen marked this conversation as resolved.
Show resolved Hide resolved

## Raising bugs or feature requests

Please raise bug reports or feature requests under [Bicep Issues](https://github.com/Azure/bicep/issues) as usual.
Loading