使用 Azure Sphere CLI 登录
重要
这是 Azure Sphere(旧版)文档。 Azure Sphere(旧版)将于 2027 年 9 月 27 日停用,用户此时必须迁移到 Azure Sphere(集成)。 使用位于 TOC 上方的版本选择器查看 Azure Sphere(集成)文档。
Azure Sphere CLI 提供两种身份验证类型来登录到 Azure Sphere 安全服务。 最简单的入门方法是使用 Azure Sphere CLI,该 CLI 会自动使用浏览器登录。 如果 CLI 无法启动浏览器,则可以使用设备代码进行身份验证。
以交互方式登录
Azure Sphere CLI 中的默认身份验证方法使用默认 Web 浏览器登录。
若要登录,请运行 azsphere login 命令。 例如:
azsphere login
---------------------
Name
=====================
bob@contoso.com
---------------------
打开默认 Web 浏览器并加载一个 Azure Sphere 登录页,提示你登录。 如果列表包含用于 Azure Sphere 的标识,请选择该标识。 如果没有,请输入适当的凭据。
使用设备代码登录
如果 CLI 无法打开默认 Web 浏览器,或者默认 Web 浏览器不可用,则可以使用设备代码使用命令 azsphere login --use-device-code 登录。
- 打开浏览器并 https://aka.ms/devicelogin 输入终端中显示的授权代码。
- 在浏览器中使用帐户凭据登录。
例如:
azsphere login --use-device-code
To sign in, use a web browser to open the page https://microsoft.com/devicelogin and enter the code <device-code> to authenticate.
---------------------
Name
=====================
bob@contoso.com
---------------------