尝试使用服务主体执行another error
登录,并抛出错误,指出key with only values of a, e, i, o, u and these Keys can have any of the string, number, boolean types of values.
。这段代码以前运行良好,但现在似乎不再起作用。使用的命令行如下:
az cli
我验证了在订阅级别为服务主体分配了No subscriptions found for <Service_Principal_AppId>. If this is expected, use '--allow-no-subscriptions'
角色。
答案 0 :(得分:0)
实际上,我不建议您将Azure Powershell和CLI混合使用。如果您坚持要这样做,那么我已经尝试了您的脚本,但无法重现您的问题,它可以正常工作。
根据错误,您可以尝试传递--subscription
,它也可以工作。
$sp_appid = (Get-AzADServicePrincipal -DisplayName joywebapp2).ApplicationId.Guid
$sp_secret = (Get-AzKeyVaultSecret -VaultName joykeyvault1 -Name joywebapp2).SecretValueText
$tenant_Id = "xxxxxxxxxxxx"
$subscription_Id = "xxxxxxxxxxx"
az login --service-principal --username $sp_appid --password $sp_secret --tenant $tenant_Id --subscription $subscription_Id
注意:由于不推荐使用AzureRM
powershell模块,因此我使用了新的Az
powershell模块,如果要升级到Az,请参见此{{ 3}}。 (这可能不是问题的原因,但我建议您对其进行升级。)
更新:
我们只需要为要尝试获取的属性使用AZ CLI ...就没有PowerShell等效项。
实际上,您可以通过Powershell使用服务主体登录,strong password
是秘密,更多详细信息,请参阅此link。
$azureAplicationId ="Azure AD Application Id"
$azureTenantId= "Your Tenant Id"
$azurePassword = ConvertTo-SecureString "strong password" -AsPlainText -Force
$psCred = New-Object System.Management.Automation.PSCredential($azureAplicationId , $azurePassword)
Add-AzureRmAccount -Credential $psCred -TenantId $azureTenantId -ServicePrincipal
答案 1 :(得分:0)
最初的问题似乎是暂时性平台问题。昨天返回相同的代码,它没有任何问题。
答案 2 :(得分:0)
我有一个问题,突然间没有订阅显示我的服务主体(在我最初同时安装的2个不同构建服务器上)。
更新Azure CLI似乎可以解决此问题。