Azure App Config导入CLI:使用-y flag时如何保留预览显示
问题:Azure App Config自动化导入时保留预览日志
我在更新Azure App Config时使用以下命令:
az appconfig kv import -n my-app-config-store --label test -s file --format json --path "file.json" --content-type "application/json" --separator : --depth 3
执行后会弹出预览提示:
---------------- Key Values Preview ---------------- Updating: - {"key": "URL", "value": "\"www.test.myapp.com\""} + {"key": "URL", "value": "\"www.test2.myapp.com\""} Do you want to continue? (y/n): y
为实现流水线自动化,我添加了-y参数跳过确认,但此时无法再看到预览内容:
az appconfig kv import -n my-app-config-store --label test -s file --format json --path "file.json" --content-type "application/json" --separator : --depth 3 -y
我需要将预览信息记录到日志中,请问有没有办法在使用-y参数的同时仍显示预览?
尝试过的方法及错误
我试过以下命令:
az appconfig kv import -n my-app-config-store --label test -s file --format json --path "file.json" --content-type "application/json" --separator : --depth 3 && yes | head -n 1
但得到错误提示:
Unable to prompt for confirmation as no tty available. Use --yes.
(翻译:无法提示确认,因为没有可用的终端交互环境,请使用--yes参数。)
解决方案
可以通过两步操作实现需求:
- 先执行带
--dry-run参数的模拟导入命令,输出预览信息到日志:
az appconfig kv import -n my-app-config-store --label test -s file --format json --path "file.json" --content-type "application/json" --separator : --depth 3 --dry-run
这条命令会输出和手动执行时一致的预览内容,但不会实际修改配置。
- 再执行带
-y参数的实际导入命令:
az appconfig kv import -n my-app-config-store --label test -s file --format json --path "file.json" --content-type "application/json" --separator : --depth 3 -y
如果需要合并成一条命令执行,用分号分隔即可:
az appconfig kv import -n my-app-config-store --label test -s file --format json --path "file.json" --content-type "application/json" --separator : --depth 3 --dry-run ; az appconfig kv import -n my-app-config-store --label test -s file --format json --path "file.json" --content-type "application/json" --separator : --depth 3 -y
这样流水线执行时,会先输出预览信息到日志,再自动完成配置导入,全程无需人工交互。
内容的提问来源于stack exchange,提问作者JS noob
相关产品推荐
相关产品推荐

