gpt4 book ai didi

azure - Set-AzureRmResource 抛出 api 版本错误

转载 作者:行者123 更新时间:2023-12-03 01:40:15 28 4
gpt4 key购买 nike

我正在尝试以编程方式向 Azure 政府中的资源添加标签。当我尝试在没有标签的资源上设置标签时,我使用 Set-AzureRmResource 命令。我已经尝试设置 ApiVersion 和不设置(不应该使用最新版本)当我使用调试标志时,它显示正在设置的版本,但我仍然收到下面的错误。

Set-AzureRmResource : Cannot validate argument on parameter 'ResourceId'. The argument is null or empty. Provide an
argument that is not null or empty, and then try the command again.
At line:1 char:108
+ ... ONMENT=""; ORGANIZATION="" } -ResourceId $resource.ResourceId -Force ...
+ ~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidData: (:) [Set-AzureRmResource], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationError,Microsoft.Azure.Commands.ResourceManager.Cmdlets.Implem
entation.SetAzureResourceCmdlet

我尝试运行的代码片段如下。

Set-AzureRmResource -Tag @{ ENVIRONMENT=""; ORGANIZATION="" } -ResourceId $resource.ResourceId  -Force

编辑:指定 Azure 政府编辑 2:从代码中删除了显式版本设置

最佳答案

我尝试在 Azure Government 中使用新的 Az 命令:

Set-AzResource -Tag @{ ENVIRONMENT=""; ORGANIZATION="" } -ResourceId $resource.ResourceId  -Force

..这对我来说效果很好。 (我使用旧的 AzureRm 命令遇到序列化错误)。仅供引用...不确定您昨天何时尝试过,但存在 DNS 问题,导致一些服务中断,这可能导致错误的错误。

关于azure - Set-AzureRmResource 抛出 api 版本错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54422716/

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