gpt4 book ai didi

python - 如何使用azure cli和rest命令清除设置?

转载 作者:行者123 更新时间:2023-12-03 01:22:35 25 4
gpt4 key购买 nike

我想从 keyVaultReferenceIdentity 中删除设置

az rest --method PATCH --uri "${resourceId}?api-version=2021-01-01" --body "{""properties"":{""keyVaultReferenceIdentity"":null}}" --query properties.keyVaultReferenceIdentity -o json

但是为此我有

Unsupported Media Type({"error":{"code":"UnsupportedMediaType","message":"The content media type '' is not supported. Only 'application/json' is supported."}})

如果我添加标题:

$headers = @{"Content-Type" = "application/json" }


az rest --method PATCH --Headers $headers --uri "${resourceId}?api-version=2021-01-01" --body "{""properties"":{""keyVaultReferenceIdentity"":null}}" --query properties.keyVaultReferenceIdentity -o json

然后:

The command failed with an unexpected error. Here is the traceback:not enough values to unpack (expected 2, got 1)Traceback (most recent call last):File "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/util.py", line 506, in shell_safe_json_parseFile "json_init_.py", line 370, in loadsFile "json\decoder.py", line 337, in decodeFile "json\decoder.py", line 355, in raw_decodejson.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

The above exception was the direct cause of the following exception:

Traceback (most recent call last):File "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/util.py", line 815, in send_raw_requestFile "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/util.py", line 531, in shell_safe_json_parseazure.cli.core.azclierror.InvalidArgumentValueError: Failed to parse JSON: System.Collections.HashtableError detail: Expecting value: line 1 column 1 (char 0)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):File "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\knack/cli.py", line 231, in invokeFile "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/init.py", line 657, in executeFile "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/init.py", line 720, in _run_jobs_seriallyFile "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/init.py", line 691, in _run_jobFile "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/init.py", line 328, in callFile "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/command_operation.py", line 121, in handlerFile "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/command_modules/util/custom.py", line 16, in rest_callFile "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/util.py", line 818, in send_raw_requestValueError: not enough values to unpack (expected 2, got 1)

想法是清除keyVaultReferenceIdentity,但是我可以找到有效的语法和参数组合。

我找到了this issue在 GH 上,但没有帮助。

最佳答案

我用您的 CLI 命令进行了重现,并根据正确的格式进行了修改并修复,下面是 CLI 命令,我们可以在其中执行它而不会出现任何错误。

az rest --method patch --headers "{'Content-Type':'application/json'}" --uri/subscriptions/SUBSCRIPTION_ID/resourceGroups/RESOURCE_GROUP_NAME/providers/Microsoft.Web/sites/CheckingLogs0805?api-version=2015-08-01--body "{'properties': {'siteConfig': {'keyVaultReferenceIdentity':null}}}" --queryproperties.keyVaultReferenceIdentity -o json

因此,上述命令将修复您显示的错误消息(即 UnsupportedMediaType 和 JSONDecodeError

现在来解决清除“keyVaultReferenceIdentity”值的问题。这通常在创建时默认设置为 SystemAssigned。这些值取自托管身份。

请检查documentation对于值“系统身份”和“托管身份”。

从我修复的命令中,我们可以更改任何其他参数的值。

请参阅屏幕截图,因为我更改了“属性”的值:{“enabled”:true}

LocalScreenshot

关于python - 如何使用azure cli和rest命令清除设置?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68824995/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com