
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Connect Azure Account Using PowerShell
To connect the azure account with PowerShell, we can use the Connect-AZAccount command. If we check the command parameters from the below URL, there are multiple methods we can connect to the azure account but in this article, we will use the simple methods to connect.
Using the Interactive console to connect portal
Using DeviceLogin method.
Using Credentials method.
Using the Interactive console method to connect the portal.
When we use the Connect-AZAccount directly without any parameter, it will open a popup for the azure portal credential.
You need to enter your Azure credentials there.
Using Device Login method.
In this method, Connect-AZAccount uses the parameter -DeviceLogin. Once you run the command, it will show the code on the console window and that code we need to enter on the website,
Example
Connect-AzAccount -DeviceCode
Output
WARNING: To sign in, use a web browser to open the page https://microsoft.com/devicelogin and enter the code SAYX4512 to authenticate.
As shown in the above output, you need to enter display code on the website,https://Microsoft.com/DeviceLogin and if you are not already authenticated you need to enter Azure credentials there.
Using Credentials Method.
You can direct provide Azure user credentials in the Get-Credentials command and use those credentials in Connect-AZAccount .
Example
$creds = Get-Credential Connect-AZAccount -Credential $creds
Once you enter the correct credentials, your account will be connected. But if your organization has configured the multi-factor authentication this method won’t work and likely it will produce an error.