作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
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/
Azure 和 Powershell 存在一些问题。我只是检查资源组是否存在,但一直遇到此错误。此后的下一步是创建资源组(如果不存在),但这也会引发相同的错误。希望有人能够提出一些解决方法或修复建议。
我是一名优秀的程序员,十分优秀!