gpt4 book ai didi

azure - 获取-AzResourceGroup : 'this.Client.SubscriptionId' cannot be null

转载 作者:行者123 更新时间:2023-12-02 23:35:48 24 4
gpt4 key购买 nike

Azure 和 Powershell 存在一些问题。我只是检查资源组是否存在,但一直遇到此错误。此后的下一步是创建资源组(如果不存在),但这也会引发相同的错误。希望有人能够提出一些解决方法或修复建议。

请注意,我有权访问订阅,我可以看到它们并成功设置默认订阅,如下面的脚本所示。

返回完整错误

'this.Client.SubscriptionId' cannot be null.
At **********************\envir\create-env.ps1:21 char:1
+ Get-AzResourceGroup -Name $resourceGroup -ErrorVariable $doesNotExist ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : CloseError: (:) [Get-AzResourceGroup], ValidationException
+ FullyQualifiedErrorId : Microsoft.Azure.Commands.ResourceManager.Cmdlets.Implementation.GetAzureResourceGroupCmdlet

我刚刚安装了 Az 模块,版本详细信息如下。

Version    Name                                Repository
------- ---- ----------
1.6.0 Az PSGallery

我只是运行一个非常简单的脚本(如下),我认为这可能与未设置默认订阅有关,但设置没有任何区别。

$passwd = ConvertTo-SecureString $servicePrincipalKey -AsPlainText -Force
$pscredential = New-Object
System.Management.Automation.PSCredential($servicePrincipalUserName, $passwd)
Connect-AzAccount -ServicePrincipal -Credential $pscredential -TenantId $tenantId
Select-AzureSubscription -Default -SubscriptionName $subscriptioName
Get-AzResourceGroup -Name $resourceGroup -ErrorVariable $doesNotExist

然后我收到上面列出的错误。

最佳答案

我发现了问题,我创建的服务主体没有足够的权限访问@4c74356b41建议的订阅,我最终给了它贡献者的角色,这解决了问题。

关于azure - 获取-AzResourceGroup : 'this.Client.SubscriptionId' cannot be null,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55538160/

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