简体   繁体   English

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

[英]How to clear settings using azure cli and rest command?

I want to remove settings from keyVaultReferenceIdentity我想从keyVaultReferenceIdentity中删除设置

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

But for this I have但是为此我有

Unsupported Media Type({"error":{"code":"UnsupportedMediaType","message":"The content media type '' is not supported. Only 'application/json' is supported."}})不支持的媒体类型({“错误”:{“代码”:“UnsupportedMediaType”,“消息”:“不支持内容媒体类型''。仅支持'application / json'。”}})

If I add headers:如果我添加标题:

$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

then:然后:

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_parse File "json_ init _.py", line 370, in loads File "json\decoder.py", line 337, in decode File "json\decoder.py", line 355, in raw_decode json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)这是回溯:没有足够的值来解压(预期 2,得到 1)回溯(最后一次调用):文件“D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\ azure/cli/core/util.py”,第 506 行,在 shell_safe_json_parse 文件“ json_init_.py ”中,第 370 行,在加载文件“json\decoder.py”中,第 337 行,在解码文件“json\decoder.py”中。 py”,第 355 行,在 raw_decode json.decoder.JSONDecodeError:期望值:第 1 行第 1 列(字符 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_request File "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/util.py", line 531, in shell_safe_json_parse azure.cli.core.azclierror.InvalidArgumentValueError: Failed to parse JSON: System.Collections.Hashtable Error detail: Expecting value: line 1 column 1 (char 0)回溯(最近调用最后):文件“D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/util.py”,第 815 行,在 send_raw_request 文件中“D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/util.py”,第 531 行,在 shell_safe_json_parse azure.cli.core.azclierror.InvalidArgumentValueError 中:无法解析 JSON:System.Collections.Hashtable 错误详细信息:预期值:第 1 行第 1 列(字符 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 invoke File "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/ init .py", line 657, in execute File "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/ init .py", line 720, in _run_jobs_serially File "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/ init .py", line 691, in _run_job File "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/ init .py", line 328, in call File "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/command_operation.py", line 121, in handler File "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/command_modules/util/custom.py", line 16, in rest_call File "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cl追溯(最近调用最后):文件“D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\knack/cli.py”,第 231 行,在调用文件“D:\ a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/ init .py", line 657, in execute File "D:\a\1\s\build_scripts \windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/ init.py ",第 720 行,在 _run_jobs_serially 文件“D:\a\1\s\build_scripts\windows\artifacts\cli\ Lib\site-packages\azure/cli/core/commands/ init.py ”,第 691 行,在 _run_job 文件“D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure /cli/core/commands/ init .py”,第 328 行,在调用文件“D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/ command_operation.py”,第 121 行,在处理程序文件“D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/command_modules/util/custom.py”中,第 16 行, 在 rest_call 文件 "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cl i/core/util.py", line 818, in send_raw_request ValueError: not enough values to unpack (expected 2, got 1) i/core/util.py”,第 818 行,在 send_raw_request ValueError:没有足够的值来解压(预期 2,得到 1)

Idea is to clear keyVaultReferenceIdentity however I can find valid syntax and parameters combination.想法是清除keyVaultReferenceIdentity但是我可以找到有效的语法和参数组合。

I found this issue on GH but it didn't help.我在 GH 上发现了这个问题,但没有帮助。

I did a repro with your CLI command and modified according to correct format and fixed, below is the CLI command where we can execute it without getting any errors.我用你的 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}}}" --query properties.keyVaultReferenceIdentity -o json 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}}}" --query properties.keyVaultReferenceIdentity -o json

So, above command will fix the error messages which you have shown (ie, UnsupportedMediaType and JSONDecodeError因此,上面的命令将修复您显示的错误消息(即 UnsupportedMediaType 和 JSONDecodeError

Now coming to the question to clear the value of 'keyVaultReferenceIdentity'.现在提出清除“keyVaultReferenceIdentity”值的问题。 This usually sets by default while creation as SystemAssigned.这通常在创建时默认设置为 SystemAssigned。 These values are taken from Managed Identities.这些值取自托管身份。

Please check the documentation for the values System Identity and Managed Identity.请查看文档以了解系统标识和托管标识的值。

From the command which I have fixed, we can change the value of any other parameter.从我修复的命令中,我们可以更改任何其他参数的值。

Refer to screenshot as I have changed value of 'properties': {"enabled": true}请参考屏幕截图,因为我已经更改了“属性”的值:{“enabled”:true}

本地截图

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在经典 Azure DevOps 管道中存储 AWS CLI 命令的结果 - How to store result of a AWS CLI command in Classic Azure DevOps Pipeline 无法使用 Azure 发布管道通过 Azure CLI 命令更新逻辑应用程序 JSON 文件 - Logic App JSON file could not be update through Azure CLI Command using Azure Release Pipeline 如何将 azure cli 命令的 output 添加到 github 操作 - How do I add output of azure cli command to github actions Azure CLI 将值传递给其他命令 Azure 命令 - Azure CLI Passing Value To Other Azure Command 如何在启动时从 Azure Docker 容器发出 CLI 命令(或使用 Azure SDK) - How to issue a CLI command (or make use of Azure SDK) from an Azure Docker Container at startup Bitbucket 使用 Azure-cli 命令部署到 Azure VM 的管道无法访问脚本文件 - Bitbucket pipeline to deploy to Azure VM using Azure-cli command cannot access to script file 如何使用 Azure CLI 从特定的 Azure 存储帐户获取所有容器? - How to Get All the Containers From a Specific Azure Storage Account using Azure CLI? 如何使用 azure CLI 检查 Loganalytic alertrule 是否存在 - How to check the existance of a Loganalytic alertrule using azure CLI 如何使用 REST API 列出 azure 回购中内容的文件 - How to list the files with content that are in azure repo using REST API 如何将 python 脚本 arguments 传递给 Azure CLI `az ml run submit-script` 命令? - How do I pass in python script arguments to Azure CLI `az ml run submit-script` command?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM