为 Packer 的 Azure 构建器清理图像名称的函数

Function to clean image names for Packer's Azure builder

在为 AWS 构建打包程序映像时,有一个名为 clean_ami_name 的函数可以删除无效字符。对于 google,还有另一个名为 clean_image_name 的 google 云。

是否有 Azure 的等效项,或者人们总是在 managed_image_name 字符串中硬编码图像名称?

相关文档 here 提到了 AWS 和 GCP 但没有提到 Azure,我认为这是对 azure 映像构建的一个非常普遍的需求。

暂无此功能。请提交 feature request

目前没有这样的实现功能。但希望在路上:https://github.com/hashicorp/packer/pull/6558

您可以使用clean_resource_name函数。此函数将用“-”字符替换非法字符。示例:

"mybuild-{{isotime | clean_resource_name}}" 将变为 mybuild-2017-10-18t02-06-30z.

注意:有效的 Azure 图像名称必须匹配正则表达式 ^[^\W][\w-.)]{0,79}$

https://www.packer.io/docs/templates/engine#clean_resource_name-3