Repository navigation
Description
Bicep CLI commands for Azure operations
Today, Bicep CLI has no built-in deployment capabilities - it purely exposes compiler functionality such as bicep build or bicep lint. To provide deployment capabilities, Bicep CLI is tightly integrated into Azure CLI and Azure PowerShell, such that these tools invoke Bicep CLI for compilation, and deploy the compiled artifacts themselves.
This was the right decision at the time; it was made during the early phases of Bicep development, as we wanted a seamless experience to ease migration, and didn't want to invest energy in building a deployment experience ourselves. There are various things that have changed since this decision was made:
- Bicep is now a mature project with significant adoption. We have more energy to spend on providing a better CLI experience.
- New features such as
externalInputs, variable expressions, extension configs, snapshot files, and local deploy exist. .bicepparamfiles exist, and we have a better handle on some of the friction points associated with them.
One common concept that this proposal explores is simplifying the CLI experience by shifting configuration into the .bicepparam files. For example, rather than writing:
az deployment group create --subscription-id <foo> --resource-group <bar> --parameters a=<b>The user should be able to write:
bicep deployThe reasons why I think this is beneficial are:
- Reduces duplication in CI pipelines, and simplifies local reproducability.
- Gives the Bicep author more control over exposing configuration.
- Permits better validation during authoring, and a more coherent validation experience when deploying.
- Works well with other proposed commands such as
bicep what-ifandbicep destroy.
Goals
Main Goals
- Propose a set of
.bicepparamsyntax changes and new Bicep CLI command groups for managing deployments. - Propose an approach on rationalizing some of the more recent language features against each other (extension configs, external inputs), along with other proposed features such as
bicep deploy. - Propose improvements to visualization of deployments.
Other Goals
- Simplify migration from deployments to deployment stacks.
- Provide higher-quality visualization for errors, diagnostics, and real-time operations.
New Syntax
The syntax proposals are all changes to the .bicepparam file syntax.
Changes to using
Rather than relying on CLI arguments for configuration, configuration can be specified using a with clause:
using 'main.bicep' with {
mode: 'deployment'
scope: resourceGroup('f794b1c4-c575-4f8d-9eb0-1816c630c110', 'myRg')
name: 'main' // optional
}
param foo = 'bar'For Deployment Stacks:
using 'main.bicep' with {
mode: 'stack'
scope: resourceGroup('f794b1c4-c575-4f8d-9eb0-1816c630c110', 'myRg')
name: 'myStack'
actionOnUnmanage: {
resources: 'delete'
}
denySettings: {
mode: 'denyDelete'
}
}
param foo = 'bar'CLI usage:
bicep what-if main.bicepparam
bicep deploy main.bicepparam
# if using stacks
bicep destroy main.bicepparamNew readEnvVar() & readCliArg() functions
Use the new externalInput() function as a way of giving the author control over how run-time values are read.
Define readCliArg() and readEnvVar() as syntactic sugar for externalInput:
-
readCliArg(<arg>)would be syntactic sugar forexternalInput('sys.cliArg', <arg>) -
readEnvVar(<arg>)would be syntactic sugar forexternalInput('sys.envVar', <arg>) -
Example usage for
readEnvVar:var subscriptionId = readEnvVar('AZURE_SUBSCRIPTION_ID') using 'main.bicep' with { mode: 'deployment' scope: resourceGroup(subscriptionId, 'myRg') }
CLI experience:
export AZURE_SUBSCRIPTION_ID=f794b1c4-c575-4f8d-9eb0-1816c630c110 bicep what-if main.bicepparam bicep deploy main.bicepparam -
Example usage for
readCliArg:var subscriptionId = readCliArg('subscription-id') using 'main.bicep' with { mode: 'deployment' scope: resourceGroup(subscriptionId, 'myRg') }
CLI experience:
bicep what-if --arg-subscription-id f794b1c4-c575-4f8d-9eb0-1816c630c110 main.bicepparam bicep deploy --arg-subscription-id f794b1c4-c575-4f8d-9eb0-1816c630c110 main.bicepparam
These functions would be valid anywhere in the param file - not just in the scope field. For example:
using 'main.bicep' with {
mode: 'deployment'
scope: resourceGroup('f794b1c4-c575-4f8d-9eb0-1816c630c110', 'myRg')
}
type EnvironmentType = 'test' | 'prod'
var environment EnvironmentType = readCliArg('env-name')
var config = {
test: ...
prod: ...
}[environment]
param envSuffix = config.suffixUsage:
bicep deploy --arg-env-name test
bicep deploy --arg-env-name prodNew CLI Commands
bicep deploy
Initiates a deployment to Azure.
Provides a clean interface for tracking operations in real time and visualizing failures:
bicep what-if
Runs a what-if on Azure and reports results. Can also be used for validation only without returning results.
bicep destroy
Deletes a Deployment Stack. Only valid if the .bicepparam file has been configured as a Stack with the mode property.
Changes to existing CLI Commands
bicep local-deploy
Remove this command group entirely, and just have "Local" be available under the bicep deploy command.
bicep snapshot
Align with the arguments proposed for the new CLI command groups (bicep deploy etc).
Other notes
Deploy Pane
If accepted, the Deployment pane should be updated to operate with this new form of configuration.
Trying this out
This functionality is currently available on an experimental branch. See here for information on previewing it.
deploy.mov
Open Questions
- Does the concept of "CLI Arguments" (as opposed to parameters) feel confusing?
- Could we simplify further by avoiding the need to type the file name in cases where it's unambiguous (e.g.
bicep deployif there's only a single.bicepparamfile in the current directory)? - How would we rationalize this with the experience already in Azure CLI & Azure PowerShell?
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsTodo
Activity
slavizh commentedon Sep 2, 2025
The changes looks ok to me but I would like to touch on some points:
With this new syntax I would guess you will be able to do New-AzSubscriptionDeployment point to the Bicep param file and not having to provide parameters like location, name, etc. (that are required) if the bicep param file already has the values? If that is the case that brings the situation to context login. With Az PS it very much depends the context of the subscription when deployed. If you are not switched to the correct context the deployment will not happen. Will bicep cli underneath switch the correct context or this is something we will have to do as we currently do? Or may be third approach all the Deployment PS commands will be made in some way that the context does not matter and you can easily deploy to any context as long as it is specified in bicep param? BTW based on the scope you will have different parameters. For example Location is required when deploying at subscription or management group scope. Deployment stacks also have some other different parameters based on the scope. It will also be nice if you can define the scope for subscriptions and management groups based on their display name in addition to their IDs. I know that the display names are not unique but if you have subscriptions or management groups with the same names it is questionable how and why you use bicep. There should be possibility for Snapshot commands in Az CLI and PS in the future as well.
With Az PS you can use the verbose switch and that is functionality that I do not see fully in bicep cli. In the video it seems that there is some progress but the progress seems like very rough implementation. Could be because it is preview but I would like to understand more how it will work and propose some things. From the video it seems to me that progress is shown only modules/deployments. I would want to see actual resources with resource types as you can with -Verbose switch. Additionally it seems only the progress of the main module is shown and once that is finished it shows the end result of the deployments within that module. I would like to see all modules/resources progress during their deployment not wait to the main module to finish to show all the result. The point of progress is to show you exactly what is happening at what time. Another important thing is that progress to work within CI/CD - Azure DevOps/GitHub so you can see the progress when you are running deployment in a pipeline.
Currently when you show results of what-if in Azure DevOps pipeline there is no proper coloring. As far as I understand this is partially due to DevOps pipelines not supporting the format that is used in Az PS commandlets but I would like that to be resolved somehow for bicep cli as I can see there is not only coloring in what-if results but also for deployment progress. I guess one option to support the color format use in DevOps or being able to convince DevOps to invest in the color format use by Az PS and presumably by bicep cli.
I have already mentioned the thing you can do with -Verbose to follow the progress but there are some other good things with Az PS. Things like being able to get results in object format. Such results are what-if results, deployment results, errors, etc. For bicep cli would be good if output and errors are in json format so we can easily convert them to PS object and work with them. Also would be good if these results have the same or very similar format used in Az PS commands so in case we decide to adopt fully bicep cli for the deployments we can do that in an easy way.
Az PS modules support the ability to install multiple versions and pick specific versions to use. Note that this capability is not available in Az CLI but for Az PS this allows for easier adoption when there are breaking changes or bugs. For example you can have one version of a script use Az v 13.0 and another version of a script using Az v 15.0 running on the same hosts/agents. I think there was a separate topic around that for bicep cli. Do not remember the exact issue number. I for sure have mentioned that scenario there for having the ability to have multiple versions of bicep cli installed and controlling the usage which version based on bicepconfig.json.
If I understand correctly this will be non-breaking change as you can define using with 'with' and without 'with'?
One thing to think about this scenario is the possibility that the referenced module is in container registry located in different tenant where the deployment is happening. In that case it is unclear how you will be able deploy as presumably the deployment would require pulling the module from the registry locally before starting the deployment when done in CI/CD. Not sure how wide spread is that scenario but for us it is. We currently overcome this by having one task that downloads the module from the container registry and another task that reads bicepparam file and replace the value in using with the locally downloaded location of the main.json. You might also want to add some setting the using syntax to always download the module (force) when doing deployment instead of picking it from the cache. This relates to scenarios where you publish hotfix and minor versions of a module to the same tag to avoid end users updating their files even for small issues. That way you will make sure that you deploy with the latest version instead of some older cache version that does not contain the hotfix.
Related to the open questions:
lumunro commentedon Sep 2, 2025
Some great ideas Anthony Martin (@anthony-c-martin)
Some additional items for the wish list which may improve even further. Not sure which would be best way to set these, maybe via param and/or in
bicepconfig.jsonmaikvandergaag commentedon Sep 2, 2025
First off, it is an excellent proposal and a good way forward for Bicep that offers a lot more opportunities.
Regarding the questions:
Does the concept of "CLI Arguments" (as opposed to parameters) feel confusing?
No, it does not. Would be great if you were able to supply default values as, for example: readCliArg(, 'default-value')
Could we simplify further by avoiding the need to type the file name in cases where it's unambiguous (e.g. Bicep deploy if there's only a single .bicepparam file in the current directory)?
In our deployments mechanisms we explicitly supply the files that we are deploying. Like Stanislav Zhelyazkov (@slavizh) mentiones what happens when there are multiple files in the repo?
How would we rationalize this with the experience already in Azure CLI & Azure PowerShell?
The Bicep CLI will be an additional approach where you pick what is needed for your situation. Hopefully, it works in line with what is already there (PowerShell / CLI). Ultimately, this should be consolidated in the future, where PS and the AZ CLI use the DBC deploy version.
pazdedav commentedon Sep 8, 2025
What a great proposal. I really like the direction, where this is going, resembling Terraform or AZD flows and arguments.
As for the specific questions you asked, Anthony Martin (@anthony-c-martin):
Does the concept of "CLI Arguments" (as opposed to parameters) feel confusing?
To me, it isn't confusing, as it is quite common in other CLI tools. Having the ability to control the entire lifecycle in this way would be an excellent improvement.
Could we simplify further by avoiding the need to type the file name in cases where it's unambiguous (e.g. bicep deploy if there's only a single .bicepparam file in the current directory)?
It is great that we no longer need to specify the template filename, since we are (or should be) referencing it in the
.bicepparamfile, but I would still prefer clarity over simplicity and require the input for the parameter file that contains other configuration (RGs, location) as described in the proposal.How would we rationalize this with the experience already in Azure CLI & Azure PowerShell?
What I am about to describe would be quite controversial, but I wouldn't even mind a scenario, where deployment operations of IaC templates are "removed" from AZ CLI and Az PowerShell (or replaced with aliases to Bicep CLI), letting them handle imperative operations and commands only and "lift" Bicep CLI to become the only deployment CLI tool for declarative deployments. Have a separation of duties between these two worlds. I do appreciate there are tons of dependencies making such a bold move rather complex.
shenglol commentedon Sep 16, 2025
Instead of extending the using statement to support a with clause, I wonder if it would make sense to adopt the syntax we’ve been considering for Bicep deploy:
For deployment stacks mode, we can use a decorator:
IMHO this object-style syntax simplifies things compared to individual parameter assignments. It also makes parameter composition easier if we allow importing shared variables, for example:
Supporting this in main.bicepparam would make it compatible with .bicepdeploy files. It could also serve as a natural step toward migrating to .bicepdeploy and gradually deprecating .bicepparam files.
Experimental `bicep deploy`, `bicep what-if` and `bicep teardown` com…
anthony-c-martin commentedon Sep 18, 2025
Thanks Stanislav Zhelyazkov (@slavizh), lumunro, Maik van der Gaag (@maikvandergaag), David Pazdera (@pazdedav), Shenglong Li (@shenglol) for the very detailed feedback!
This'll be available as an experimental feature in the upcoming release, and I am planning on addressing some of the detailed ideas raised here in a follow-up iteration.
maikvandergaag commentedon Sep 18, 2025
Anthony Martin (@anthony-c-martin) Cool! Let us know if there is something we could help with.
marsontret commentedon Sep 22, 2025
Does the concept of "CLI Arguments" (as opposed to parameters) feel confusing?
--arg-prefix. I would prefer passing a set of key/value pairs to--args- for e.g.--args "subscription-id=f794b1c4-c575-4f8d-9eb0-1816c630c110" - similar to how--parameters` work.--parametersflag for when a.bicepparamisn't being passed.Could we simplify further by avoiding the need to type the file name in cases where it's unambiguous (e.g.
bicep deployif there's only a single.bicepparamfile in the current directory)?How would we rationalize this with the experience already in Azure CLI & Azure PowerShell?
bicepcommand groupslavizh commentedon Sep 25, 2025
Shenglong Li (@shenglol) Overall both can be supported if you ask me. And instead of coming with another file extension all could be possible within bicpeparam files. That way no deprecation will be needed and will make it easier for end users. New file format will require all third party to update their syntax highlighting and the adoption of bicepparam is not great when first party service like Azure DevOps hasn't adopted proper highlighting for that extension.
Anthony Martin (@anthony-c-martin) one additional thing I can propose is to make deployment stacks the default option and classic deployments an opt-in. That is of course if you want folks to signal adoption of deployment stacks.
slavizh commentedon Sep 25, 2025
Shenglong Li (@shenglol) also for me personally there is a better reading of the code when the parameters are separate from the deployment information.
shenglol commentedon Sep 25, 2025
Stanislav Zhelyazkov (@slavizh) Yeah supporting both probably makes more sense. Given the broad adoption of bicepparams at this moment, it’s too late and expensive to consider deprecating it.
I agree that separating deployment info from parameters can improve readability to some extent. However, I think having a single deploy object is overall more concise, easier to work with. Since the syntax is already very close to the existing module syntax, it should feel familiar and easy to read for most people. Also, the object is directly aligned with the Deployments REST API schema.
What really frustrates me about the current Bicep params syntax is how inconsistent and fragile it feels. Every time we want to add new functionality, we end up having to invent another piece of syntax. For example, parameter reuse required introducing
extendsbecause the original design doesn’t support composition. More recently, when we added extension configs support, we had to introduce yet another syntax:With the addition of
using with, a complete .bicepparam file might look like this:By comparison, the equivalent deploy object feels less fragile and more consistent:
Another advantage of the deploy object approach is how straightforward it makes overriding parameters and scopes. For example:
slavizh commentedon Sep 26, 2025
Shenglong Li (@shenglol) I cannot comment much on the k8s extension as I have not used it much, I have only used the graph one extensively. I never got the concept of kubeconfig and why it was done that way. If I understand correctly kubeconfigs is some kind of credential to log to the kubernetes clusters. I did not understand why this had to be a separate configuration rather a property in each resource deployment. Additionally using something like credentials instead of user assigned identities to login seems so legacy to me but may be that is me not understanding k8s fully. Anyway that is a different topic. Overall these are valid points. My bicep usage is more advanced (or different) than most examples you will see over Internet as we tend to describe our parameters in hierarchical way where at the top we only have 2-3 parameters. So if we take APIM at top we will define resource group and under the resource group, APIM service, within the APIM service we will have the option to define multiple APIs, withing the APIs we will have the option to define multiple operations and so on. Of course within every object you will have multiple parameters/properties of different types configuring different settings for the resource. Additionally the scoping in such scenarios I think is not applicable for me as we deploy at subscription or management group scope always and never at resource group as we either deploy the resource group with the module or chose the resource group for deployment via the parameters. The proposed syntax for me it seems more like another version to deploy modules as theoretically you can have multiple deploy statements (and even having dependencies between them) and when executed via bicep deploy, deployment will start for each of them at the context provided. So in practice that is already possible via current templates/modules and the only difference is that we do not have bicep deploy and a way to switch the context based on what is configured. The context thing comes from Az PS where you have to set specific context (subscription) to do deployments or manage any resources in that subscription and you can only do deployments to other subscriptions if you switch the context first. Note that I am not opposing the idea just laying some thoughts. There is probably also a third option: using statement stays as it is, deploy statement is added and if you do not provide main.bicep or link to container registry module to the deploy statement it just takes the one defined in using. That is like middle ground where you do not have breaking change but still new deploy statement is added with all of its benefits. Of course the syntax have to take into account if param is defined or if deploy with no reference to module is defined. You will have to use one or the other. And of course there could be an option to define multiple deploy statements but only one of them should not have reference to modules. If dependencies between deploy statements have to be made that will require having reference names and most likely supporting loops. That of course will bring deploy very close (if not identical) to how you define modules in templates but of course the difference will be that deploy is defined in bicepparam files and it can be executed with bicep deploy command.
Gijsreyn commentedon Sep 28, 2025
How does the Bicep CLI authenticate against Azure when deploying? Does it still need AZ CLI or Azure PowerShell to get a token?
shenglol commentedon Sep 30, 2025
Stanislav Zhelyazkov (@slavizh) We’re working on a new version of the k8s extension where users will only need to provide a managed identity ID and an AKS cluster resource ID in the config, but yeah that’s a separate topic.
Could you share some examples of the .bicepparam files? My guess is that extends might be heavily used to build the parameter hierarchy. If that’s the case, I think using a deploy statement combined with variable imports could be an easier way to structure the hierarchy.
The reason is that extends essentially implements an inheritance pattern, whereas deploy + variable import gives you inheritance plus composition. Another advantage is that typed variables provide type checking and completions, whereas parameter assignments alone don’t enforce types unless the parameter file is linked to a Bicep file with using, which is often the case for shared parameter files.
I’ll use the following example to illustrate the idea. Suppose you have the following parameter files hierarchy:
In this setup, you will only get type checking and completions in child.bicepparam. As the hierarchy grows more complex, it becomes harder to follow and diagnose errors.
The same setup can be achieved with a deployment statement plus shared variable imports, which gives you type checking and better composability:
Another key advantage of the latter approach is that it encourages a flattened structure rather than a tree. For example,
parent2.bicepdoes not need to inherit fromroot.bicep, unlike in the.bicepparamexample. In other words, each node in the inheritance chain can be separated into components at the same level, with their composition deferred to the child parameter file, which encourages separation of concerns. For more complex scenarios, inheritance can still be used to maximize code reuse.shenglol commentedon Sep 30, 2025
It uses the auth provider specified in the cloud section of
bicepconfig.json, so it can be Azure CLI, Azure PowerShell, service principal environment variables, etc.Gijsreyn commentedon Oct 1, 2025
So, that would still mean this command relies on external tools/locations?
slavizh commentedon Oct 2, 2025
Shenglong Li (@shenglol) Below you can see example bicepparam file. We are not using currently extends as it is very limited and not suitable for our case. Note that we are using using statement which points to our modules and these modules have types so you know exactly at each level of the hierarchy what are the required parameters/properties and which not, their descriptions, possible values and types.
In our case it makes more sense if using variables import. That way we can put variables in the values for the parameters we use and still VSC will tell us if the variable we use in the parameter's value is correct or not. For example if the variable is int and the parameter is string that will throw error in VSC. The only thing missing with variable imports is the ability not to import the whole variable but only parts of it. For example if the variable is an object and if I want to import only a parameter/property of that object I should be able to do it. And the other more confusing part for end users is that in order to use variables and import them these have to be in bicep file not bicepparam file. Also if you click on any of the variables used should lead you to the file and that variable. This currently works only for the variable but not on child parameters of the variable if it is object or array.
Overall I find extend too simple for too simple scenarios but that is another topic.
shenglol commentedon Oct 3, 2025
It depends on what authentication provider you use. If it's service principal, not Azure CLI / Pwsh is needed.
Gijsreyn commentedon Oct 3, 2025
Thanks for the response. That would mean the user still always has to install some tool to get this working. Pwsh isn't shipped OOBE in any platform (Windows, macOS, or Linux). I would like to see the command not to rely on any other tooling.
shenglol commentedon Oct 3, 2025
Got it. I think it makes sense to add support for this, since we’re already using
Azure.Identity, which provides InteractiveBrowserCredential. It could also be valuable in other scenarios, such as restoring remote modules. Gijs Reijn (@Gijsreyn), would you mind opening a new issue to track it?Gijsreyn commentedon Oct 3, 2025
Sure thing!
Add a Bicep recipe for Radius.Compute/containerImages (radius-project…