简体   繁体   English

Azure Bicep 与 ARM 模板的比较

[英]Azure Bicep comparison with ARM template

I read something about Azure Bicep, it is something new I feel -我读了一些关于 Azure Bicep 的东西,我觉得这是一种新的东西——

Azure Resource Manager and ARM Templates are written in a JSON syntax that can be cumbersome to work with. Azure 资源管理器和 ARM 模板是用 JSON 语法编写的,使用起来可能很麻烦。 Azure Bicep is a Domain Specific Language (DSL) that offers a transparent abstraction over Azure Resource Manager and ARM Templates that offers support for a cleaner code syntax with better support for modularity and code re-use. Azure Bicep 是一种域特定语言 (DSL),它提供对 Azure 资源管理器和 ARM 模板的透明抽象,支持更清晰的代码语法,更好地支持模块化和代码重用。 Azure Bicep offers a few improvements for authoring Azure IaC over the use of ARM Template JSON. Azure Bicep 为使用 ARM 模板 JSON 创作 Azure IaC 提供了一些改进。

I want to understand the comparison between ARM template and Azure Bicep like what are advantage and disadvantage, limitations and use cases for these two.我想了解 ARM 模板和 Azure Bicep 之间的比较,例如这两者的优缺点、限制和用例。

I think the official GitHub repository for Bicep has pretty much all the answers you mention in your question.我认为 Bicep 的官方 GitHub 存储库几乎包含您在问题中提到的所有答案。

Some extracts:部分摘录:

Bicep is a Domain Specific Language (DSL) for deploying Azure resources declaratively. Bicep 是一种域特定语言 (DSL),用于以声明方式部署 Azure 资源。 It aims to drastically simplify the authoring experience with a cleaner syntax, improved type safety, and better support for modularity and code re-use.它旨在通过更简洁的语法、改进的类型安全性以及更好地支持模块化和代码重用来极大地简化创作体验。 Bicep is a transparent abstraction over ARM and ARM templates Bicep 是对 ARM 和 ARM 模板的透明抽象

How is life better with Bicep?二头肌如何让生活更美好?

  • Simpler syntax when compared to equivalent JSON与等效的 JSON 相比,语法更简单
  • [...] [...]

Known limitations已知限制

  • No support for single-line object and arrays (ie ['a', 'b', 'c'])不支持单行对象和数组(即 ['a', 'b', 'c'])
  • [...] [...]

FAQ常问问题

Is this ready for production use?这准备好用于生产了吗? Yes.是的。 As of v0.3, Bicep is now supported by Microsoft Support Plans and Bicep has 100% parity with what can be accomplished with ARM Templates.从 v0.3 开始,Microsoft 支持计划现在支持 Bicep,并且 Bicep 与 ARM 模板可以实现的功能 100% 相同。 As of this writing, there are no breaking changes currently planned, but it is still possible they will need to be made in the future.在撰写本文时,目前没有计划中的重大更改,但将来仍有可能需要进行更改。

Update: Updated extracts because it is now production ready.更新:更新了摘录,因为它现在可以生产了。

I think the best way to think about BICEP is simply an easier and less error-prone process to generate ARM templates.我认为考虑 BICEP 的最佳方式只是一个更简单、更不容易出错的生成 ARM 模板的过程。 Ultimately, the BICEP tool is just a transpiler ie it turns BICEP files into a single ARM template that can be deployed in the way you're used to.最终,BICEP 工具只是一个转译器,即将 BICEP 文件转换为单个 ARM 模板,可以按照您习惯的方式进行部署。 It's not adding additional layers of abstraction, so you can always use the most recent resource manager API version and attributes.它不会添加额外的抽象层,因此您始终可以使用最新的资源管理器 API 版本和属性。

Having played with it a little, I'm pretty excited about it.玩了一会儿,我对它感到非常兴奋。 Before BICEP came along, I was using linked templates for modularity and re-using code wherever I could, but it was cumbersome to wrangle large and verbose JSON files.在 BICEP 出现之前,我使用链接模板来实现模块化并尽可能地重用代码,但是处理大而冗长的 JSON 文件很麻烦。

With the VSCode BICEP extension and the efforts Microsoft have put into intellisense and linting of BICEP, plus the ability to quickly see the ARM output, I think we'll enjoy significant productivity increases.有了 VSCode BICEP 扩展以及微软在 BICEP 的智能感知和 linting 方面所做的努力,加上快速查看 ARM 输出的能力,我认为我们将享受到显着的生产力提升。

In addition, the BICEP decompiler looks like a really useful migration tool to turn existing ARM templates into BICEP.此外, BICEP 反编译器看起来是一个非常有用的迁移工具,可以将现有的 ARM 模板转换为 BICEP。

ARM templates have been a source of frustration and woe in the past, but BICEP is huge improvement. ARM 模板在过去一直是令人沮丧和痛苦的根源,但 BICEP 是巨大的改进。 Obviously Terraform does great work in this area too, but unless you're specifically multi-cloud and multi-resource-provider, I believe BICEP offers a sensible approach.显然 Terraform 在这方面也做得很好,但除非你是专门的多云和多资源提供商,否则我相信 BICEP 提供了一种明智的方法。

BICEP is much more approachable than the ARM template syntax. BICEP 比 ARM 模板语法更容易理解。
BICEP is designed as a combination of Yaml/TS/Js formatting without needless punctuation. BICEP 被设计为 Yaml/TS/Js 格式的组合,没有不必要的标点符号。 Bicep is a markup language like CSS with loops, if's, ternary operations, and a VS Code intellisense plugin that validates syntax. Bicep 是一种类似于 CSS 的标记语言,带有循环、if、三元运算和验证语法的 VS Code 智能感知插件。 Bicep still requires the user to understand Azure Resource Manager "resources" (a Bicep term) but gives the devops monkey a much sweeter syntax sugar to work with than error prone json jibberish {","}; Bicep 仍然需要用户理解 Azure 资源管理器“资源”(一个 Bicep 术语),但为 devops 猴子提供了比容易出错的 json jibberish {","} 更甜蜜的语法糖; Bicep also adds support for comments which are not part of Json. Bicep 还增加了对不属于 Json 的评论的支持。 Bicep is also a bit safer to use with it's -c ("check sanity") since everything (by default) is scoped to the ResourceGroup level. Bicep 与 -c(“检查健全性”)一起使用也更安全,因为所有内容(默认情况下)都限定在 ResourceGroup 级别。

BICEP provides feature parity with ARM, because it is a transpiler that produces ARM templates but adds higher-level functionality such as loops, includes, symbolic references. BICEP 提供与 ARM 相同的功能,因为它是一个转译器,可生成 ARM 模板,但添加了更高级别的功能,例如循环、包含、符号引用。 ARM is the underlying language to bicep, it is also used by tools such as terraform, or self-managed K8 auto-scaling. ARM 是二头肌的底层语言,它也被 terraform 或自我管理的 K8 自动缩放等工具使用。

The one downside is that BICEP transpiles into ARM, so if you have bugs in your bicep code you might end up needing to learn ARM anyway to understand what happened.一个缺点是 BICEP 转译为 ARM,所以如果你的二头肌代码中有错误,你可能最终需要学习 ARM 以了解发生了什么。

The one downside is that BICEP transpiles into ARM, so if you have bugs in your bicep code you might end up needing to learn ARM anyway to understand what happened.一个缺点是 BICEP 转译为 ARM,所以如果你的二头肌代码中有错误,你可能最终需要学习 ARM 以了解发生了什么。

I think this shortcoming is easier than debugging when you run into problems with TF.我认为当您遇到 TF 问题时,这个缺点比调试更容易。

Currently, the relationship between ARM templates and BICEP is straightforward and one-to-one, which is very straightforward.目前ARM模板和BICEP的关系是直截了当的,一对一的,非常直白。 Unfortunately, working with Azure requires an understanding of Azure REST API Specifications and ARM Tempate.不幸的是,使用 Azure 需要了解 Azure REST API 规范和 ARM 模板。 But I like Bisp because I don't want to wrestle with ARM Tempate every time.但我喜欢 Bisp 因为我不想每次都和 ARM Tempate 搏斗。

Bicep made my Azure Life happy.二头肌让我的 Azure 生活变得快乐。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM