You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

在App Configuration中添加Microsoft.Targeting用户时遇验证错误

解决Microsoft.Targeting筛选器添加用户的错误及Az Cli参数问题

问题核心

你遇到两个关键问题:

  1. 给Microsoft.Targeting筛选器添加新用户时触发验证错误,提示:Some of your feature flags are not valid. Please navigate to Advanced Edit for more details.
  2. 使用Az Cli更新筛选器参数时,存在格式错误,且无法正确读取JSON文件内容传递给--function-parameters参数

修复步骤

一、修正Targeting筛选器的JSON结构

先检查高级编辑里的JSON格式,必须严格匹配Azure的要求:

  • users必须是字符串数组,每个元素为用户ID/UPN,无语法错误
  • defaultRolloutPercentage是数字类型,不能加引号
  • groups为空数组时需保留[]结构
    示例正确结构:
{
  "users": ["user1@contoso.com", "new-user@contoso.com"],
  "groups": [],
  "defaultRolloutPercentage": 0
}

二、Az Cli命令的正确用法

1. 直接传递参数(短内容场景)

根据操作系统对JSON进行转义:

  • Windows PowerShell:
az feature-flags update --name "你的功能标志名" --resource-group "你的资源组" --subscription "你的订阅ID" --filter "Microsoft.Targeting" --function-parameters '{\"users\": [\"new-user@contoso.com\"], \"groups\": [], \"defaultRolloutPercentage\": 0}'
  • Linux/macOS Bash:
az feature-flags update --name "你的功能标志名" --resource-group "你的资源组" --subscription "你的订阅ID" --filter "Microsoft.Targeting" --function-parameters '{"users": ["new-user@contoso.com"], "groups": [], "defaultRolloutPercentage": 0}'

2. 从JSON文件读取参数(长内容场景)

步骤1:创建targeting-params.json文件,内容如下:

{
  "users": ["new-user@contoso.com"],
  "groups": [],
  "defaultRolloutPercentage": 0
}

步骤2:执行Az Cli命令:

  • Windows PowerShell:
az feature-flags update --name "你的功能标志名" --resource-group "你的资源组" --subscription "你的订阅ID" --filter "Microsoft.Targeting" --function-parameters (Get-Content -Raw .\targeting-params.json)
  • Linux/macOS Bash:
az feature-flags update --name "你的功能标志名" --resource-group "你的资源组" --subscription "你的订阅ID" --filter "Microsoft.Targeting" --function-parameters "$(cat targeting-params.json)"

三、验证修复

执行命令后,进入功能标志的高级编辑界面,确认JSON结构与预期一致,再尝试添加用户,验证错误是否消失。

内容的提问来源于stack exchange,提问作者Diwakar Reddy

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.03 18:23:10