gpt4 book ai didi

Azure 设置订阅命令通过 shell 脚本失败,但无需 shell 脚本即可工作

转载 作者:行者123 更新时间:2023-12-03 00:59:34 26 4
gpt4 key购买 nike

我只是尝试通过 shell 脚本执行一组 AZ 命令。

az account set --subscription "test-subscription"

如果我在 az login 之后直接在 powershell 上运行该命令,它工作正常。

但是如果我通过 shell 脚本运行相同的命令,则会抛出 AzureCloud 中不存在订阅的错误。

更新:

az account show 命令的输出

{
"environmentName": "AzureCloud",
"homeTenantId": "xxx-xx-xx-x",
"id": "xx-xx-xx-x-xx",
"isDefault": true,
"managedByTenants": [
{
"tenantId": "xx-xx-xxx-xx-xx"
}
],
"name": "subscription-name",
"state": "Enabled",
"tenantId": "xx-xx-xx-xxx",
"user": {
"name": "f<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="a3cd8dcfcde3dbdb8dc0ccce" rel="noreferrer noopener nofollow">[email protected]</a>",
"type": "user"
}
}

最佳答案

登录时尝试指定 --tenant 为订阅的租户 ID。

az login --tenant '<tenant-id>'

然后使用

az account set --subscription '<subscription-id>'

关于Azure 设置订阅命令通过 shell 脚本失败,但无需 shell 脚本即可工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62852293/

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