如何在 PowerShell 中使用 Az CLI 命令登录 Azure 帐户?

要使用 Azure CLI 登录 Azure 帐户,我们需要使用az login命令。键入az login命令后,它会提示您输入 Azure 门户登录控制台。

如果需要在浏览器中使用设备验证码登录,则需要使用参数--use-device-code。

PS C:\> az login --use-device-code
To sign in, use a web browser to open the page https://microsoft.com/devicelogin and enter the code ‘DeviceCode’ to authenticate.

您需要打开一个网站https://microsoft.com/devicelogin/并输入代码。如果您尚未连接到 Microsoft Azure 门户,则需要先登录。

您还可以在命令行中提供用户名和密码,如下所示。

PS C:\> az login --username azureusername --password azurepassword

如果没有提供密码,它会提示输入密码。

PS C:\> az login --username azureuseraccount
Password:

猜你喜欢