Azure / bicep
- четверг, 3 сентября 2020 г. в 00:24:47
C#
Note: Bicep is currently an experimental language and we expect to ship breaking changes in future releases. It is not yet recommended for production usage. Please take a look at the known limitations prior to opening any issues.
Bicep is a Domain Specific Language (DSL) for deploying Azure resources declaratively. It aims to drastically simplify the authoring experience with a cleaner syntax and better support for modularity and code re-use. Bicep is a transparent abstraction over ARM and ARM templates, which means anything that can be done in an ARM Template can be done in bicep (outside of temporary known limitations). All resource types
, apiVersions
, and properties
that are valid in an ARM template are equally valid in Bicep on day one.
Bicep compiles down to standard ARM Template JSON files, which means the ARM JSON is effectively being treated as an Intermediate Language (IL).
type
and/or apiVersion
in Bicep.To get going with bicep, start by installing the tooling.
Once the tooling is installed, you can start the bicep tutorial, which walks you through the structure and capabilities of bicep, deploying bicep files, and converting an ARM template into the equivalent bicep file.
Alternatively, you can try the Bicep Playground.
First, author your Bicep code using the Bicep language service as part of the Bicep VS Code extension, then compile that code into an ARM template using the Bicep CLI:
bicep build ./main.bicep
You should see the compiled template main.json
get created in the same directory as main.bicep
. Now that you have the ARM Template, you can use all existing ARM Template tooling such as what-if, the ARM Tools Extension, and the deployment CLI commands.
You can now deploy this template via any method you would like such as:
az deployment group create -f ./main.json -g my-rg
[...]
expressions syntax required
parameters('myParam')
)"location"
)'${namePrefix}-vm'
instead of concat(parameters('namePrefix'), '-vm')
type
and apiVersion
explicitly.aks.properties.fqdn
instead of reference(parameters('aksName')).properties.fqdn
)variables
, resources
, outputs
) can be declared anywhere.
"parameters": {}
object, variables had to be declared together in one "variables": {}
object, etc.dependsOn
in the compiled ARM Template if the symbolic name is used in another resouce declaration.copy
or condition
property [#185, #186]Microsoft.Resources/deployments
resource and using the templateLink
or template
property to insert the full ARM template) [#187]
['a', 'b', 'c']
) are not yet supportedAz
deployment cmdlets and az cli
deployment commandstype
structure and requiring a name
, you will not get errors for missing or incorrect properties in a resource declaration'/subscriptions/.../resourceGroups/.../providers/Microsoft.ManagedIdentity/...': {}
)Because we are now treating the ARM Template as an IL, we expect and encourage other implementations of IL (ARM Template) generation. We'll keep a running list of alternatives for creating ARM templates that may better fit your use case.
This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.opensource.microsoft.com.
When you submit a pull request, a CLA bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.
This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.