0

作为一名 Azure 初学者,我正在尝试配置一个基本的 Ubuntu VM。我从http://azure.microsoft.com页面的“免费试用”链接开始创建帐户。我成功创建了一个帐户,并且可以在https://portal.azure.com看到管理控制台。然后我安装了最新的基于 node.js 的 CLI(Mac OS X 上的 0.10.1)。

我下载了一个 .publishsettings 文件,azure account download并使用 .publishsettings 成功加载了它azure account import。我现在可以看到我的帐户azure account list(名称为“免费试用”,当前为“真实”)。

然后我通过 将 CLI 置于资源管理器模式azure config mode arm。这是因为我的目标是使用这个101-vm-simple-linux资源管理器模板创建我的基本 VM。为此,我将按照资源管理器模板演练中的说明进行操作。

我尝试使用 azure 命令行工具会产生此错误:

您当前的订阅可能是从 publishsettings 文件创建的,并且在 arm 模式下无法工作。您可以通过运行“azure login”或“azure accout set”来修复它

当我按照要求进行操作时,我从登录命令本身收到了基本相同的错误消息:

% azure login -u 'the account id I just signed up with' info: Executing command login Password: *************** Authenticating... error: Interactive login is required. Use 'azure login' to interactively login. info: Error information has been recorded to /Users/kent/.azure/azure.err error: login command failed

有人可以告诉我如何使用 Azure CLI 成功登录以便继续吗?

4

3 回答 3

1

如果您尝试使用用于创建 Azure 订阅的Microsoft 帐户(例如 johndoe@hotmail.com)进行身份验证,则会收到此错误。

您需要将组织用户(或服务主体)添加到 Azure 租户的 Azure Active Directory。此处提供了有关如何执行此操作的说明。

然后,让该用户成为您订阅的共同管理员。为此,在旧门户 (manage.windowsazure.com) 中,单击左侧导航中的设置(位于最底部)。在“设置”页面中,单击“管理员”选项卡。然后,单击页面底部的添加以将您之前创建的用户添加为订阅的管理员。

在此处输入图像描述

现在,您可以使用此组织用户的用户身份从 CLI 登录。例如:

azure login -u johndoe@xyz.onmicrosoft.com

此处提供了有关此方案和其他从 CLI 进行身份验证的方法的更多信息。

于 2016-06-18T00:59:00.700 回答
0

输入“azure login”,然后会提示您输入 url 和设备代码。将其输入网站,然后您应该可以使用“azure login -u email-address”登录

于 2016-06-18T00:44:15.300 回答
0

我想补充一点,因为--username-u有多种用途。

-u也适用于服务主体。当您在没有用户交互的情况下运行任务时,服务主体很有用。

使用Azure CLI 2.0,这将与以下命令一起使用:

az login --service-principal -u "${clientId}" -p "${clientSecret}" -t "${tenantId}"

您可以通过创建Active Directory 应用程序来获取这些变量。

下面是登录命令的 Azure CLI 2.0 的 --help 输出:

 Command
    az login: Log in to access Azure subscriptions.

Arguments
    --password -p      : User password or client secret. Will prompt if not given.
    --service-principal: The credential representing a service principal.
    --tenant -t        : The tenant associated with the service principal.
    --username -u      : Organization id or service principal.

Global Arguments
    --debug            : Increase logging verbosity to show all debug logs.
    --help -h          : Show this help message and exit.
    --output -o        : Output format.  Allowed values: json, jsonc, table, tsv.  Default: json.
    --query            : JMESPath query string. See http://jmespath.org/ for more information and
                         examples.
    --verbose          : Increase logging verbosity. Use --debug for full debug logs.

Examples
    Log in interactively.
        az login

    Log in with user name and password. This doesn't work with Microsoft accounts or accounts that
    have two-factor authentication enabled.
        az login -u johndoe@contoso.com -p VerySecret

    Log in with a service principal.
        az login --service-principal -u http://azure-cli-2016-08-05-14-31-15 -p VerySecret --tenant
        contoso.onmicrosoft.com
于 2017-03-08T00:12:39.090 回答