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

如何在PowerShell中抑制Az命令的CryptographyDeprecationWarning警告?

解决Azure CLI执行时的CryptographyDeprecationWarning警告问题

首先明确:你遇到的CryptographyDeprecationWarning: Blowfish has been deprecated警告来自Azure CLI本身(底层Python代码),而非PowerShell的ConvertFrom-Json命令,所以给ConvertFrom-Json加--WarningAction会报错(该命令不支持这个参数)。

以下是几种有效抑制警告的方法:

方法1:设置Python环境变量临时抑制特定弃用警告

在执行az命令前,先设置Python的警告过滤环境变量,仅对当前会话生效:

$env:PYWARNINGS = "ignore:CryptographyDeprecationWarning"
az webapp list --query "[].{name:name, resourceGroup:resourceGroup}" --output json | ConvertFrom-Json

方法2:临时全局调整PowerShell警告偏好(谨慎使用)

如果不想针对特定警告做过滤,可以临时修改PowerShell的警告处理规则,执行完成后再恢复原有设置:

# 保存原有警告偏好
$originalWarningPreference = $WarningPreference
# 设置为忽略所有警告
$WarningPreference = "SilentlyContinue"

# 执行目标命令
az webapp list --query "[].{name:name, resourceGroup:resourceGroup}" --output json | ConvertFrom-Json

# 恢复原有警告偏好
$WarningPreference = $originalWarningPreference

方法3:升级Azure CLI到最新版本

该警告多由Azure CLI依赖的cryptography库版本过旧导致,升级Azure CLI到最新版可从根源解决底层依赖问题:

az upgrade

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.18 17:42:01