azure-policy - 你如何在 Azure 中强制执行整数个标记值
问题描述
我的 Azure 政策拒绝评估以下错误的表达式。我认为问题在于,当您在门户中提供标记值时,即使打算传递整数值,它们也会作为字符串传递给 ARM。试图弄清楚如何为标签强制执行整数值作为结果
{
"field": "tags['Longevity']",
"less": 1
}
错误
"The policy assignment 'd9c1d0b06de841559a1cbafe' associated with the policy definition 'dee67dc2-7393-4c02-916f-92511146c970' could not be evaluated.
A 'less' or 'lessOrEquals' or 'greater' or 'greaterOrEquals' expression expects operands of same type for comparison. The supported types are string, integer, float, ISO 8601 datetime. Please either fix the
policy or remove the policy assignment to unblock. See https://aka.ms/policy-conditions for usage details."
解决方案
Microsoft 支持提供了一个答案 答案如下,可以按预期工作。必须使用 concat() 函数看起来像是逃避抱怨方括号内的方括号
{
"value": "[int(field(concat('tags[', 'Longevity', ']')))]",
"less": 0
},
推荐阅读
- r - 将列名向量传递给 data.table 中的函数
- laravel - 即使使用密钥,VeeValidate 也会验证不存在的字段错误
- node.js - 发出 post 请求时 npm 服务器关闭
- javascript - 如何在 Django 中保存范围滑块(多输入表单)的值
- sql - SQL - 如何在 XML 标记中插入唯一 ID
- c++ - 如果 g++ 已经对此进行了优化,那么向量化代码是否有用?
- github - 即使您有学分,如何在出错时从 git-lfs 获取大文件
- xml - XML / XSLT 1.0 - 如何对文本字符串使用 XSL 模板匹配?
- java - Generating Pyramid to Show Numbers in Module 10
- python - 移动最大值